From 49ae7927cb3137ed8ae645278082d03c83ffd940 Mon Sep 17 00:00:00 2001 From: highstreetherbert Date: Fri, 10 Jul 2020 17:47:11 +0200 Subject: Reformat sdnr netconfnode-state-service to ONAP code style Reformat to ONAP code style Issue-ID: SDNC-1276 Signed-off-by: highstreetherbert Change-Id: Ib7faecb419770d8ffb4b25d5d34446a2cd71fc7f Signed-off-by: highstreetherbert --- .../impl/GenericTransactionUtils.java | 13 +- .../impl/NetconfAccessorImpl.java | 20 ++- .../impl/NetconfNodeStateServiceImpl.java | 176 +++++++++++---------- .../impl/conf/odlAkka/AkkaConfig.java | 9 +- .../impl/conf/odlAkka/ClusterConfig.java | 46 +++--- .../impl/conf/odlAkka/ClusterNodeInfo.java | 19 +-- .../impl/conf/odlGeo/ClusterRoleInfo.java | 14 +- .../conf/odlGeo/ClusterRoleInfoCollection.java | 4 +- .../impl/conf/odlGeo/GeoConfig.java | 4 +- .../rpc/NetconfnodeStateServiceRpcApiImpl.java | 10 +- .../impl/rpc/RpcApigetStateCallback.java | 6 +- 11 files changed, 174 insertions(+), 147 deletions(-) (limited to 'sdnr/wt/netconfnode-state-service/provider/src/main') diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java index 6a811ea59..755224027 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl; import com.google.common.base.Preconditions; @@ -58,7 +58,8 @@ public final class GenericTransactionUtils implements TransactionUtils { AtomicBoolean noErrorIndication = new AtomicBoolean(); AtomicReference statusText = new AtomicReference<>(); - @Nullable T obj = readDataOptionalWithStatus(dataBroker, dataStoreType, iid, noErrorIndication, statusText); + @Nullable + T obj = readDataOptionalWithStatus(dataBroker, dataStoreType, iid, noErrorIndication, statusText); if (!noErrorIndication.get()) { LOG.warn("Read transaction for identifier " + iid + " failed with status " + statusText.get()); @@ -84,7 +85,8 @@ public final class GenericTransactionUtils implements TransactionUtils { LogicalDatastoreType dataStoreType, InstanceIdentifier iid, AtomicBoolean noErrorIndication, AtomicReference statusIndicator) { - @Nullable T data = null; + @Nullable + T data = null; noErrorIndication.set(false); statusIndicator.set("Preconditions"); @@ -109,7 +111,8 @@ public final class GenericTransactionUtils implements TransactionUtils { statusIndicator.set("Create Read Transaction"); ReadTransaction readTransaction = dataBroker.newReadOnlyTransaction(); try { - @NonNull FluentFuture> od = readTransaction.read(dataStoreType, iid); + @NonNull + FluentFuture> od = readTransaction.read(dataStoreType, iid); statusIndicator.set("Read done"); if (od != null) { statusIndicator.set("Unwrap checkFuture done"); diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java index 654b9d7d9..433b34e49 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java @@ -58,7 +58,8 @@ public class NetconfAccessorImpl implements NetconfAccessor { /** * Contains all data to access and manage netconf device - * @param nodeId of managed netconf node + * + * @param nodeId of managed netconf node * @param netconfNode information * @param dataBroker to access node * @param mountpoint of netconfNode @@ -78,7 +79,7 @@ public class NetconfAccessorImpl implements NetconfAccessor { } /** - * @param nodeId with uuid of managed netconf node + * @param nodeId with uuid of managed netconf node * @param dataBroker to access node */ public NetconfAccessorImpl(String nodeId, NetconfNode netconfNode, DataBroker dataBroker, MountPoint mountpoint, @@ -95,31 +96,36 @@ public class NetconfAccessorImpl implements NetconfAccessor { public DataBroker getDataBroker() { return dataBroker; } + @Override public MountPoint getMountpoint() { return mountpoint; } + @Override public TransactionUtils getTransactionUtils() { return transactionUtils; } + @Override public NetconfNode getNetconfNode() { return netconfNode; } + @Override public Capabilities getCapabilites() { return capabilities; } @Override - public @NonNull ListenerRegistration doRegisterNotificationListener(@NonNull T listener) { + public @NonNull ListenerRegistration doRegisterNotificationListener( + @NonNull T listener) { log.info("Begin register listener for Mountpoint {}", mountpoint.getIdentifier().toString()); - final Optional optionalNotificationService = mountpoint - .getService(NotificationService.class); + final Optional optionalNotificationService = + mountpoint.getService(NotificationService.class); final NotificationService notificationService = optionalNotificationService.get(); - final ListenerRegistration ranListenerRegistration = notificationService - .registerNotificationListener(listener); + final ListenerRegistration ranListenerRegistration = + notificationService.registerNotificationListener(listener); log.info("End registration listener for Mountpoint {} Listener: {} Result: {}", mountpoint.getIdentifier().toString(), optionalNotificationService, ranListenerRegistration); return ranListenerRegistration; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java index adced6b33..c190346c4 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl; import java.util.Collection; @@ -144,7 +144,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc this.listenerL1 = null; this.listenerL2 = null; - this.initializationSuccessful= false; + this.initializationSuccessful = false; this.netconfNodeConnectListenerList = new CopyOnWriteArrayList<>(); this.netconfNodeStateListenerList = new CopyOnWriteArrayList<>(); this.vesNotificationListenerList = new CopyOnWriteArrayList<>(); @@ -165,9 +165,11 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc public void setMountPointService(MountPointService mountPointService) { this.mountPointService = mountPointService; } + public void setClusterSingletonService(ClusterSingletonServiceProvider clusterSingletonService) { this.clusterSingletonServiceProvider = clusterSingletonService; } + public void setEntityDataProvider(IEntityDataProvider iEntityDataProvider) { this.iEntityDataProvider = iEntityDataProvider; } @@ -187,8 +189,9 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc this.clusterName = akkaConfig == null ? "" : akkaConfig.getClusterConfig().getClusterSeedNodeName("abc"); // Provide status information - ClusterConfig cc = akkaConfig==null?null:akkaConfig.getClusterConfig(); - this.iEntityDataProvider.setStatus(StatusKey.CLUSTER_SIZE,cc==null?"1":String.format("%d",cc.getClusterSize())); + ClusterConfig cc = akkaConfig == null ? null : akkaConfig.getClusterConfig(); + this.iEntityDataProvider.setStatus(StatusKey.CLUSTER_SIZE, + cc == null ? "1" : String.format("%d", cc.getClusterSize())); // RPC Service for specific services this.rpcApiService.setStatusCallback(this); @@ -206,6 +209,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc LOG.info("Session Initiated end. Initialization done {}", initializationSuccessful); } + /** Blueprint destroy-method method */ public void destroy() { close(); @@ -213,6 +217,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc /** * Getter + * * @return NetconfnodeStateServiceRpcApiImpl */ public NetconfnodeStateServiceRpcApiImpl getNetconfnodeStateServiceRpcApiImpl() { @@ -227,7 +232,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc @Override public @NonNull ListenerRegistration registerNetconfNodeConnectListener( final @NonNull L netconfNodeConnectListener) { - LOG.info("Register connect listener {}",netconfNodeConnectListener.getClass().getName()); + LOG.info("Register connect listener {}", netconfNodeConnectListener.getClass().getName()); netconfNodeConnectListenerList.add(netconfNodeConnectListener); return new ListenerRegistration() { @@ -238,7 +243,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc @Override public void close() { - LOG.info("Remove connect listener {}",netconfNodeConnectListener); + LOG.info("Remove connect listener {}", netconfNodeConnectListener); netconfNodeConnectListenerList.remove(netconfNodeConnectListener); } }; @@ -247,7 +252,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc @Override public @NonNull ListenerRegistration registerNetconfNodeStateListener( @NonNull L netconfNodeStateListener) { - LOG.info("Register state listener {}",netconfNodeStateListener.getClass().getName()); + LOG.info("Register state listener {}", netconfNodeStateListener.getClass().getName()); netconfNodeStateListenerList.add(netconfNodeStateListener); return new ListenerRegistration() { @@ -258,7 +263,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc @Override public void close() { - LOG.info("Remove state listener {}",netconfNodeStateListener); + LOG.info("Remove state listener {}", netconfNodeStateListener); netconfNodeStateListenerList.remove(netconfNodeStateListener); } }; @@ -267,7 +272,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc @Override public @NonNull ListenerRegistration registerVesNotifications( @NonNull L vesNotificationListener) { - LOG.info("Register Ves notification listener {}",vesNotificationListener.getClass().getName()); + LOG.info("Register Ves notification listener {}", vesNotificationListener.getClass().getName()); vesNotificationListenerList.add(vesNotificationListener); return new ListenerRegistration() { @@ -278,7 +283,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc @Override public void close() { - LOG.info("Remove Ves notification listener {}",vesNotificationListener); + LOG.info("Remove Ves notification listener {}", vesNotificationListener); vesNotificationListenerList.remove(vesNotificationListener); } }; @@ -311,6 +316,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc /** * Indication if init() of this bundle successfully done. + * * @return true if init() was successful. False if not done or not successful. */ public boolean isInitializationSuccessful() { @@ -322,8 +328,9 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc */ /** - * For each mounted device a mountpoint is created and this listener is called. - * Mountpoint was created or existing. Managed device is now fully connected to node/mountpoint. + * For each mounted device a mountpoint is created and this listener is called. Mountpoint was created or existing. + * Managed device is now fully connected to node/mountpoint. + * * @param nNodeId id of the mountpoint * @param netconfNode mountpoint contents */ @@ -349,8 +356,8 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc LOG.info("isNetconfNodeMaster indication {} for mountpoint {}", isNetconfNodeMaster, mountPointNodeName); if (isNetconfNodeMaster) { - InstanceIdentifier instanceIdentifier = NETCONF_TOPO_IID.child(Node.class, - new NodeKey(new NodeId(mountPointNodeName))); + InstanceIdentifier instanceIdentifier = + NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(mountPointNodeName))); Optional optionalMountPoint = null; int timeout = 10000; @@ -399,6 +406,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc /** * Leave the connected status to a non connected or removed status for master mountpoint + * * @param action that occurred * @param nNodeId id of the mountpoint * @param netconfNode mountpoint contents or not available on remove @@ -407,8 +415,8 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc String mountPointNodeName = nNodeId.getValue(); LOG.info("netconfNode id {}", mountPointNodeName); - InstanceIdentifier instanceIdentifier = NETCONF_TOPO_IID.child(Node.class, - new NodeKey(new NodeId(mountPointNodeName))); + InstanceIdentifier instanceIdentifier = + NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(mountPointNodeName))); Optional optionalMountPoint = mountPointService.getMountPoint(instanceIdentifier); if (optionalMountPoint.isPresent()) { Optional optionalNetconfNodeDatabroker = optionalMountPoint.get().getService(DataBroker.class); @@ -436,15 +444,14 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc final DataObjectModification root = change.getRootNode(); //if (LOG.isTraceEnabled()) { - LOG.info /*trace*/("Handle this modificationType:{} path:{} root:{}", root.getModificationType(), - change.getRootPath(), root); + LOG.info /*trace*/("Handle this modificationType:{} path:{} root:{}", root.getModificationType(), + change.getRootPath(), root); //} // Catch potential nullpointer exceptions .. try { ModificationType modificationTyp = root.getModificationType(); - Node node = modificationTyp == ModificationType.DELETE ? root.getDataBefore() - : root.getDataAfter(); + Node node = modificationTyp == ModificationType.DELETE ? root.getDataBefore() : root.getDataAfter(); NodeId nodeId = node != null ? node.getNodeId() : null; if (nodeId != null) { if (nodeId.equals(CONTROLLER)) { @@ -453,70 +460,70 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc } else { if (modificationTyp != null) { switch (modificationTyp) { - case SUBTREE_MODIFIED: // Create or modify sub level node - case WRITE: // Create or modify top level node - // Treat an overwrite as an update - // leaveconnected state.before = connected; state.after != connected - // enterConnected state.after == connected - // => Here create or update by checking root.getDataBefore() != null - - boolean connectedBefore, connectedAfter, created=false; - NetconfNode nNodeAfter = getNetconfNode(root.getDataAfter()); - connectedAfter = isConnected(nNodeAfter); - if (root.getDataBefore() != null) { - // It is an update - NetconfNode nodeBefore = getNetconfNode(root.getDataBefore()); - connectedBefore = isConnected(nodeBefore); - } else { - // It is a create - connectedBefore = false; - created = true; - } - - LOG.info( - "L1 NETCONF Node change with id:{} ConnectedBefore:{} connectedAfter {}:cluster status:{} akkaIsCluster:{}", - nodeId, connectedBefore, connectedAfter, - getClusteredConnectionStatus(nNodeAfter), isCluster); - - if(created) { - netconfNodeStateListenerList.forEach(item -> { - try { - item.onCreated(nodeId, nNodeAfter); - } catch (Exception e) { - LOG.info("Exception during onCreated listener call", e); - } - }); - } - if (!connectedBefore && connectedAfter) { - enterConnectedState(nodeId, nNodeAfter); - } else { - LOG.debug("State change {} {}", connectedBefore, connectedAfter); - if (connectedBefore && !connectedAfter) { - leaveConnectedState(nodeId, Optional.of(nNodeAfter)); + case SUBTREE_MODIFIED: // Create or modify sub level node + case WRITE: // Create or modify top level node + // Treat an overwrite as an update + // leaveconnected state.before = connected; state.after != connected + // enterConnected state.after == connected + // => Here create or update by checking root.getDataBefore() != null + + boolean connectedBefore, connectedAfter, created = false; + NetconfNode nNodeAfter = getNetconfNode(root.getDataAfter()); + connectedAfter = isConnected(nNodeAfter); + if (root.getDataBefore() != null) { + // It is an update + NetconfNode nodeBefore = getNetconfNode(root.getDataBefore()); + connectedBefore = isConnected(nodeBefore); + } else { + // It is a create + connectedBefore = false; + created = true; + } + + LOG.info( + "L1 NETCONF Node change with id:{} ConnectedBefore:{} connectedAfter {}:cluster status:{} akkaIsCluster:{}", + nodeId, connectedBefore, connectedAfter, + getClusteredConnectionStatus(nNodeAfter), isCluster); + + if (created) { + netconfNodeStateListenerList.forEach(item -> { + try { + item.onCreated(nodeId, nNodeAfter); + } catch (Exception e) { + LOG.info("Exception during onCreated listener call", e); + } + }); + } + if (!connectedBefore && connectedAfter) { + enterConnectedState(nodeId, nNodeAfter); + } else { + LOG.debug("State change {} {}", connectedBefore, connectedAfter); + if (connectedBefore && !connectedAfter) { + leaveConnectedState(nodeId, Optional.of(nNodeAfter)); + } + netconfNodeStateListenerList.forEach(item -> { + try { + item.onStateChange(nodeId, nNodeAfter); + } catch (Exception e) { + LOG.info("Exception during onStateChange listener call", e); + } + }); } + // doProcessing(update ? Action.UPDATE : Action.CREATE, nodeId, root); + break; + case DELETE: + // Node removed + // leaveconnected state.before = connected; + leaveConnectedState(nodeId, Optional.empty()); netconfNodeStateListenerList.forEach(item -> { try { - item.onStateChange(nodeId, nNodeAfter); + item.onRemoved(nodeId); } catch (Exception e) { - LOG.info("Exception during onStateChange listener call", e); + LOG.info("Exception during onRemoved listener call", e); } }); - } - // doProcessing(update ? Action.UPDATE : Action.CREATE, nodeId, root); - break; - case DELETE: - // Node removed - // leaveconnected state.before = connected; - leaveConnectedState(nodeId, Optional.empty()); - netconfNodeStateListenerList.forEach(item -> { - try { - item.onRemoved(nodeId); - } catch (Exception e) { - LOG.info("Exception during onRemoved listener call", e); - } - }); - // doProcessing(Action.REMOVE, nodeId, root); - break; + // doProcessing(Action.REMOVE, nodeId, root); + break; } } } @@ -530,14 +537,13 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc // ---- subclasses for listeners /** - * Clustered listener function to select the right node from - * DataObjectModification. Called at all nodes. + * Clustered listener function to select the right node from DataObjectModification. Called at all nodes. */ private class L1 implements ClusteredDataTreeChangeListener { @Override public void onDataTreeChanged(@NonNull Collection> changes) { LOG.info("L1 TreeChange enter changes:{}", changes.size()); - new Thread( () -> onDataTreeChangedHandler(changes)).start(); + new Thread(() -> onDataTreeChangedHandler(changes)).start(); LOG.info("L1 TreeChange leave"); } } @@ -557,7 +563,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc /* --- private helpers --- */ private static @Nullable NetconfNode getNetconfNode(Node node) { - return node != null ? node.augmentation(NetconfNode.class) : null; + return node != null ? node.augmentation(NetconfNode.class) : null; } private static boolean isConnected(NetconfNode nNode) { @@ -603,7 +609,9 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc LOG.debug("check if me is responsible for node"); ClusteredConnectionStatus ccs = nNode.getClusteredConnectionStatus(); @SuppressWarnings("null") - @NonNull String masterNodeName = ccs == null || ccs.getNetconfMasterNode() == null ? "null" : ccs.getNetconfMasterNode(); + @NonNull + String masterNodeName = + ccs == null || ccs.getNetconfMasterNode() == null ? "null" : ccs.getNetconfMasterNode(); LOG.debug("sdnMasterNode=" + masterNodeName + " and sdnMyNode=" + this.clusterName); if (!masterNodeName.equals(this.clusterName)) { LOG.debug("netconf change but me is not master for this node"); diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java index d0ea0eb69..64b0edbd6 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka; import java.io.File; @@ -77,10 +77,11 @@ public class AkkaConfig { public boolean isSingleNode() { return !this.isCluster(); } - public static AkkaConfig parse(String content) throws Exception { + + public static AkkaConfig parse(String content) throws Exception { Config cfg = ConfigFactory.parseString(content); AkkaConfig c = new AkkaConfig(); - c.cluserConfig=new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster")); + c.cluserConfig = new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster")); return c; } } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java index 7f8d6cc78..47d3ec3b7 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka; import java.util.ArrayList; @@ -35,20 +35,20 @@ public class ClusterConfig { private final ClusterRoleInfoCollection roles; private ClusterNodeInfo ismeInfo; - public static ClusterConfig defaultSingleNodeConfig() - { - ClusterConfig cfg=new ClusterConfig(); - cfg.ismeInfo=ClusterNodeInfo.defaultSingleNodeInfo(); + public static ClusterConfig defaultSingleNodeConfig() { + ClusterConfig cfg = new ClusterConfig(); + cfg.ismeInfo = ClusterNodeInfo.defaultSingleNodeInfo(); cfg.seedNodes.add(cfg.ismeInfo); cfg.roles.add(ClusterRoleInfo.defaultSingleNodeRole()); return cfg; } - public ClusterConfig() - { + + public ClusterConfig() { this.seedNodes = new ArrayList<>(); this.roles = new ClusterRoleInfoCollection(); } + public ClusterConfig(Config o) throws Exception { { this.seedNodes = new ArrayList<>(); @@ -87,9 +87,9 @@ public class ClusterConfig { public String getHostName(String defaultValue) { if (getRoleMemberIndex() > 0 && getRoleMemberIndex() <= seedNodes.size()) { - return this.seedNodes.get(getRoleMemberIndex()-1).getRemoteAddress(); + return this.seedNodes.get(getRoleMemberIndex() - 1).getRemoteAddress(); } else { - LOG.warn("Seednode not available for roleMemberIndex {}. Using default {}",getRoleMember(), defaultValue); + LOG.warn("Seednode not available for roleMemberIndex {}. Using default {}", getRoleMember(), defaultValue); return defaultValue; } } @@ -97,33 +97,37 @@ public class ClusterConfig { public String getDBClusterName(String defaultValue) { String r = null; if (this.seedNodes != null && this.seedNodes.size() > 0) { - r = String.format("cluster-%s.%d", this.seedNodes.get(0).getRemoteAddress(), this.seedNodes.get(0).getPort()); + r = String.format("cluster-%s.%d", this.seedNodes.get(0).getRemoteAddress(), + this.seedNodes.get(0).getPort()); } if (r == null || r.isEmpty()) { r = defaultValue; } return r; } + public String getClusterSeedNodeName() { return this.getClusterSeedNodeName(""); } + public String getClusterSeedNodeName(String defaultValue) { - int idx=this.getRoleMemberIndex()-1; - String r=null; - if(this.seedNodes!=null && idx>=0 && this.seedNodes.size()>0 && this.seedNodes.size()>idx) - { - r=this.seedNodes.get(idx).getSeedNodeName(); + int idx = this.getRoleMemberIndex() - 1; + String r = null; + if (this.seedNodes != null && idx >= 0 && this.seedNodes.size() > 0 && this.seedNodes.size() > idx) { + r = this.seedNodes.get(idx).getSeedNodeName(); } if (r == null || r.isEmpty()) { r = defaultValue; } return r; } + public int getRoleMemberIndex() { - ClusterRoleInfo role=this.roles.get("member"); - return role!=null?role.getIndex():0; + ClusterRoleInfo role = this.roles.get("member"); + return role != null ? role.getIndex() : 0; } + public ClusterRoleInfo getRoleMember() { return this.roles.get("member"); } @@ -133,9 +137,9 @@ public class ClusterConfig { return "ClusterConfig [seedNodes=" + seedNodes + ", roles=" + roles + ", ismeInfo=" + ismeInfo + "]"; } - public int getClusterSize() { - return this.seedNodes == null ? 0 : this.seedNodes.size(); - } + public int getClusterSize() { + return this.seedNodes == null ? 0 : this.seedNodes.size(); + } } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java index ef161ad12..b27a7bd5c 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,13 +14,13 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class ClusterNodeInfo { +public class ClusterNodeInfo { private final String protocol; private final String clusterName; private final String remoteAdr; @@ -28,7 +28,7 @@ public class ClusterNodeInfo { private final String seedNodeName; public static ClusterNodeInfo defaultSingleNodeInfo() { - return new ClusterNodeInfo("akka.tcp","opendaylight-cluster-data","127.0.0.1",2550); + return new ClusterNodeInfo("akka.tcp", "opendaylight-cluster-data", "127.0.0.1", 2550); } public ClusterNodeInfo(String s) throws Exception { @@ -46,11 +46,11 @@ public class ClusterNodeInfo { } public ClusterNodeInfo(String protocol, String clustername, String remoteadr, int port) { - this.protocol=protocol; - this.clusterName=clustername; - this.remoteAdr=remoteadr; - this.port=port; - this.seedNodeName=this.protocol+"://"+this.clusterName+"@"+this.remoteAdr+":"+this.port; + this.protocol = protocol; + this.clusterName = clustername; + this.remoteAdr = remoteadr; + this.port = port; + this.seedNodeName = this.protocol + "://" + this.clusterName + "@" + this.remoteAdr + ":" + this.port; } public String getProtocol() { @@ -64,6 +64,7 @@ public class ClusterNodeInfo { public String getRemoteAddress() { return remoteAdr; } + public String getSeedNodeName() { return seedNodeName; } diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java index 994ef548b..8f4446bb4 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlGeo; import java.util.regex.Matcher; @@ -29,24 +29,25 @@ public class ClusterRoleInfo { final Pattern pattern = Pattern.compile(regex); final Matcher matcher = pattern.matcher(s); if (!matcher.find()) { - throw new Exception("unexpected role format:"+s); + throw new Exception("unexpected role format:" + s); } this.Role = matcher.group(1); this.Index = Integer.parseInt(matcher.group(2)); } private ClusterRoleInfo(String role, int idx) { - this.Role=role; - this.Index=idx; + this.Role = role; + this.Index = idx; } public static ClusterRoleInfo defaultSingleNodeRole() { - return new ClusterRoleInfo("member",1); + return new ClusterRoleInfo("member", 1); } public String getRole() { return Role; } + public int getIndex() { return Index; } @@ -84,6 +85,7 @@ public class ClusterRoleInfo { } return true; } + @Override public String toString() { return "ClusterRoleInfo [Role=" + Role + ", Index=" + Index + "]"; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java index 478ed8394..e50ac9daa 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlGeo; import java.util.ArrayList; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java index c25f3264b..5091e5219 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlGeo; import java.io.File; diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java index 9215887ff..896f010d8 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.rpc; import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.VesNotificationListener; @@ -113,9 +113,11 @@ public class NetconfnodeStateServiceRpcApiImpl implements NetconfnodeStateServic PushAttributeChangeNotificationInput input) { RpcResultBuilder result; try { - AttributeChangeNotificationBuilder attributeChangeNotificationBuilder = new AttributeChangeNotificationBuilder(); + AttributeChangeNotificationBuilder attributeChangeNotificationBuilder = + new AttributeChangeNotificationBuilder(); attributeChangeNotificationBuilder.fieldsFrom(input); - vesNotificationListenerList.forEach(item -> item.onNotification(attributeChangeNotificationBuilder.build())); + vesNotificationListenerList + .forEach(item -> item.onNotification(attributeChangeNotificationBuilder.build())); result = RpcResultBuilder.success(); } catch (Exception e) { result = RpcResultBuilder.failed(); diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java index 1434cf41a..b33c1473d 100644 --- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java +++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java @@ -1,4 +1,4 @@ -/******************************************************************************* +/* * ============LICENSE_START======================================================================== * ONAP : ccsdk feature sdnr wt * ================================================================================================= @@ -14,7 +14,7 @@ * or implied. See the License for the specific language governing permissions and limitations under * the License. * ============LICENSE_END========================================================================== - ******************************************************************************/ + */ package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.rpc; @@ -23,5 +23,5 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfn public interface RpcApigetStateCallback { - GetStatusOutputBuilder getStatus(GetStatusInput input); + GetStatusOutputBuilder getStatus(GetStatusInput input); } -- cgit 1.2.3-korg