forked from Ericsson/ecchronos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Paul Chandler
committed
Oct 21, 2024
1 parent
e32e352
commit 41b3823
Showing
16 changed files
with
292 additions
and
844 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...in/java/com/ericsson/bss/cassandra/ecchronos/application/spring/EccNodeStateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* Copyright 2024 Telefonaktiebolaget LM Ericsson | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ericsson.bss.cassandra.ecchronos.application.spring; | ||
|
||
import com.datastax.oss.driver.api.core.metadata.Node; | ||
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 EccNodesSync myEccNodesSync; | ||
private DistributedJmxConnectionProvider myJmxConnectionProvider; | ||
ExecutorService service ; | ||
|
||
|
||
|
||
AgentNativeConnectionProvider myAgentNativeConnectionProvider = null; | ||
public EccNodeStateListener () | ||
{ | ||
service = Executors.newFixedThreadPool(4); | ||
} | ||
private static final Logger LOG = LoggerFactory.getLogger(EccNodeStateListener.class); | ||
|
||
@Override | ||
public void onAdd(Node node) | ||
{ | ||
|
||
LOG.info("Node added {}", node.getHostId()); | ||
NodeAddedAction callable = new NodeAddedAction(myEccNodesSync, myJmxConnectionProvider, myAgentNativeConnectionProvider, node ); | ||
service.submit(callable); | ||
|
||
} | ||
|
||
@Override | ||
public void onUp(Node node) | ||
{ | ||
LOG.info("Node up {}", node.getHostId()); | ||
} | ||
|
||
@Override | ||
public void onDown(Node node) | ||
{ | ||
LOG.info("Node Down {}", node.getHostId()); | ||
} | ||
|
||
@Override | ||
public void onRemove(Node node) | ||
{ | ||
LOG.info("Node removed {}", node.getHostId()); | ||
NodeRemovedAction callable = new NodeRemovedAction(myEccNodesSync, myJmxConnectionProvider, myAgentNativeConnectionProvider, node ); | ||
service.submit(callable); | ||
} | ||
|
||
@Override | ||
public void close() throws Exception | ||
{ | ||
} | ||
|
||
public void setJmxConnectionProvider(DistributedJmxConnectionProvider myJmxConnectionProvider) | ||
{ | ||
this.myJmxConnectionProvider = myJmxConnectionProvider; | ||
} | ||
|
||
public void setAgentNativeConnectionProvider(AgentNativeConnectionProvider myAgentNativeConnectionProvider) | ||
{ | ||
this.myAgentNativeConnectionProvider = myAgentNativeConnectionProvider; | ||
} | ||
|
||
public void setEccNodesSync(EccNodesSync eccNodesSync) { | ||
this.myEccNodesSync = eccNodesSync; | ||
} | ||
|
||
} |
73 changes: 73 additions & 0 deletions
73
...rc/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeAddedAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright 2024 Telefonaktiebolaget LM Ericsson | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ericsson.bss.cassandra.ecchronos.application.spring; | ||
|
||
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 org.springframework.scheduling.annotation.Async; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.concurrent.Callable; | ||
import java.util.concurrent.CompletableFuture; | ||
import com.datastax.oss.driver.api.core.metadata.Node; | ||
|
||
|
||
public class NodeAddedAction implements Callable<Boolean> { | ||
|
||
|
||
private static final Logger LOG = LoggerFactory.getLogger(com.ericsson.bss.cassandra.ecchronos.application.spring.NodeAddedAction.class); | ||
|
||
private final EccNodesSync myEccNodesSync; | ||
private final DistributedJmxConnectionProvider myJmxConnectionProvider; | ||
|
||
private final DistributedNativeConnectionProvider myDistributedNativeConnectionProvider; | ||
|
||
private final Node myNode; | ||
|
||
|
||
public NodeAddedAction(EccNodesSync eccNodesSync, DistributedJmxConnectionProvider jmxConnectionProvider, DistributedNativeConnectionProvider distributedNativeConnectionProvider, Node node) | ||
{ | ||
myEccNodesSync = eccNodesSync; | ||
myJmxConnectionProvider = jmxConnectionProvider; | ||
myDistributedNativeConnectionProvider = distributedNativeConnectionProvider; | ||
myNode = node; | ||
} | ||
|
||
|
||
@Override | ||
public Boolean call() | ||
{ | ||
Boolean result = true; | ||
|
||
LOG.info("Node Up {}", myNode.getHostId()); | ||
myEccNodesSync.verifyAcquireNode(myNode); | ||
try | ||
{ | ||
myJmxConnectionProvider.add(myNode); | ||
} | ||
catch (IOException e) | ||
{ | ||
LOG.warn("Node {} JMX connection failed", myNode.getHostId()); | ||
result = false; | ||
} | ||
myDistributedNativeConnectionProvider.addNode(myNode); | ||
|
||
return result; | ||
} | ||
} |
56 changes: 0 additions & 56 deletions
56
...c/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeChangeRecord.java
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
...src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeComparator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.