summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java25
-rw-r--r--feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java37
-rw-r--r--feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java2
-rw-r--r--feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java4
-rw-r--r--packages/base/src/files/etc/m2/standalone-settings.xml27
5 files changed, 54 insertions, 41 deletions
diff --git a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java
index 10210ebf..c9f4c782 100644
--- a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java
+++ b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/Keyword.java
@@ -49,7 +49,7 @@ public class Keyword {
new ConcurrentHashMap<>();
// this is a pre-defined 'Lookup' instance that always returns 'null'
- private static Lookup nullLookup = (Object obj) -> (String) null;
+ private static Lookup nullLookup = (Object obj) -> null;
/**
* This method takes the object's class, looks it up in the 'classToLookup'
@@ -166,14 +166,14 @@ public class Keyword {
}
}
- Class<?> keyClass = buildReflectiveLookup_findKeyClass(clazz);
+ Class<?> keyClass = buildReflectiveLookupFindKeyClass(clazz);
if (keyClass == null) {
// no matching class name found
return null;
}
- return buildReflectiveLookup_build(clazz, keyClass);
+ return buildReflectiveLookupBuild(clazz, keyClass);
}
/**
@@ -182,7 +182,7 @@ public class Keyword {
* interfaces. If no match is found, repeat with the superclass,
* and all the way up the superclass chain.
*/
- private static Class<?> buildReflectiveLookup_findKeyClass(Class<?> clazz) {
+ private static Class<?> buildReflectiveLookupFindKeyClass(Class<?> clazz) {
Class<?> keyClass = null;
for (Class<?> cl = clazz; cl != null; cl = cl.getSuperclass()) {
if (classNameToSequence.containsKey(cl.getName())) {
@@ -212,7 +212,7 @@ public class Keyword {
return keyClass;
}
- private static Lookup buildReflectiveLookup_build(Class<?> clazz, Class<?> keyClass) {
+ private static Lookup buildReflectiveLookupBuild(Class<?> clazz, Class<?> keyClass) {
// we found a matching key in the table -- now, process the values
Class<?> currentClass = keyClass;
@@ -279,7 +279,12 @@ public class Keyword {
}
// add optional conversion function ('null' if it doesn't exist)
- last.next = conversionFunctionLookup;
+ // The preceding 'sequence.split(...)' will always return at
+ // least one entry, so there will be at least one
+ // attempt to go through the loop. If it then makes it out of the loop
+ // without returning (or an exception), 'current' and 'last' will both be
+ // set to non-null values.
+ last.next = conversionFunctionLookup; // NOSONAR
// successful - return the first 'Lookup' instance in the chain
return first;
@@ -441,11 +446,11 @@ public class Keyword {
static final int UUID_LENGTH = 36;
static {
- conversionFunction.put("uuid", value -> {
+ conversionFunction.put("uuid", value ->
// truncate strings to 36 characters
- return value != null && value.length() > UUID_LENGTH
- ? value.substring(0, UUID_LENGTH) : value;
- });
+ value != null && value.length() > UUID_LENGTH
+ ? value.substring(0, UUID_LENGTH) : value
+ );
}
/**
diff --git a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
index 66ac58da..ef88abf2 100644
--- a/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
+++ b/feature-server-pool/src/main/java/org/onap/policy/drools/serverpool/TargetLock.java
@@ -147,6 +147,9 @@ public class TargetLock implements Lock, Serializable {
private static final String QP_SERVER = "server";
private static final String QP_TTL = "ttl";
+ // define a constant for empty of byte array
+ private static final byte[] EMPTY_BYTE_ARRAY = {};
+
/**
* This method triggers registration of 'eventHandler', and also extracts
* property values.
@@ -1524,7 +1527,7 @@ public class TargetLock implements Lock, Serializable {
logger.error("Couldn't forward 'lock/dumpLocksData to uuid {}",
serverUuid);
- return null;
+ return EMPTY_BYTE_ARRAY;
}
return Base64.getEncoder().encode(Util.serialize(new HostData()));
@@ -1641,11 +1644,7 @@ public class TargetLock implements Lock, Serializable {
UUID uuid = cdr.identity.uuid;
// fetch/generate 'MergeData' instance for this UUID
- MergedData md = mergedDataMap.get(uuid);
- if (md == null) {
- md = new MergedData(uuid);
- mergedDataMap.put(uuid, md);
- }
+ MergedData md = mergedDataMap.computeIfAbsent(uuid, key -> new MergedData(uuid));
// update 'MergedData.clientDataRecord'
if (md.clientDataRecord == null) {
@@ -1680,11 +1679,7 @@ public class TargetLock implements Lock, Serializable {
UUID uuid = le.currentOwnerUuid;
// fetch/generate 'MergeData' instance for this UUID
- MergedData md = mergedDataMap.get(uuid);
- if (md == null) {
- md = new MergedData(uuid);
- mergedDataMap.put(uuid, md);
- }
+ MergedData md = mergedDataMap.computeIfAbsent(uuid, key -> new MergedData(uuid));
// update 'lockEntries' table entry
if (lockEntries.get(le.key) != null) {
@@ -1728,11 +1723,7 @@ public class TargetLock implements Lock, Serializable {
UUID uuid = waiting.ownerUuid;
// fetch/generate 'MergeData' instance for this UUID
- MergedData md = mergedDataMap.get(uuid);
- if (md == null) {
- md = new MergedData(uuid);
- mergedDataMap.put(uuid, md);
- }
+ MergedData md = mergedDataMap.computeIfAbsent(uuid, key -> new MergedData(uuid));
// update 'MergedData.serverLockEntry' and
// 'MergedData.serverWaiting'
@@ -2383,7 +2374,7 @@ public class TargetLock implements Lock, Serializable {
return Base64.getEncoder().encode(Util.serialize(this));
} catch (IOException e) {
logger.error("TargetLock.AuditData.encode Exception", e);
- return null;
+ return EMPTY_BYTE_ARRAY;
}
}
@@ -2557,7 +2548,7 @@ public class TargetLock implements Lock, Serializable {
// if we reach this point, we didn't forward for some reason
logger.error("Couldn't forward 'lock/audit to uuid {}", serverUuid);
- return null;
+ return EMPTY_BYTE_ARRAY;
}
AuditData auditData = AuditData.decode(encodedData);
@@ -2565,7 +2556,7 @@ public class TargetLock implements Lock, Serializable {
AuditData auditResp = auditData.generateResponse(true);
return auditResp.encode();
}
- return null;
+ return EMPTY_BYTE_ARRAY;
}
/**
@@ -2650,9 +2641,7 @@ public class TargetLock implements Lock, Serializable {
// map 'key -> bucket number', and then 'bucket number' -> 'server'
Server server = Bucket.bucketToServer(Bucket.bucketNumber(key));
if (server != null) {
- AuditData auditData =
- auditMap.computeIfAbsent(server, sk -> new AuditData());
- return auditData;
+ return auditMap.computeIfAbsent(server, sk -> new AuditData());
}
// this happens when the bucket has not been assigned to a server yet
@@ -2712,7 +2701,7 @@ public class TargetLock implements Lock, Serializable {
// serialize
byte[] encodedData = auditData.encode();
- if (encodedData == null) {
+ if (encodedData.length == 0) {
// error has already been displayed
return;
}
@@ -2779,7 +2768,7 @@ public class TargetLock implements Lock, Serializable {
// serialize
byte[] encodedData = auditData.encode();
- if (encodedData == null) {
+ if (encodedData.length == 0) {
// error has already been displayed
return;
}
diff --git a/feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java b/feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java
index 789dfe61..044067a3 100644
--- a/feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java
+++ b/feature-server-pool/src/test/java/org/onap/policy/drools/serverpool/AdapterImpl.java
@@ -175,7 +175,7 @@ public class AdapterImpl extends Adapter {
for (int i = 0; i < Bucket.BUCKETCOUNT; i += 1) {
Bucket bucket = Bucket.getBucket(i);
while (bucket.getOwner() == null) {
- Thread.sleep(Math.min(endTime - System.currentTimeMillis(), 100L));
+ await().atMost(Math.min(endTime - System.currentTimeMillis(), 100L), TimeUnit.MILLISECONDS);
}
}
} catch (IllegalArgumentException e) {
diff --git a/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java b/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java
index 436cf77f..fe525788 100644
--- a/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java
+++ b/feature-server-pool/src/test/java/org/onap/policy/drools/serverpooltest/Test1.java
@@ -181,9 +181,7 @@ public class Test1 {
UUID leaderUuid = firstAdapter.getLeader().getUuid();
for (Adapter adapter : Adapter.adapters) {
UUID uuid = adapter.getLeader().getUuid();
- assertTrue(adapter.toString() + " has UUID " + uuid
- + " (expected UUID " + leaderUuid + ")",
- uuid.equals(leaderUuid));
+ assertEquals(adapter.toString(), leaderUuid, uuid);
}
}
diff --git a/packages/base/src/files/etc/m2/standalone-settings.xml b/packages/base/src/files/etc/m2/standalone-settings.xml
index 8dff1a67..c2f6b63f 100644
--- a/packages/base/src/files/etc/m2/standalone-settings.xml
+++ b/packages/base/src/files/etc/m2/standalone-settings.xml
@@ -3,7 +3,7 @@
============LICENSE_START=======================================================
Base Package
================================================================================
- Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2020 Bell Canada.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,8 +21,8 @@
-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<offline>false</offline>
<profiles>
<profile>
@@ -74,10 +74,31 @@
</repository>
</repositories>
</profile>
+ <profile>
+ <id>onap-public</id>
+ <repositories>
+ <repository>
+ <id>central</id>
+ <url>https://repo1.maven.org/maven2/</url>
+ </repository>
+ <repository>
+ <id>onap-public</id>
+ <name>onap-public</name>
+ <url>https://nexus.onap.org/content/repositories/public/</url>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>false</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+ </profile>
</profiles>
<activeProfiles>
<activeProfile>policy-local</activeProfile>
<activeProfile>releases</activeProfile>
<activeProfile>snapshots</activeProfile>
+ <activeProfile>onap-public</activeProfile>
</activeProfiles>
</settings>