import org.onap.policy.controlloop.actorServiceProvider.ActorService;
import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class Test {
-
+ private static final Logger logger = LoggerFactory.getLogger(Test.class);
+
@org.junit.Test
public void test() {
- System.out.println("Dumping actors");
+ logger.debug("Dumping actors");
ActorService actorService = ActorService.getInstance();
assertNotNull(actorService);
int num = 0;
for (Actor actor : actorService.actors()) {
- System.out.println(actor.actor());
+ logger.debug(actor.actor());
for (String recipe : actor.recipes()) {
- System.out.println("\t" + recipe + " " + actor.recipeTargets(recipe) + " " + actor.recipePayloads(recipe));
+ logger.debug("\t {} {} {}", recipe, actor.recipeTargets(recipe), actor.recipePayloads(recipe));
}
num++;
}
- System.out.println("Found " + num + " actors");
+ logger.debug("Found {} actors", num);
}
}
import java.util.ServiceLoader;
import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.collect.ImmutableList;
public class ActorService {
-
+
+ private static final Logger logger = LoggerFactory.getLogger(ActorService.class);
private static ActorService service;
private ServiceLoader<Actor> loader;
public ImmutableList<Actor> actors() {
Iterator<Actor> iter = loader.iterator();
- System.out.println("returning actors");
+ logger.debug("returning actors");
while (iter.hasNext()) {
- System.out.println("Got " + iter.next().actor());
+ logger.debug("Got {}", iter.next().actor());
}
return ImmutableList.copyOf(loader.iterator());
// 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
//
//
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.");
//
// 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);
// 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();
}
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) {
this.currentOperation = null;
return;
}
- System.out.println("not current");
+ logger.debug("not current");
}
for (Operation op : this.operationHistory) {
if (op.attempt == attempt.intValue()) {
return;
}
}
- System.out.println("Could not find associated operation");
+ logger.debug("Could not find associated operation");
}
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
//
// 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
//
//
// Get the topic queue
//
- System.out.println("queueing");
+ logger.debug("queueing");
return topicMap.get(topic).add(obj);
}
// 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;
}
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();
ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID);
ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager);
- System.out.println(manager);
+ logger.debug("{}",manager);
//
//
//
// 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"));
//
//
PolicyResult result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
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());
// 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"));
//
//
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());
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
//
//
//
- 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"));
//
//
PolicyResult result = manager.onResponse(response);
- System.out.println(manager);
+ logger.debug("{}",manager);
assertTrue(result == null);
assertFalse(manager.isOperationComplete());
assertTrue(manager.isOperationRunning());
// 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);
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);
//
//
//
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"))) {
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);
}
}
try {
request = RequestParser.parseRequest(xacmlReq);
} catch (IllegalArgumentException | IllegalAccessException | DataTypeException e) {
- logger.error("CallGuardTask.run threw: ", e);
+ logger.error("CallGuardTask.run threw: {}", e);
}
- System.out.println("\n********** XACML REQUEST START ********");
- System.out.println(request);
- System.out.println("********** XACML REQUEST END ********\n");
+ logger.debug("\n********** XACML REQUEST START ********");
+ logger.debug("{}", request);
+ logger.debug("********** XACML REQUEST END ********\n");
com.att.research.xacml.api.Response xacmlResponse = PolicyGuardXacmlHelper.callPDP(embeddedPdpEngine, "", request, false);
- System.out.println("\n********** XACML RESPONSE START ********");
- System.out.println(xacmlResponse);
- System.out.println("********** XACML RESPONSE END ********\n");
+ logger.debug("\n********** XACML RESPONSE START ********");
+ logger.debug("{}", xacmlResponse);
+ logger.debug("********** XACML RESPONSE END ********\n");
PolicyGuardResponse guardResponse = PolicyGuardXacmlHelper.ParseXacmlPdpResponse(xacmlResponse);
}
long estimatedTime = System.nanoTime() - startTime;
- System.out.println("\n\n============ Guard inserted with decision "+ guardResponse.result + " !!! =========== time took: " +(double)estimatedTime/1000/1000 +" mili sec \n\n");
+ logger.debug("\n\n============ Guard inserted with decision {} !!! =========== time took: {} mili sec \n\n",
+ guardResponse.result, (double)estimatedTime/1000/1000);
workingMemory.insert(guardResponse);
}
else{
//Notice, we are checking here for the base issuer prefix.
if (!string.contains(this.getIssuer())) {
- logger.debug("Requested issuer '{}' does not match {}", string, (this.getIssuer() == null ? "null" : "'" + this.getIssuer() + "'"));
+ logger.debug("Requested issuer '{}' does not match {}", string, getIssuer());
logger.debug("FeqLimiter PIP - Issuer {} does not match with: ", string, this.getIssuer());
return StdPIPResponse.PIP_RESPONSE_EMPTY;
}
pipResponse = pipFinder.getMatchingAttributes(pipRequest, this);
if (pipResponse != null) {
if (pipResponse.getStatus() != null && !pipResponse.getStatus().isOk()) {
- logger.debug("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
pipResponse = null;
}
if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
- logger.debug("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus().toString());
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
+ pipResponse = null;
+ }
+ if (pipResponse.getAttributes() != null && pipResponse.getAttributes().isEmpty()) {
+ logger.warn("Error retrieving {}: {}", pipRequest.getAttributeId().stringValue(), pipResponse.getStatus());
pipResponse = null;
}
}
import org.onap.policy.controlloop.policy.TargetType;
import org.onap.policy.guard.impl.PNFTargetLock;
import org.onap.policy.guard.impl.VMTargetLock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PolicyGuard {
private static Map<String, TargetLock> activeLocks = new HashMap<String, TargetLock>();
-
+ private static final Logger logger = LoggerFactory.getLogger(PolicyGuard.class);
public static class LockResult<A, B> {
private A a;
private B b;
//
// Return result
//
- System.out.println("Locking " + lock);
+ logger.debug("Locking {}", lock);
return LockResult.createLockResult(GuardResult.LOCK_ACQUIRED, lock);
}
}
public static boolean unlockTarget(TargetLock lock) {
synchronized(activeLocks) {
if (activeLocks.containsKey(lock.getTargetInstance())) {
- System.out.println("Unlocking " + lock);
+ logger.debug("Unlocking {}", lock);
return (activeLocks.remove(lock.getTargetInstance()) != null);
}
return false;
//
response = (com.att.research.xacml.api.Response) callRESTfulPDP(new ByteArrayInputStream(jsonString.getBytes()), new URL(restfulPdpUrl/*"https://localhost:8443/pdp/"*/));
} catch (Exception e) {
- System.err.println("Error in sending RESTful request: " + e);
+ logger.error("Error in sending RESTful request: ", e);
}
} else if(xacmlEmbeddedPdpEngine != null){
//
try {
response = (com.att.research.xacml.api.Response) xacmlEmbeddedPdpEngine.decide((com.att.research.xacml.api.Request) request);
} catch (PDPException e) {
- System.err.println(e);
+ logger.error(e.getMessage(), e);
}
long lTimeEnd = System.currentTimeMillis();
- System.out.println("Elapsed Time: " + (lTimeEnd - lTimeStart) + "ms");
+ logger.debug("Elapsed Time: {} ms", (lTimeEnd - lTimeStart));
}
return response;
}
while(it_attr.hasNext()){
Attribute current_attr = it_attr.next();
String s = current_attr.getAttributeId().stringValue();
- //System.out.println("ATTR ID = " + s);
if(s.equals("urn:oasis:names:tc:xacml:1.0:request:request-id")){
Iterator<AttributeValue<?>> it_values = current_attr.getValues().iterator();
req_id_from_xacml_response = UUID.fromString(it_values.next().getValue().toString());
- //System.out.println("UUID = " + req_id_from_xacml_response);
}
if(s.equals("urn:oasis:names:tc:xacml:1.0:operation:operation-id")){
Iterator<AttributeValue<?>> it_values = current_attr.getValues().iterator();
operation_from_xacml_response = it_values.next().getValue().toString();
- //System.out.println("OPERATION = " + operation_from_xacml_response);
}
}
public static void fromYamlToXacml(String yamlFile, String xacmlTemplate, String xacmlPolicyOutput){
ControlLoopGuard yamlGuardObject = Util.loadYamlGuard(yamlFile);
- System.out.println("clname: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getControlLoopName());
- System.out.println("actor: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
- System.out.println("recipe: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
- System.out.println("num: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target());
- System.out.println("duration: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window());
- System.out.println("time_in_range: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range());
+ logger.debug("clname: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getControlLoopName());
+ logger.debug("actor: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
+ logger.debug("recipe: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
+ logger.debug("num: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target());
+ logger.debug("duration: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window());
+ logger.debug("time_in_range: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range());
Path xacmlTemplatePath = Paths.get(xacmlTemplate);
String xacmlTemplateContent;
p = Pattern.compile("\\$\\{guardActiveEnd\\}");
m = p.matcher(xacmlFileContent);
xacmlFileContent = m.replaceAll(guardActiveEnd);
- System.out.println(xacmlFileContent);
+ logger.debug(xacmlFileContent);
return xacmlFileContent;
}
public static void fromYamlToXacmlBlacklist(String yamlFile, String xacmlTemplate, String xacmlPolicyOutput){
ControlLoopGuard yamlGuardObject = Util.loadYamlGuard(yamlFile);
- System.out.println("actor: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
- System.out.println("recipe: " + yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
- System.out.println("freq_limit_per_target: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target());
- System.out.println("time_window: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window());
- System.out.println("active_time_range: " + yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range());
+ logger.debug("actor: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getActor());
+ logger.debug("recipe: {}", yamlGuardObject.getGuards().getFirst().getMatch_parameters().getRecipe());
+ logger.debug("freq_limit_per_target: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getFreq_limit_per_target());
+ logger.debug("time_window: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getTime_window());
+ logger.debug("active_time_range: {}", yamlGuardObject.getGuards().getFirst().getLimit_constraints().getFirst().getActive_time_range());
Path xacmlTemplatePath = Paths.get(xacmlTemplate);
String xacmlTemplateContent;
p = Pattern.compile("\\$\\{guardActiveEnd\\}");
m = p.matcher(xacmlFileContent);
xacmlFileContent = m.replaceAll(guardActiveEnd);
- System.out.println(xacmlFileContent);
+ logger.debug(xacmlFileContent);
for(String target : blacklist){
p = Pattern.compile("\\$\\{blackListElement\\}");
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class Util {
+ private static final Logger logger = LoggerFactory.getLogger(Util.class);
public static class Pair<A, B> {
public final A a;
public final B b;
Object obj = yaml.load(contents);
//String ttt = ((ControlLoopPolicy)obj).policies.getFirst().payload.get("asdas");
- System.out.println(contents);
+ logger.debug(contents);
//for(Policy policy : ((ControlLoopPolicy)obj).policies){
return new Pair<ControlLoopPolicy, String>((ControlLoopPolicy) obj, contents);
Pair<Integer, String> httpDetails = RESTManager.post(url, username, password, headers, "application/json", Serialization.gsonPretty.toJson(request));
if (httpDetails == null) {
- System.out.println("AAI POST Null Response to " + url);
+ logger.debug("AAI POST Null Response to {}", url);
return null;
}
- System.out.println(url);
- System.out.println(httpDetails.a);
- System.out.println(httpDetails.b);
+ logger.debug(url);
+ logger.debug("{}", httpDetails.a);
+ logger.debug("{}", httpDetails.b);
if (httpDetails.a == 200) {
try {
AAINQF199Response response = Serialization.gsonPretty.fromJson(httpDetails.b, AAINQF199Response.class);
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
if (httpDetailsGet == null) {
- System.out.println("AAI GET Null Response to " + urlGet);
+ logger.debug("AAI GET Null Response to {}", urlGet);
return null;
}
- System.out.println(urlGet);
- System.out.println(httpDetailsGet.a);
- System.out.println(httpDetailsGet.b);
+ logger.debug(urlGet);
+ logger.debug("{}", httpDetailsGet.a);
+ logger.debug("{}", httpDetailsGet.b);
if (httpDetailsGet.a == 200) {
try {
import org.onap.policy.controlloop.ControlLoopNotificationType;
import org.onap.policy.controlloop.ControlLoopTargetType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
+
public final class Serialization {
public static class notificationTypeAdapter implements JsonSerializer<ControlLoopNotificationType>, JsonDeserializer<ControlLoopNotificationType> {
+
@Override
public JsonElement serialize(ControlLoopNotificationType src, Type typeOfSrc,
JsonSerializationContext context) {
}
public static class gsonUTCAdapter implements JsonSerializer<ZonedDateTime>, JsonDeserializer<ZonedDateTime> {
+ private static final Logger logger = LoggerFactory.getLogger(gsonUTCAdapter.class);
public static final DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSSxxx");
public ZonedDateTime deserialize(JsonElement element, Type type, JsonDeserializationContext context)
try {
return ZonedDateTime.parse(element.getAsString(), format);
} catch (Exception e) {
- System.err.println(e);
+ logger.error(e.getMessage(), e);
}
return null;
}
MSOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, MSOResponse.class);
String body = Serialization.gsonPretty.toJson(response);
- System.out.println("***** Response to post:");
- System.out.println(body);
+ logger.debug("***** Response to post:");
+ logger.debug(body);
String requestId = response.requestReferences.requestId;
int attemptsLeft = 20;
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, MSOResponse.class);
body = Serialization.gsonPretty.toJson(responseGet);
- System.out.println("***** Response to get:");
- System.out.println(body);
+ logger.debug("***** Response to get:");
+ logger.debug(body);
if(httpDetailsGet.a == 200){
if(responseGet.request.requestStatus.requestState.equalsIgnoreCase("COMPLETE") ||
responseGet.request.requestStatus.requestState.equalsIgnoreCase("FAILED")){
- System.out.println("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState);
+ logger.debug("***** ######## VF Module Creation "+responseGet.request.requestStatus.requestState);
return responseGet;
}
}
Thread.sleep(20000);
}
+
if (responseGet != null
&& responseGet.request != null
&& responseGet.request.requestStatus != null
&& responseGet.request.requestStatus.requestState != null) {
logger.warn("***** ######## VF Module Creation timeout. Status: ( {})", responseGet.request.requestStatus.requestState);
}
+
return responseGet;
} catch (JsonSyntaxException e) {
logger.error("Failed to deserialize into MSOResponse: ", e);
import org.onap.policy.mso.MSORequestInfo;
import org.onap.policy.mso.MSORequestParameters;
import org.onap.policy.mso.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestDemo {
-
+ private static final Logger logger = LoggerFactory.getLogger(TestDemo.class);
@Test
public void test() {
request.requestDetails.requestParameters.userParams.add(userParam2);
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
//MSOResponse response = MSOManager.createModuleInstance("http://localhost:7780/", "my_username", "my_passwd", request);
//body = Serialization.gsonPretty.toJson(response);
- //System.out.println(body);
+ //logger.debug(body);
}
@Test
public void testHack() {
- System.out.println("** HACK **");
+ logger.debug("** HACK **");
MSORequest request = new MSORequest();
//
request.requestDetails.relatedInstanceList.add(relatedInstanceListElement2);
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
}
}
CredentialsProvider credentials = new BasicCredentialsProvider();
credentials.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
- System.out.println("HTTP REQUEST: " + url + " -> " + username + ((password!=null)?password.length():"-") + " -> " + contentType);
+ logger.debug("HTTP REQUEST: {} -> {} {} -> {}", url, username, ((password!=null)?password.length():"-"), contentType);
if (headers != null) {
- System.out.println("Headers: ");
+ logger.debug("Headers: ");
headers.forEach((name, value) -> {
- System.out.println(name + " -> " + value);
+ logger.debug("{} -> {}", name, value);
});
}
- System.out.println(body);
+ logger.debug(body);
try (CloseableHttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(credentials).build()) {
HttpResponse response = client.execute(post);
String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- System.out.println("HTTP POST Response Status Code: " + response.getStatusLine().getStatusCode());
- System.out.println("HTTP POST Response Body:");
- System.out.println(returnBody);
+ logger.debug("HTTP POST Response Status Code: {}", response.getStatusLine().getStatusCode());
+ logger.debug("HTTP POST Response Body:");
+ logger.debug(returnBody);
return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
} catch (IOException e) {
HttpResponse response = client.execute(get);
String returnBody = EntityUtils.toString(response.getEntity(), "UTF-8");
- logger.debug("HTTP GET Response Status Code: " + response.getStatusLine().getStatusCode());
- logger.debug("HTTP GET Response Body: " + returnBody);
+
+ logger.debug("HTTP GET Response Status Code: {}", response.getStatusLine().getStatusCode());
+ logger.debug("HTTP GET Response Body:");
+ logger.debug(returnBody);
return new Pair<Integer, String>(response.getStatusLine().getStatusCode(), returnBody);
} catch (IOException e) {
import org.onap.policy.vnf.trafficgenerator.PGStream;
import org.onap.policy.vnf.trafficgenerator.PGStreams;
import org.onap.policy.vnf.trafficgenerator.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestDemo {
-
+ private static final Logger logger = LoggerFactory.getLogger(TestDemo.class);
@Test
public void test() {
PGRequest request = new PGRequest();
}
String body = Serialization.gsonPretty.toJson(request);
- System.out.println(body);
+ logger.debug(body);
// fail("Not yet implemented");
}
import org.onap.policy.vfc.util.Serialization;
import org.onap.policy.rest.RESTManager;
import org.onap.policy.rest.RESTManager.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.JsonSyntaxException;
private String username;
private String password;
private VFCRequest vfcRequest;
-
+ private static final Logger logger = LoggerFactory.getLogger(VFCManager.class);
+
public VFCManager(VFCRequest request) {
vfcRequest = request;
// TODO: Get base URL, username and password from MSB?
VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
String body = Serialization.gsonPretty.toJson(response);
- System.out.println("Response to VFC Heal post:");
- System.out.println(body);
+ logger.debug("Response to VFC Heal post:");
+ logger.debug(body);
String jobId = response.jobId;
int attemptsLeft = 20;
Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers);
responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class);
body = Serialization.gsonPretty.toJson(responseGet);
- System.out.println("Response to VFC Heal get:");
- System.out.println(body);
+ logger.debug("Response to VFC Heal get:");
+ logger.debug(body);
if (httpDetailsGet.a == 200) {
if (responseGet.responseDescriptor.status.equalsIgnoreCase("finished") ||
responseGet.responseDescriptor.status.equalsIgnoreCase("error")) {
- System.out.println("VFC Heal Status " + responseGet.responseDescriptor.status);
+ logger.debug("VFC Heal Status {}", responseGet.responseDescriptor.status);
break;
}
}
Thread.sleep(20000);
}
if (attemptsLeft <= 0)
- System.out.println("VFC timeout. Status: (" + responseGet.responseDescriptor.status + ")");
+ logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status);
} catch (JsonSyntaxException e) {
- System.err.println("Failed to deserialize into VFCResponse" + e.getLocalizedMessage());
+ logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e);
} catch (InterruptedException e) {
- System.err.println("Interrupted exception: " + e.getLocalizedMessage());
+ logger.error("Interrupted exception: {}", e.getLocalizedMessage(), e);
}
} else {
- System.out.println("VFC Heal Restcall failed");
+ logger.warn("VFC Heal Restcall failed");
}
}
}
import java.io.InputStream;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.Yaml;
public class ControlLoopPolicyTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopPolicyTest.class);
@Test
public void test() {
this.test("src/test/resources/v1.0.0/policy_Test.yaml");
options.setPrettyFlow(true);
yaml = new Yaml(options);
String dumpedYaml = yaml.dump(obj);
- System.out.println(dumpedYaml);
+ logger.debug(dumpedYaml);
//
// Read that string back into our java object
//
}
public void dump(Object obj) {
- System.out.println("Dumping " + obj.getClass().getCanonicalName());
- System.out.println(obj.toString());
+ logger.debug("Dumping ", obj.getClass().getCanonicalName());
+ logger.debug("{}", obj);
}
}
import org.onap.policy.controlloop.policy.builder.MessageLevel;
import org.onap.policy.controlloop.policy.builder.Results;
import org.onap.policy.controlloop.policy.guard.builder.ControlLoopGuardBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
public class ControlLoopGuardBuilderTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopGuardBuilderTest.class);
@Test
public void testControlLoopGuard() {
try {
//
// Print out the specification
//
- System.out.println(results.getSpecification());
+ logger.debug(results.getSpecification());
//
} catch (FileNotFoundException e) {
fail(e.getLocalizedMessage());
import java.io.InputStream;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.DumperOptions.FlowStyle;
import org.yaml.snakeyaml.Yaml;
public class ControlLoopGuardTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopGuardTest.class);
@Test
public void testGuardvDNS() {
this.test("src/test/resources/v2.0.0-guard/policy_guard_ONAP_demo_vDNS.yaml");
options.setPrettyFlow(true);
yaml = new Yaml(options);
String dumpedYaml = yaml.dump(obj);
- System.out.println(dumpedYaml);
+ logger.debug(dumpedYaml);
//
// Read that string back into our java object
//
}
public void dump(Object obj) {
- System.out.println("Dumping " + obj.getClass().getCanonicalName());
- System.out.println(obj.toString());
+ logger.debug("Dumping {}", obj.getClass().getCanonicalName());
+ logger.debug("{}", obj);
}
}
import org.onap.policy.vnf.trafficgenerator.PGRequest;
import org.onap.policy.vnf.trafficgenerator.PGStream;
import org.onap.policy.vnf.trafficgenerator.PGStreams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestAPPCPayload {
+ private static final Logger logger = LoggerFactory.getLogger(TestAPPCPayload.class);
@Test
public void test() {
PGRequest request = new PGRequest();
appc.Action = "ModifyConfig";
appc.Payload = new HashMap<String, Object>();
appc.Payload.put("pg-streams", request);
- System.out.println(Serialization.gsonPretty.toJson(appc));
+ logger.debug(Serialization.gsonPretty.toJson(appc));
}
}
import org.onap.policy.controlloop.ControlLoopTargetType;
import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.appc.util.Serialization;
-
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TestFirewallDemo {
-
+ private static final Logger logger = LoggerFactory.getLogger(TestFirewallDemo.class);
@Test
public void testvDNS() throws IOException {
//
invalidEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- Invalid ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(invalidEvent));
+ logger.debug("----- Invalid ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(invalidEvent));
//
// Insert invalid DCAE Event into memory
onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(onsetEvent));
+ logger.debug("----- ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(onsetEvent));
//
// Insert first DCAE ONSET Event into memory
invalidEvent.AAI.put("generic-vnf.vnf-id", "foo");
invalidEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- Invalid ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(invalidEvent));
+ logger.debug("----- Invalid ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(invalidEvent));
//
// Insert invalid DCAE Event into memory
//onsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(onsetEvent));
+ logger.debug("----- ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(onsetEvent));
//
// Insert first DCAE ONSET Event into memory
//subOnsetEvent.AAI.put("vserver.vserver-name", "vserver-name-16102016-aai3255-data-11-1");
subOnsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET;
- System.out.println("----- Subsequent ONSET -----");
- System.out.println(Serialization.gsonPretty.toJson(subOnsetEvent));
+ logger.debug("----- Subsequent ONSET -----");
+ logger.debug(Serialization.gsonPretty.toJson(subOnsetEvent));
//
// Insert subsequent DCAE ONSET Event into memory
responseStatus1.Code = 100;
response1.Status = responseStatus1;
//
- System.out.println("----- APP-C RESPONSE 100 -----");
- System.out.println(Serialization.gsonPretty.toJson(response1));
+ logger.debug("----- APP-C RESPONSE 100 -----");
+ logger.debug(Serialization.gsonPretty.toJson(response1));
//
// Insert APPC Response into memory
//
responseStatus2.Code = 400;
response2.Status = responseStatus2;
//
- System.out.println("----- APP-C RESPONSE 400 -----");
- System.out.println(Serialization.gsonPretty.toJson(response2));
+ logger.debug("----- APP-C RESPONSE 400 -----");
+ logger.debug(Serialization.gsonPretty.toJson(response2));
//
// Insert APPC Response into memory
//
}
public static void dumpFacts(KieSession kieSession) {
- System.out.println("Fact Count: " + kieSession.getFactCount());
+ logger.debug("Fact Count: {}", kieSession.getFactCount());
for (FactHandle handle : kieSession.getFactHandles()) {
- System.out.println("FACT: " + handle);
+ logger.debug("FACT: {}", handle);
}
}
KieModuleModel kModule = ks.newKieModuleModel();
- System.out.println("KMODULE:" + System.lineSeparator() + kModule.toXML());
+ logger.debug("KMODULE: {} {}", System.lineSeparator(), kModule.toXML());
//
// Generate our drools rule from our template
Results results = builder.getResults();
if (results.hasMessages(Message.Level.ERROR)) {
for (Message msg : results.getMessages()) {
- System.err.println(msg.toString());
+ logger.error("{}", msg);
}
throw new RuntimeException("Drools Rule has Errors");
}
for (Message msg : results.getMessages()) {
- System.out.println(msg.toString());
+ logger.debug("{}", msg);
}
//
// Create our kie Session and container
//
ReleaseId releaseId = ks.getRepository().getDefaultReleaseId();
- System.out.println(releaseId);
+ logger.debug("{}", releaseId);
KieContainer kContainer = ks.newKieContainer(releaseId);
return kContainer.newKieSession();
ruleContents = m.replaceAll(appcTopic);
}
- System.out.println(ruleContents);
+ logger.debug(ruleContents);
return ruleContents;
}
import org.onap.policy.aai.AAINQF199.AAINQF199Response;
import org.onap.policy.aai.AAINQF199.AAINQF199ResponseWrapper;
import org.onap.policy.mso.util.Serialization;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
public class TestMSO {
+ private static final Logger logger = LoggerFactory.getLogger(TestMSO.class);
+
@Test
public void test() throws FileNotFoundException {
Gson gson = new Gson();
JsonReader reader = new JsonReader(new FileReader("src/test/resources/aairesponse.json"));
AAINQF199Response response = gson.fromJson(reader, AAINQF199Response.class);
- System.out.println(Serialization.gsonPretty.toJson(response));
+ logger.debug(Serialization.gsonPretty.toJson(response));
AAINQF199ResponseWrapper aainqf199ResponseWrapper = new AAINQF199ResponseWrapper(UUID.randomUUID(), response);
//
// print MSO request for debug
//
- System.out.println("MSO request sent:");
- System.out.println(Serialization.gsonPretty.toJson(request));
+ logger.debug("MSO request sent:");
+ logger.debug(Serialization.gsonPretty.toJson(request));
}
}
import org.onap.policy.drools.impl.PolicyEngineJUnitImpl;
import org.onap.policy.guard.PolicyGuard;
import org.onap.policy.guard.PolicyGuardYamlToXacml;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.att.research.xacml.api.pdp.PDPEngine;
import com.att.research.xacml.api.pdp.PDPEngineFactory;
import com.att.research.xacml.util.FactoryException;
public class ControlLoopXacmlGuardTest {
-
+ private static final Logger logger = LoggerFactory.getLogger(ControlLoopXacmlGuardTest.class);
@Ignore
@Test
- System.out.println("============");
- System.out.println(URLEncoder.encode(pair.b, "UTF-8"));
- System.out.println("============");
+ logger.debug("============");
+ logger.debug(URLEncoder.encode(pair.b, "UTF-8"));
+ logger.debug("============");
kieSession.addEventListener(new RuleRuntimeEventListener() {
@Override
public void matchCreated(MatchCreatedEvent event) {
- //System.out.println("matchCreated: " + event.getMatch().getRule());
+ //logger.debug("matchCreated: " + event.getMatch().getRule());
}
@Override
@Override
public void beforeMatchFired(BeforeMatchFiredEvent event) {
- //System.out.println("beforeMatchFired: " + event.getMatch().getRule() + event.getMatch().getObjects());
+ //logger.debug("beforeMatchFired: " + event.getMatch().getRule() + event.getMatch().getObjects());
}
@Override
//
// Insert our globals
//
- final ControlLoopLogger logger = new ControlLoopLoggerStdOutImpl();
kieSession.setGlobal("Logger", logger);
final PolicyEngineJUnitImpl engine = new PolicyEngineJUnitImpl();
kieSession.setGlobal("Engine", engine);
// "About to query Guard" notification (Querying about Restart)
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("\n\n####################### GOING TO QUERY GUARD about Restart!!!!!!");
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("\n\n####################### GOING TO QUERY GUARD about Restart!!!!!!");
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
// "About to query Guard" notification (Querying about Rebuild)
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("\n\n####################### GOING TO QUERY GUARD about Rebuild!!!!!!");
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("\n\n####################### GOING TO QUERY GUARD about Rebuild!!!!!!");
+ logger.debug("Rule: {} Message", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
// "About to query Guard" notification (Querying about Migrate)
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("\n\n####################### GOING TO QUERY GUARD!!!!!!");
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("\n\n####################### GOING TO QUERY GUARD!!!!!!");
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
// "Response from Guard" notification
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
if(true == ((VirtualControlLoopNotification)obj).message.contains("Guard result: Permit")){
obj = engine.subscribe("UEB", "POLICY-CL-MGT");
assertNotNull(obj);
- System.out.println("Rule: " + ((VirtualControlLoopNotification)obj).policyName +" Message: " + ((VirtualControlLoopNotification)obj).message);
+ logger.debug("Rule: {} Message {}", ((VirtualControlLoopNotification)obj).policyName, ((VirtualControlLoopNotification)obj).message);
assertTrue(obj instanceof VirtualControlLoopNotification);
assertTrue(((VirtualControlLoopNotification)obj).notification.equals(ControlLoopNotificationType.OPERATION));
assertTrue(obj instanceof Request);
assertTrue(((Request)obj).CommonHeader.SubRequestID.equals("1"));
- System.out.println("\n============ APP-C Got request!!! ===========\n");
+ logger.debug("\n============ APP-C Got request!!! ===========\n");
//
// Ok - let's simulate ACCEPT
//
} catch (InterruptedException e) {
- System.err.println("Test thread got InterruptedException " + e.getLocalizedMessage());
+ logger.error("Test thread got InterruptedException ", e.getLocalizedMessage());
} catch (AssertionError e) {
- System.err.println("Test thread got AssertionError " + e.getLocalizedMessage());
+ logger.error("Test thread got AssertionError ", e.getLocalizedMessage());
e.printStackTrace();
} catch (Exception e) {
- System.err.println("Test thread got Exception " + e.getLocalizedMessage());
+ logger.error("Test thread got Exception ", e.getLocalizedMessage());
e.printStackTrace();
}
kieSession.halt();
public static void dumpFacts(KieSession kieSession) {
- System.out.println("Fact Count: " + kieSession.getFactCount());
+ logger.debug("Fact Count: {}", kieSession.getFactCount());
for (FactHandle handle : kieSession.getFactHandles()) {
- System.out.println("FACT: " + handle);
+ logger.debug("FACT: {}", handle);
}
}
p = Pattern.compile("\\$\\{controlLoopYaml\\}");
m = p.matcher(ruleContents);
ruleContents = m.replaceAll(controlLoopYaml);
- System.out.println(ruleContents);
+ logger.debug(ruleContents);
return ruleContents;
}
KieModuleModel kModule = ks.newKieModuleModel();
- System.out.println("KMODULE:" + System.lineSeparator() + kModule.toXML());
+ logger.debug("KMODULE: {} {}", System.lineSeparator(), kModule.toXML());
//
// Generate our drools rule from our template
Results results = builder.getResults();
if (results.hasMessages(Message.Level.ERROR)) {
for (Message msg : results.getMessages()) {
- System.err.println(msg.toString());
+ logger.error("{}", msg);
}
throw new RuntimeException("Drools Rule has Errors");
}
for (Message msg : results.getMessages()) {
- System.out.println(msg.toString());
+ logger.debug("{}", msg);
}
//
// Create our kie Session and container
//
ReleaseId releaseId = ks.getRepository().getDefaultReleaseId();
- System.out.println(releaseId);
+ logger.debug("{}", releaseId);
KieContainer kContainer = ks.newKieContainer(releaseId);
return kContainer.newKieSession();
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public final class Util {
+ private static final Logger logger = LoggerFactory.getLogger(Util.class);
public static class Pair<A, B> {
public final A a;
public final B b;
Object obj = yaml.load(contents);
//String ttt = ((ControlLoopPolicy)obj).policies.getFirst().payload.get("asdas");
- System.out.println(contents);
+ logger.debug(contents);
//for(Policy policy : ((ControlLoopPolicy)obj).policies){
return new Pair<ControlLoopPolicy, String>((ControlLoopPolicy) obj, contents);