aboutsummaryrefslogtreecommitdiffstats
path: root/feature-lifecycle/src
diff options
context:
space:
mode:
authorjhh <jorge.hernandez-herrero@att.com>2020-01-09 14:13:47 -0600
committerjhh <jorge.hernandez-herrero@att.com>2020-01-09 14:13:47 -0600
commitf5cd84316856905a3206f715de958c875fef98d0 (patch)
tree931583b47c035559133dbc115fda0c3bf7152443 /feature-lifecycle/src
parent4cfde2fbf8390c980a96490c15440752851fd1c5 (diff)
feature-lifecycle sonar cleanup
Issue-ID: POLICY-2322 Signed-off-by: jhh <jorge.hernandez-herrero@att.com> Change-Id: Ief23b331390b1721f67dd81b47519f629f427519
Diffstat (limited to 'feature-lifecycle/src')
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java39
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java6
-rw-r--r--feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java6
3 files changed, 32 insertions, 19 deletions
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java
index 59a65e36..d27172b2 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFeature.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP
* ================================================================================
- * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -43,26 +43,22 @@ public class LifecycleFeature
@Override
public boolean afterStart(PolicyEngine engine) {
- fsm.start();
- return false;
+ return fsmStart();
}
@Override
public boolean afterStart(PolicyController controller) {
- fsm.start(controller);
- return false;
+ return fsmStart(controller);
}
@Override
public boolean beforeStop(PolicyEngine engine) {
- fsm.stop();
- return false;
+ return fsmStop();
}
@Override
public boolean beforeStop(PolicyController controller) {
- fsm.stop(controller);
- return false;
+ return fsmStop(controller);
}
@Override
@@ -73,19 +69,36 @@ public class LifecycleFeature
@Override
public boolean beforeHalt(PolicyController controller) {
- fsm.stop(controller);
- return false;
+ return fsmStop(controller);
}
@Override
public boolean beforeLock(PolicyController controller) {
- fsm.stop(controller);
- return false;
+ return fsmStop(controller);
}
@Override
public boolean afterUnlock(PolicyController controller) {
+ return fsmStart(controller);
+ }
+
+ private boolean fsmStart() {
+ fsm.start();
+ return false;
+ }
+
+ private boolean fsmStart(PolicyController controller) {
fsm.start(controller);
return false;
}
+
+ private boolean fsmStop() {
+ fsm.stop();
+ return false;
+ }
+
+ private boolean fsmStop(PolicyController controller) {
+ fsm.stop(controller);
+ return false;
+ }
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
index 805dfd01..d43357a8 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleFsm.java
@@ -82,7 +82,7 @@ public class LifecycleFsm implements Startable {
@Getter
protected final String name = NetworkUtil.getHostname();
- protected volatile LifecycleState state = new LifecycleStateTerminated(this);
+ protected LifecycleState state = new LifecycleStateTerminated(this);
@GsonJsonIgnore
protected ScheduledExecutorService scheduler = makeExecutor();
@@ -164,7 +164,7 @@ public class LifecycleFsm implements Startable {
* Stop a controller event.
*/
public synchronized void stop(@NonNull PolicyController controller) {
- logger.info("lifecycle event: stop controller: {}" + controller.getName());
+ logger.info("lifecycle event: stop controller: {}", controller.getName());
for (ToscaPolicyTypeIdentifier id : controller.getPolicyTypes()) {
policyTypesMap.remove(id);
}
@@ -245,7 +245,7 @@ public class LifecycleFsm implements Startable {
this.subgroup = subgroup;
}
- protected void transitionToAction(@NonNull LifecycleState newState) {
+ protected synchronized void transitionToAction(@NonNull LifecycleState newState) {
state = newState;
}
diff --git a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
index a80c8853..e9ad9ffc 100644
--- a/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
+++ b/feature-lifecycle/src/main/java/org/onap/policy/drools/lifecycle/LifecycleStateRunning.java
@@ -22,7 +22,7 @@
package org.onap.policy.drools.lifecycle;
import java.util.List;
-import java.util.function.BiFunction;
+import java.util.function.BiPredicate;
import lombok.NonNull;
import org.onap.policy.drools.system.PolicyController;
import org.onap.policy.models.pdp.concepts.PdpResponseDetails;
@@ -158,7 +158,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
}
protected boolean syncPolicies(List<ToscaPolicy> policies,
- BiFunction<PolicyController, ToscaPolicy, Boolean> sync) {
+ BiPredicate<PolicyController, ToscaPolicy> sync) {
boolean success = true;
for (ToscaPolicy policy : policies) {
ToscaPolicyTypeIdentifier policyType = policy.getTypeIdentifier();
@@ -169,7 +169,7 @@ public abstract class LifecycleStateRunning extends LifecycleStateDefault {
continue;
}
- success = sync.apply(controller, policy) && success;
+ success = sync.test(controller, policy) && success;
}
return success;