X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=datarouter-prov%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdatarouter%2Fprovisioning%2Fbeans%2FNodeClass.java;h=f3eb1eb661670c818c7c6bde6ace5371de1ca392;hb=ce73ff52ce9aafb07d1aa4c28405328d83c816b9;hp=4c140490621710bcc84f7c88517d402253f125f0;hpb=fbb33454e311e72bd2f4fb0290babb92fd15b93c;p=dmaap%2Fdatarouter.git diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java old mode 100644 new mode 100755 index 4c140490..f3eb1eb6 --- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java +++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/NodeClass.java @@ -32,7 +32,6 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.TreeSet; - import org.apache.log4j.Logger; import org.onap.dmaap.datarouter.provisioning.utils.DB; @@ -43,6 +42,7 @@ import org.onap.dmaap.datarouter.provisioning.utils.DB; * @version $Id: NodeClass.java,v 1.2 2014/01/15 16:08:43 eby Exp $ */ public abstract class NodeClass extends Syncable { + private static Map map; private static Logger intLogger = Logger.getLogger("org.onap.dmaap.datarouter.provisioning.internal"); public NodeClass() { @@ -53,19 +53,20 @@ public abstract class NodeClass extends Syncable { } /** - * Add nodes to the NODES table, when the NODES parameter value is changed. - * Nodes are only added to the table, they are never deleted. The node name is normalized - * to contain the domain (if missing). + * Add nodes to the NODES table, when the NODES parameter value is changed. Nodes are only added to the table, they + * are never deleted. The node name is normalized to contain the domain (if missing). * * @param nodes a pipe separated list of the current nodes */ public static void setNodes(String[] nodes) { - if (map == null) + if (map == null) { reload(); + } int nextid = 0; for (Integer n : map.values()) { - if (n >= nextid) + if (n >= nextid) { nextid = n + 1; + } } // take | separated list, add domain if needed. @@ -136,8 +137,9 @@ public abstract class NodeClass extends Syncable { public static Integer lookupNodeName(final String name) { Integer n = map.get(name); - if (n == null) + if (n == null) { throw new IllegalArgumentException("Invalid node name: " + name); + } return n; } @@ -148,8 +150,9 @@ public abstract class NodeClass extends Syncable { if (s.endsWith("*")) { s = s.substring(0, s.length() - 1); for (String s2 : keyset) { - if (s2.startsWith(s)) + if (s2.startsWith(s)) { coll.add(s2); + } } } else if (keyset.contains(s)) { coll.add(s); @@ -162,14 +165,6 @@ public abstract class NodeClass extends Syncable { return coll; } - protected String lookupNodeID(int n) { - for (String s : map.keySet()) { - if (map.get(s) == n) - return s; - } - return null; - } - public static String normalizeNodename(String s) { if (s != null && s.indexOf('.') <= 0) { Parameters p = Parameters.getParameter(Parameters.PROV_DOMAIN); @@ -184,4 +179,13 @@ public abstract class NodeClass extends Syncable { } } + + protected String lookupNodeID(int n) { + for (String s : map.keySet()) { + if (map.get(s) == n) { + return s; + } + } + return null; + } }