summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager
diff options
context:
space:
mode:
authorMagnusen, Drew (dm741q) <dm741q@att.com>2017-08-24 11:37:46 -0500
committerMagnusen, Drew (dm741q) <dm741q@att.com>2017-08-28 13:07:09 -0500
commit11e0afc41aa47b9b5fe36c6c654c5b7493e4ba46 (patch)
treeb05742106ad95c9f47a006f36eb87aabb784ca1e /controlloop/common/eventmanager
parentd03507850e293674cc118f76bab0629d457179ae (diff)
Removal of sys.out/err with logger messages
Removed any use of System.out.println or System.err.println and replaced with relevant logger statements. Issue-ID: POLICY-176 Change-Id: I91513267635bfb2a34f2a9650c48f367d53fc842 Signed-off-by: Magnusen, Drew (dm741q) <dm741q@att.com>
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java4
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java12
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java21
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java30
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java17
5 files changed, 46 insertions, 38 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 3feab7d7c..b61eabc4b 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
@@ -341,7 +341,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
// PLD - this is simply comparing the policy. Do we want to equals the whole object?
//
if (this.currentOperation.policy.equals(operation.policy)) {
- System.out.println("Finishing " + this.currentOperation.policy.getRecipe() + " result is " + this.currentOperation.getOperationResult());
+ logger.debug("Finishing {} result is {}", this.currentOperation.policy.getRecipe(), this.currentOperation.getOperationResult());
//
// Save history
//
@@ -359,7 +359,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
//
return;
}
- System.out.println("Cannot finish current operation " + this.currentOperation.policy + " does not match given operation " + operation.policy);
+ logger.debug("Cannot finish current operation {} does not match given operation {}", this.currentOperation.policy, operation.policy);
return;
}
throw new ControlLoopException("No operation to finish.");
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
index 0df58be06..09f69fb0b 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
@@ -211,7 +211,7 @@ public class ControlLoopOperationManager implements Serializable {
//
// We are not supporting MSO interface at the moment
//
- System.out.println("We are not supporting MSO actor in the latest release.");
+ logger.debug("We are not supporting MSO actor in the latest release.");
return null;
case "VFC":
this.operationRequest = VFCActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, operation.operation, this.policy);
@@ -315,10 +315,10 @@ public class ControlLoopOperationManager implements Serializable {
// Sanity check
//
if (this.policy == null) {
- System.out.println("getOperationTimeout returning 0");
+ logger.debug("getOperationTimeout returning 0");
return 0;
}
- System.out.println("getOperationTimeout returning " + this.policy.getTimeout());
+ logger.debug("getOperationTimeout returning {}", this.policy.getTimeout());
return this.policy.getTimeout();
}
@@ -485,7 +485,7 @@ public class ControlLoopOperationManager implements Serializable {
private void completeOperation(Integer attempt, String message, PolicyResult result) {
if (attempt == null) {
- System.out.println("attempt cannot be null (i.e. subRequestID)");
+ logger.debug("attempt cannot be null (i.e. subRequestID)");
return;
}
if (this.currentOperation != null) {
@@ -509,7 +509,7 @@ public class ControlLoopOperationManager implements Serializable {
this.currentOperation = null;
return;
}
- System.out.println("not current");
+ logger.debug("not current");
}
for (Operation op : this.operationHistory) {
if (op.attempt == attempt.intValue()) {
@@ -520,7 +520,7 @@ public class ControlLoopOperationManager implements Serializable {
return;
}
}
- System.out.println("Could not find associated operation");
+ logger.debug("Could not find associated operation");
}
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java
index 5c019c487..bb5cec8da 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/drools/impl/PolicyEngineJUnitImpl.java
@@ -28,29 +28,32 @@ import java.util.Queue;
import org.onap.policy.appc.Request;
import org.onap.policy.controlloop.ControlLoopNotification;
import org.onap.policy.controlloop.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.onap.policy.drools.PolicyEngine;
public class PolicyEngineJUnitImpl implements PolicyEngine {
+ private static final Logger logger = LoggerFactory.getLogger(PolicyEngineJUnitImpl.class);
private Map<String, Map<String, Queue<Object>>> busMap = new HashMap<String, Map<String, Queue<Object>>>();
@Override
public boolean deliver(String busType, String topic, Object obj) {
if (obj instanceof ControlLoopNotification) {
ControlLoopNotification notification = (ControlLoopNotification) obj;
- //System.out.println("Notification: " + notification.notification + " " + (notification.message == null ? "" : notification.message) + " " + notification.history);
- System.out.println(Serialization.gsonPretty.toJson(notification));
+ //logger.debug("Notification: " + notification.notification + " " + (notification.message == null ? "" : notification.message) + " " + notification.history);
+ logger.debug(Serialization.gsonPretty.toJson(notification));
}
if (obj instanceof Request) {
Request request = (Request) obj;
- System.out.println("Request: " + request.Action + " subrequest " + request.CommonHeader.SubRequestID);
+ logger.debug("Request: {} subrequst {}", request.Action, request.CommonHeader.SubRequestID);
}
//
// Does the bus exist?
//
if (busMap.containsKey(busType) == false) {
- System.out.println("creating new bus type " + busType);
+ logger.debug("creating new bus type {}", busType);
//
// Create the bus
//
@@ -64,7 +67,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
// Does the topic exist?
//
if (topicMap.containsKey(topic) == false) {
- System.out.println("creating new topic " + topic);
+ logger.debug("creating new topic {}", topic);
//
// Create the topic
//
@@ -73,7 +76,7 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
//
// Get the topic queue
//
- System.out.println("queueing");
+ logger.debug("queueing");
return topicMap.get(topic).add(obj);
}
@@ -90,13 +93,13 @@ public class PolicyEngineJUnitImpl implements PolicyEngine {
// Does the topic exist?
//
if (topicMap.containsKey(topic)) {
- System.out.println("The queue has " + topicMap.get(topic).size());
+ logger.debug("The queue has {}", topicMap.get(topic).size());
return topicMap.get(topic).poll();
} else {
- System.err.println("No topic exists " + topic);
+ logger.error("No topic exists {}", topic);
}
} else {
- System.err.println("No bus exists " + busType);
+ logger.error("No bus exists {}", busType);
}
return null;
}
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
index fd7540ae7..6116d987e 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java
@@ -42,9 +42,11 @@ import org.onap.policy.controlloop.Util;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.PolicyResult;
import org.onap.policy.controlloop.processor.ControlLoopProcessor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ControlLoopOperationManagerTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopOperationManagerTest.class);
private static VirtualControlLoopEvent onset;
static {
onset = new VirtualControlLoopEvent();
@@ -77,7 +79,7 @@ public class ControlLoopOperationManagerTest {
ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID);
ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager);
- System.out.println(manager);
+ logger.debug("{}",manager);
//
//
//
@@ -87,7 +89,7 @@ public class ControlLoopOperationManagerTest {
// Start
//
Object request = manager.startOperation(onset);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertNotNull(request);
assertTrue(request instanceof Request);
assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("1"));
@@ -103,7 +105,7 @@ public class ControlLoopOperationManagerTest {
//
//
PolicyResult result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
@@ -115,7 +117,7 @@ public class ControlLoopOperationManagerTest {
response.Status.Value = ResponseValue.FAILURE.toString();
response.Status.Description = "AppC failed for some reason";
result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result.equals(PolicyResult.FAILURE));
assertFalse(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
@@ -123,7 +125,7 @@ public class ControlLoopOperationManagerTest {
// Retry it
//
request = manager.startOperation(onset);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertNotNull(request);
assertTrue(request instanceof Request);
assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("2"));
@@ -133,14 +135,14 @@ public class ControlLoopOperationManagerTest {
//
//
response = new Response((Request) request);
- System.out.println(manager);
+ logger.debug("{}",manager);
response.Status.Code = ResponseCode.ACCEPT.getValue();
response.Status.Value = ResponseValue.ACCEPT.toString();
//
//
//
result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
@@ -152,7 +154,7 @@ public class ControlLoopOperationManagerTest {
response.Status.Value = ResponseValue.FAILURE.toString();
response.Status.Description = "AppC failed for some reason";
result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result.equals(PolicyResult.FAILURE));
//
// Should be complete now
@@ -188,14 +190,14 @@ public class ControlLoopOperationManagerTest {
//
//
//
- System.out.println(manager);
+ logger.debug("{}",manager);
assertFalse(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
//
// Start
//
Object request = manager.startOperation(onset);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertNotNull(request);
assertTrue(request instanceof Request);
assertTrue(((Request)request).CommonHeader.SubRequestID.contentEquals("1"));
@@ -211,7 +213,7 @@ public class ControlLoopOperationManagerTest {
//
//
PolicyResult result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
@@ -219,7 +221,7 @@ public class ControlLoopOperationManagerTest {
// Now we are going to simulate Timeout
//
manager.setOperationHasTimedOut();
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(manager.isOperationComplete());
assertFalse(manager.isOperationRunning());
assertTrue(manager.getHistory().size() == 1);
@@ -232,7 +234,7 @@ public class ControlLoopOperationManagerTest {
response.Status.Value = ResponseValue.FAILURE.toString();
response.Status.Description = "AppC failed for some reason";
result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
//
//
//
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java
index 6000ca831..7bd18a3ff 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/processor/ControlLoopProcessorTest.java
@@ -36,9 +36,12 @@ import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.policy.FinalResult;
import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.policy.PolicyResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ControlLoopProcessorTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopProcessorTest.class);
+
@Test
public void test() {
try (InputStream is = new FileInputStream(new File("src/test/resources/test.yaml"))) {
@@ -59,32 +62,32 @@ public class ControlLoopProcessorTest {
public void testSuccess(String yaml) throws ControlLoopException {
ControlLoopProcessor processor = new ControlLoopProcessor(yaml);
- System.out.println("testSuccess: " + processor.getControlLoop().toString());
+ logger.debug("testSuccess: {}", processor.getControlLoop());
while (true) {
FinalResult result = processor.checkIsCurrentPolicyFinal();
if (result != null) {
- System.out.println(result);
+ logger.debug("{}", result);
break;
}
Policy policy = processor.getCurrentPolicy();
assertNotNull(policy);
- System.out.println("current policy is: " + policy.getId() + " " + policy.getName());
+ logger.debug("current policy is: {} {}", policy.getId(), policy.getName());
processor.nextPolicyForResult(PolicyResult.SUCCESS);
}
}
public void testFailure(String yaml) throws ControlLoopException {
ControlLoopProcessor processor = new ControlLoopProcessor(yaml);
- System.out.println("testFailure: " + processor.getControlLoop().toString());
+ logger.debug("testFailure: {}", processor.getControlLoop());
while (true) {
FinalResult result = processor.checkIsCurrentPolicyFinal();
if (result != null) {
- System.out.println(result);
+ logger.debug("{}", result);
break;
}
Policy policy = processor.getCurrentPolicy();
assertNotNull(policy);
- System.out.println("current policy is: " + policy.getId() + " " + policy.getName());
+ logger.debug("current policy is: {} {}", policy.getId(), policy.getName());
processor.nextPolicyForResult(PolicyResult.FAILURE);
}
}