Skip to content

Commit

Permalink
Ericsson#699 Reload nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Chandler committed Oct 21, 2024
1 parent abed199 commit a44fe4a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.auth.AuthProvider;
import com.datastax.oss.driver.api.core.metadata.Node;
import com.datastax.oss.driver.api.core.metadata.NodeStateListener;
import com.datastax.oss.driver.api.core.ssl.SslEngineFactory;
import com.ericsson.bss.cassandra.ecchronos.application.config.Config;
import com.ericsson.bss.cassandra.ecchronos.application.config.connection.AgentConnectionConfig;
Expand Down Expand Up @@ -307,14 +306,22 @@ public void close() throws IOException
{
myDistributedNativeConnectionProviderImpl.close();
}

/**
* Add a nw node to the list of nodes.
* @param myNode
*/
@Override
public void addNode(Node myNode) {
public void addNode(Node myNode)
{
myDistributedNativeConnectionProviderImpl.addNode(myNode);
}

/**
* Remove node for the list of nodes.
* @param node
*/
@Override
public void removeNode(Node myNode) {
public void removeNode(Node myNode)
{
myDistributedNativeConnectionProviderImpl.removeNode(myNode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@
import com.datastax.oss.driver.api.core.metadata.NodeStateListener;
import com.ericsson.bss.cassandra.ecchronos.application.providers.AgentNativeConnectionProvider;
import com.ericsson.bss.cassandra.ecchronos.connection.DistributedJmxConnectionProvider;
import com.ericsson.bss.cassandra.ecchronos.connection.DistributedNativeConnectionProvider;

import com.ericsson.bss.cassandra.ecchronos.data.sync.EccNodesSync;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class EccNodeStateListener implements NodeStateListener
{
private final Integer NO_OF_THREADS= 4;
private EccNodesSync myEccNodesSync;
private DistributedJmxConnectionProvider myJmxConnectionProvider;
ExecutorService service ;



AgentNativeConnectionProvider myAgentNativeConnectionProvider = null;
public EccNodeStateListener ()
private ExecutorService service;
private AgentNativeConnectionProvider myAgentNativeConnectionProvider = null;
public EccNodeStateListener()
{
service = Executors.newFixedThreadPool(4);
service = Executors.newFixedThreadPool(NO_OF_THREADS);
}
private static final Logger LOG = LoggerFactory.getLogger(EccNodeStateListener.class);

/**
* Invoked when a node is first added to the cluster.
* @param node
*/
@Override
public void onAdd(Node node)
{
Expand All @@ -53,18 +53,30 @@ public void onAdd(Node node)

}

/**
* Invoked when a node's state switches to NodeState.UP.
* @param node
*/
@Override
public void onUp(Node node)
{
LOG.info("Node up {}", node.getHostId());
}

/**
* Invoked when a node's state switches to NodeState.DOWN or NodeState.FORCED_DOWN.
* @param node
*/
@Override
public void onDown(Node node)
{
LOG.info("Node Down {}", node.getHostId());
}

/**
* Invoked when a node leaves the cluster.
* @param node
*/
@Override
public void onRemove(Node node)
{
Expand All @@ -78,16 +90,29 @@ public void close() throws Exception
{
}

/**
* jmxConnectionProvider setter.
* @param myJmxConnectionProvider
*/
public void setJmxConnectionProvider(DistributedJmxConnectionProvider myJmxConnectionProvider)
{
this.myJmxConnectionProvider = myJmxConnectionProvider;
}

/**
* agentNativeConnectionProvider setter.
* @param myAgentNativeConnectionProvider
*/

public void setAgentNativeConnectionProvider(AgentNativeConnectionProvider myAgentNativeConnectionProvider)
{
this.myAgentNativeConnectionProvider = myAgentNativeConnectionProvider;
}

/**
* eccNodesSync setter.
* @param eccNodesSync
*/
public void setEccNodesSync(EccNodesSync eccNodesSync) {
this.myEccNodesSync = eccNodesSync;
}
Expand Down

0 comments on commit a44fe4a

Please sign in to comment.