diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeChangeRecord.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeChangeRecord.java index bb2ebd62..849f8e9e 100644 --- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeChangeRecord.java +++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeChangeRecord.java @@ -17,7 +17,8 @@ import com.datastax.oss.driver.api.core.metadata.Node; -public class NodeChangeRecord { +public class NodeChangeRecord +{ enum NodeChangeType { INSERT, @@ -35,7 +36,7 @@ public NodeChangeRecord(final Node node, final NodeChangeType type) } /*** - * returns the node that has changed + * returns the node that has changed. * * @return */ @@ -45,7 +46,7 @@ public Node getNode() } /*** - * Returns the change type can be either INSERT, DELETE or UPDATE + * Returns the change type can be either INSERT, DELETE or UPDATE. * @return */ public NodeChangeType getType() diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeListComparator.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeListComparator.java index cebe5d8e..8063520c 100644 --- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeListComparator.java +++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/NodeListComparator.java @@ -24,8 +24,8 @@ import java.util.List; -public class NodeListComparator { - +public class NodeListComparator +{ private static final Logger LOG = LoggerFactory.getLogger(NodeListComparator.class); /*** @@ -65,7 +65,7 @@ List compareNodeLists(final List oldNodes, final List compareNodeLists(final List oldNodes, final List iterator) + private Node getNode(final Iterator iterator) { Node node; - if ( iterator.hasNext()) + if ( iterator.hasNext()) { node = iterator.next(); - else + } + else { node = null; + } return node; } } diff --git a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/ReloadNodesService.java b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/ReloadNodesService.java index d773c98f..20e49736 100644 --- a/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/ReloadNodesService.java +++ b/application/src/main/java/com/ericsson/bss/cassandra/ecchronos/application/spring/ReloadNodesService.java @@ -72,7 +72,7 @@ public void startScheduler() { long reLoadIntervalInMills = reLoadInterval.getInterval(TimeUnit.MILLISECONDS); LOG.info("Starting ReloadNodesService with reLoadInterval={} ms", reLoadIntervalInMills); - myScheduler.scheduleWithFixedDelay(this::reloadNodes, reLoadIntervalInMills,reLoadIntervalInMills, TimeUnit.MILLISECONDS); + myScheduler.scheduleWithFixedDelay(this::reloadNodes, reLoadIntervalInMills, reLoadIntervalInMills, TimeUnit.MILLISECONDS); } @VisibleForTesting @@ -81,7 +81,7 @@ void reloadNodes() List oldNodes = myDistributedNativeConnectionProvider.getNodes(); List newNodes = myDistributedNativeConnectionProvider.reloadNodes(); CqlSession cqlSession = myDistributedNativeConnectionProvider.getCqlSession(); - List nodeChangeList = nodeListComparator.compareNodeLists(oldNodes,newNodes); + List nodeChangeList = nodeListComparator.compareNodeLists(oldNodes, newNodes); if (!nodeChangeList.isEmpty()) { myDistributedNativeConnectionProvider.setNodes(newNodes); @@ -89,17 +89,19 @@ void reloadNodes() while (iterator.hasNext()) { NodeChangeRecord nodeChangeRecord = iterator.next(); - if ( nodeChangeRecord.getType() == NodeChangeRecord.NodeChangeType.INSERT){ + if (nodeChangeRecord.getType() == NodeChangeRecord.NodeChangeType.INSERT) + { myEccNodesSync.verifyAcquireNode(nodeChangeRecord.getNode()); try { myJmxConnectionProvider.add(nodeChangeRecord.getNode()); - } catch (IOException e) { - LOG.info("Node {} JMX connection failed", nodeChangeRecord.getNode().getHostId() ); + } catch (IOException e) + { + LOG.info("Node {} JMX connection failed", nodeChangeRecord.getNode().getHostId()); } } if ( nodeChangeRecord.getType() == NodeChangeRecord.NodeChangeType.DELETE){ - myEccNodesSync.deleteNodeStatus(nodeChangeRecord.getNode().getDatacenter(),nodeChangeRecord.getNode().getHostId()); + myEccNodesSync.deleteNodeStatus(nodeChangeRecord.getNode().getDatacenter(), nodeChangeRecord.getNode().getHostId()); try { myJmxConnectionProvider.close(nodeChangeRecord.getNode().getHostId()); @@ -114,7 +116,7 @@ void reloadNodes() } /*** - * Shutsdown the scheduler + * Shutsdown the scheduler. */ @Override public void destroy()