summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2018-08-15 18:11:01 +0000
committerGerrit Code Review <gerrit@onap.org>2018-08-15 18:11:01 +0000
commit7ee4720a0a6a7a5ea418ebea0eeff845d70170d6 (patch)
treeb3362d9bd52c4f579b0078994e5766c8bac4f8f9
parentbfb9c07ce52db84ada4f851a5b8f0efdda0828b8 (diff)
parentdbe1d23be5420a5efa4d3977fee974c452bbfd29 (diff)
Merge "Fix checkstyle issues"
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java4
-rw-r--r--controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java1
-rw-r--r--controlloop/common/feature-controlloop-casablanca/src/test/java/org/onap/policy/drools/apps/controlloop/feature/casablanca/CasablancaFeatureTest.java1
-rw-r--r--controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java65
-rw-r--r--controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java12
-rw-r--r--controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java5
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java20
-rw-r--r--controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java2
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java3
-rw-r--r--controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java18
-rw-r--r--controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java14
11 files changed, 87 insertions, 58 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index 2c1b6f628..c4affac48 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -665,7 +665,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
if (event.getAai().get(VSERVER_IS_CLOSED_LOOP_DISABLED) != null
|| event.getAai().get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED) != null) {
- if(isClosedLoopDisabled(event)) {
+ if (isClosedLoopDisabled(event)) {
throw new AaiException("is-closed-loop-disabled is set to true on VServer or VNF");
}
@@ -673,7 +673,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
return;
}
- if(vnfResponse != null || vserverResponse != null) {
+ if (vnfResponse != null || vserverResponse != null) {
// query has already been performed
return;
}
diff --git a/controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java b/controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java
index 2b0348578..0deeff5f6 100644
--- a/controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java
+++ b/controlloop/common/feature-controlloop-amsterdam/src/test/java/org/onap/policy/drools/apps/controlloop/feature/amsterdam/AmsterdamFeatureTest.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.drools.apps.controlloop.feature.amsterdam;
import static org.junit.Assert.assertTrue;
diff --git a/controlloop/common/feature-controlloop-casablanca/src/test/java/org/onap/policy/drools/apps/controlloop/feature/casablanca/CasablancaFeatureTest.java b/controlloop/common/feature-controlloop-casablanca/src/test/java/org/onap/policy/drools/apps/controlloop/feature/casablanca/CasablancaFeatureTest.java
index 8960603ae..e7629a8f2 100644
--- a/controlloop/common/feature-controlloop-casablanca/src/test/java/org/onap/policy/drools/apps/controlloop/feature/casablanca/CasablancaFeatureTest.java
+++ b/controlloop/common/feature-controlloop-casablanca/src/test/java/org/onap/policy/drools/apps/controlloop/feature/casablanca/CasablancaFeatureTest.java
@@ -17,6 +17,7 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.drools.apps.controlloop.feature.casablanca;
import static org.junit.Assert.assertEquals;
diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java
index 3c818b8b3..790d434fd 100644
--- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java
+++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetrics.java
@@ -43,26 +43,26 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Control Loop Metrics Tracker
+ * Control Loop Metrics Tracker.
*/
public interface ControlLoopMetrics {
/**
- * gets all transaction identifiers being monitored
+ * Gets all transaction identifiers being monitored.
*
* @return transaction id list
*/
List<UUID> getTransactionIds();
/**
- * gets all detailed transactions
+ * Gets all detailed transactions.
*
* @return list of transactions
*/
List<VirtualControlLoopNotification> getTransactions();
/**
- * track controller's notification events
+ * Track controller's notification events.
*
* @param controller policy controller sending out notification
* @param notification notification
@@ -70,7 +70,7 @@ public interface ControlLoopMetrics {
void transactionEvent(PolicyController controller, VirtualControlLoopNotification notification);
/**
- * gets an in-progress transaction
+ * Gets an in-progress transaction.
*
* @param requestId request ID
* @return in progress notification
@@ -78,49 +78,49 @@ public interface ControlLoopMetrics {
VirtualControlLoopNotification getTransaction(UUID requestId);
/**
- * removes an in-progress transaction
+ * Removes an in-progress transaction.
*
* @param requestId request ID
*/
void removeTransaction(UUID requestId);
/**
- * get cache size
+ * Get cache size.
*
* @return cache size
*/
long getCacheSize();
/**
- * get cache size
+ * Get cache size.
*
* @return cache size
*/
long getCacheOccupancy();
/**
- * sets cache size
+ * Sets cache size.
*
* @param cacheSize cache size
*/
void setMaxCacheSize(long cacheSize);
/**
- * cached transaction expiration timeout in seconds
+ * Cached transaction expiration timeout in seconds.
*
* @return transaction timeout in seconds
*/
long getTransactionTimeout();
/**
- * sets transaction timeout in seconds
+ * Sets transaction timeout in seconds.
*
* @param transactionTimeout transaction timeout in seconds
*/
void setTransactionTimeout(long transactionTimeout);
/**
- * reset cache
+ * Reset cache.
*
* @param cacheSize new cache size
* @param transactionTimeout new transaction timeout in seconds
@@ -128,19 +128,19 @@ public interface ControlLoopMetrics {
void resetCache(long cacheSize, long transactionTimeout);
/**
- * refresh underlying transaction management
+ * Refresh underlying transaction management.
*/
void refresh();
/**
- * singleton manager object
+ * Singleton manager object.
*/
ControlLoopMetrics manager = new CacheBasedControlLoopMetricsManager();
}
/**
- * Control Loop Metrics Tracker Implementation
+ * Control Loop Metrics Tracker Implementation.
*/
class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
@@ -189,24 +189,24 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
CacheLoader<UUID, VirtualControlLoopNotification> loader =
new CacheLoader<UUID, VirtualControlLoopNotification>() {
- @Override
- public VirtualControlLoopNotification load(UUID key) throws Exception {
- return null;
- }
- };
+ @Override
+ public VirtualControlLoopNotification load(UUID key) throws Exception {
+ return null;
+ }
+ };
RemovalListener<UUID, VirtualControlLoopNotification> listener =
new RemovalListener<UUID, VirtualControlLoopNotification>() {
- @Override
- public void onRemoval(RemovalNotification<UUID, VirtualControlLoopNotification> notification) {
- if (notification.wasEvicted()) {
- evicted(notification.getValue());
- } else {
- logger.info("REMOVAL: {} because of {}", notification.getValue().getRequestId(),
+ @Override
+ public void onRemoval(RemovalNotification<UUID, VirtualControlLoopNotification> notification) {
+ if (notification.wasEvicted()) {
+ evicted(notification.getValue());
+ } else {
+ logger.info("REMOVAL: {} because of {}", notification.getValue().getRequestId(),
notification.getCause().name());
- }
- }
- };
+ }
+ }
+ };
synchronized (this) {
if (this.cache != null) {
@@ -280,7 +280,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
}
/**
- * tracks an in progress control loop transaction
+ * Tracks an in progress control loop transaction.
*
* @param notification control loop notification
*/
@@ -293,7 +293,7 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
}
/**
- * end of a control loop transaction
+ * End of a control loop transaction.
*
* @param notification control loop notification
*/
@@ -307,8 +307,9 @@ class CacheBasedControlLoopMetricsManager implements ControlLoopMetrics {
}
this.transaction(notification, startTime);
- if (startNotification != null)
+ if (startNotification != null) {
cache.invalidate(startNotification);
+ }
}
protected void evicted(VirtualControlLoopNotification notification) {
diff --git a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java
index b15fb1479..37bafa45d 100644
--- a/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java
+++ b/controlloop/common/feature-controlloop-trans/src/main/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeature.java
@@ -33,23 +33,23 @@ import org.slf4j.LoggerFactory;
public class ControlLoopMetricsFeature implements PolicyControllerFeatureAPI {
/**
- * Feature Sequence Priority
+ * Feature Sequence Priority.
*/
public final static int FEATURE_SEQUENCE_PRIORITY = 100000;
/**
- * Properties Configuration Name
+ * Properties Configuration Name.
*/
public static final String CONFIGURATION_PROPERTIES_NAME = "feature-controlloop-trans";
/**
- * maximum number of transaction cache entries
+ * Maximum number of transaction cache entries.
*/
public static final String CL_CACHE_TRANS_SIZE_PROPERTY = "controlloop.cache.transactions.size";
public static final int CL_CACHE_TRANS_SIZE_DEFAULT = 100;
/**
- * transaction timeout in minutes
+ * Transaction timeout in minutes.
*/
public static final String CL_CACHE_TRANS_TIMEOUT_SECONDS_PROPERTY =
"controllop.cache.transactions.timeout.seconds";
@@ -61,12 +61,12 @@ public class ControlLoopMetricsFeature implements PolicyControllerFeatureAPI {
}
/**
- * Logger
+ * Logger.
*/
private static Logger logger = LoggerFactory.getLogger(ControlLoopMetricsFeature.class);
/**
- * Intercept Control Loop Notifications
+ * Intercept Control Loop Notifications.
*
* @param controller - controller
* @param protocol - protocol
diff --git a/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java b/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
index df93c7a5e..1f1e9de39 100644
--- a/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
+++ b/controlloop/common/feature-controlloop-trans/src/test/java/org/onap/policy/drools/apps/controlloop/feature/trans/ControlLoopMetricsFeatureTest.java
@@ -39,13 +39,16 @@ import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.drools.system.PolicyEngine;
/**
- * ControlLoopMetrics Tests
+ * ControlLoopMetrics Tests.
*/
public class ControlLoopMetricsFeatureTest {
private static final Path configPath = SystemPersistence.manager.getConfigurationPath();
private static PolicyController testController;
+ /**
+ * Setup method.
+ */
@BeforeClass
public static void setUp() {
SystemPersistence.manager.setConfigurationDir("src/test/resources");
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
index e9ff01072..e4fd27415 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
@@ -64,6 +64,8 @@ public class PolicyGuard {
}
/**
+ * Get the factory.
+ *
* @return the factory used to access various objects
*/
protected static Factory getFactory() {
@@ -72,7 +74,7 @@ public class PolicyGuard {
/**
* Sets the factory to be used by junit tests.
- * @param factory
+ * @param factory factory
*/
protected static void setFactory(Factory factory) {
PolicyGuard.factory = factory;
@@ -95,7 +97,7 @@ public class PolicyGuard {
String owner = makeOwner(targetType, requestID);
boolean result = factory.getManager().lock(targetInstance, owner, holdSec);
- if(!result) {
+ if (!result) {
return LockResult.createLockResult(GuardResult.LOCK_DENIED, null);
}
@@ -145,7 +147,7 @@ public class PolicyGuard {
boolean result = factory.getManager().refresh(lock.getTargetInstance(), owner, holdSec);
logger.debug("Lock {} extend {}", lock, result);
- return(result ? GuardResult.LOCK_ACQUIRED : GuardResult.LOCK_DENIED);
+ return (result ? GuardResult.LOCK_ACQUIRED : GuardResult.LOCK_DENIED);
}
/**
@@ -160,7 +162,7 @@ public class PolicyGuard {
String owner = makeOwner(lock.getTargetType(), lock.getRequestID());
boolean result = factory.getManager().unlock(lock.getTargetInstance(), owner);
- if(result) {
+ if (result) {
logger.debug("Unlocked {}", lock);
return true;
}
@@ -184,17 +186,17 @@ public class PolicyGuard {
/**
* Combines the target type and request ID to yield a single, "owner" string.
- * @param targetType
- * @param requestID
+ * @param targetType target type
+ * @param requestID request id
* @return the "owner" of a resource
* @throws IllegalArgumentException if either argument is null
*/
private static String makeOwner(TargetType targetType, UUID requestID) {
- if(targetType == null) {
+ if (targetType == null) {
throw new IllegalArgumentException("null targetType for lock request id " + requestID);
}
- if(requestID == null) {
+ if (requestID == null) {
throw new IllegalArgumentException("null requestID for lock type " + targetType);
}
@@ -207,6 +209,8 @@ public class PolicyGuard {
public static class Factory {
/**
+ * Get the manager.
+ *
* @return the lock manager to be used
*/
public PolicyResourceLockManager getManager() {
diff --git a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
index 233fc0b49..46a815cdd 100644
--- a/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
+++ b/controlloop/common/guard/src/main/java/org/onap/policy/guard/Util.java
@@ -135,7 +135,7 @@ public final class Util {
/**
* Sets Guard Properties.
*
- * @see /guard/src/test/java/org/onap/policy/guard/UtilTest.java for setting test properties
+ * <p>see /guard/src/test/java/org/onap/policy/guard/UtilTest.java for setting test properties
*/
public static void setGuardEnvProps(String url, String username, String password, String clientName,
String clientPassword, String environment) {
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java
index e728d4168..8c7392e71 100644
--- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java
+++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PIPEngineGetHistoryTest.java
@@ -113,6 +113,9 @@ public class PIPEngineGetHistoryTest {
emf.close();
}
+ /**
+ * Setup method.
+ */
@Before
public void setUp() {
// clear the table
diff --git a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java
index dd1ede49c..9cee0af27 100644
--- a/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java
+++ b/controlloop/common/guard/src/test/java/org/onap/policy/guard/PolicyGuardTest.java
@@ -29,6 +29,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
+
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.Before;
@@ -105,6 +106,9 @@ public class PolicyGuardTest {
PolicyGuard.setFactory(saveFactory);
}
+ /**
+ * Setup method.
+ */
@Before
public void setUp() {
mgr = spy(new PolicyResourceLockManager() {
@@ -282,14 +286,14 @@ public class PolicyGuardTest {
// acquired
result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid, dlcb, LOCK_SEC);
- verify(mgr).lock(INSTANCENAME, type+":"+uuid, LOCK_SEC);
+ verify(mgr).lock(INSTANCENAME, type + ":" + uuid, LOCK_SEC);
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
assertEquals(VMTargetLock.class, result.getB().getClass());
// diff owner - denied
UUID uuid2 = UUID.randomUUID();
- result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid2, dlcb, LOCK_SEC+10);
- verify(mgr).lock(INSTANCENAME, type+":"+uuid2, LOCK_SEC+10);
+ result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid2, dlcb, LOCK_SEC + 10);
+ verify(mgr).lock(INSTANCENAME, type + ":" + uuid2, LOCK_SEC + 10);
assertEquals(GuardResult.LOCK_DENIED, result.getA());
assertNull(result.getB());
}
@@ -302,21 +306,21 @@ public class PolicyGuardTest {
// acquired
result = PolicyGuard.lockTarget(type, INSTANCENAME, uuid, dlcb, LOCK_SEC);
- verify(mgr).lock(INSTANCENAME, type+":"+uuid, LOCK_SEC);
+ verify(mgr).lock(INSTANCENAME, type + ":" + uuid, LOCK_SEC);
assertEquals(GuardResult.LOCK_ACQUIRED, result.getA());
assertEquals(VMTargetLock.class, result.getB().getClass());
TargetLock lock = result.getB();
// refresh - re-acquired
- assertEquals(GuardResult.LOCK_ACQUIRED, PolicyGuard.lockTarget(lock, LOCK_SEC+1));
- verify(mgr).refresh(INSTANCENAME, type+":"+uuid, LOCK_SEC+1);
+ assertEquals(GuardResult.LOCK_ACQUIRED, PolicyGuard.lockTarget(lock, LOCK_SEC + 1));
+ verify(mgr).refresh(INSTANCENAME, type + ":" + uuid, LOCK_SEC + 1);
// unlock
PolicyGuard.unlockTarget(lock);
// refresh - denied, as we no longer own the lock
- assertEquals(GuardResult.LOCK_DENIED, PolicyGuard.lockTarget(lock, LOCK_SEC+2));
+ assertEquals(GuardResult.LOCK_DENIED, PolicyGuard.lockTarget(lock, LOCK_SEC + 2));
}
@Test(expected = IllegalArgumentException.class)
diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
index b088af78a..27c9bf8cd 100644
--- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
+++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/compiler/ControlLoopCompiler.java
@@ -52,6 +52,9 @@ public class ControlLoopCompiler implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger LOGGER = LoggerFactory.getLogger(ControlLoopCompiler.class.getName());
+ /**
+ * Compiles the policy from an object.
+ */
public static ControlLoopPolicy compile(ControlLoopPolicy policy,
ControlLoopCompilerCallback callback) throws CompilerException {
//
@@ -66,6 +69,15 @@ public class ControlLoopCompiler implements Serializable {
return policy;
}
+ /**
+ * Compiles the policy from an input stream.
+ *
+ * @param yamlSpecification the yaml input stream
+ * @param callback method to callback during compilation
+ * @return
+ *
+ * @throws CompilerException throws any compile exception found
+ */
public static ControlLoopPolicy compile(InputStream yamlSpecification,
ControlLoopCompilerCallback callback) throws CompilerException {
Yaml yaml = new Yaml(new Constructor(ControlLoopPolicy.class));
@@ -84,7 +96,7 @@ public class ControlLoopCompiler implements Serializable {
if (controlLoop == null && callback != null) {
callback.onError("controlLoop cannot be null");
}
- if (controlLoop!=null){
+ if (controlLoop != null) {
if ((controlLoop.getControlLoopName() == null || controlLoop.getControlLoopName().length() < 1)
&& callback != null) {
callback.onError("Missing controlLoopName");