aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java80
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java17
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java7
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java8
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java18
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java33
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java14
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java19
8 files changed, 108 insertions, 88 deletions
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
index 579454c5..1eac005a 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/ExtractFromNode.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,8 +33,6 @@ import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.toscaparser.api.CapabilityAssignment;
@@ -42,6 +41,8 @@ import org.onap.sdc.toscaparser.api.NodeTemplate;
import org.onap.sdc.toscaparser.api.RequirementAssignment;
import org.onap.sdc.toscaparser.api.RequirementAssignments;
import org.onap.sdc.toscaparser.api.elements.Metadata;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Extract concerned info from NodeTemplate, currently ONLY HPA Feature.
@@ -50,8 +51,9 @@ import org.onap.sdc.toscaparser.api.elements.Metadata;
*/
public class ExtractFromNode {
+ private static final Logger LOGGER = LoggerFactory.getLogger(ExtractFromNode.class);
+
private static final String CONFIGURATION_VALUE = "configurationValue";
- private static final Logger LOGGER = FlexLogger.getLogger(ExtractFromNode.class);
private static final String VDU_TYPE = "tosca.nodes.nfv.Vdu.Compute";
private static final String VDU_CP_TYPE = "tosca.nodes.nfv.VduCp";
private static final String VIRTUAL_MEM_SIZE_PATH = "virtual_memory#virtual_mem_size";
@@ -60,7 +62,7 @@ public class ExtractFromNode {
private static final String MEMORY_PAGE_SIZE_PATH = "virtual_memory#vdu_memory_requirements#memoryPageSize";
private static final String NETWORK_INTERFACE_TYPE_PATH =
"virtual_network_interface_requirements#network_interface_requirements#interfaceType";
- private static final String NETWORK_PCI_PATH =
+ private static final String NETWORK_PCI_PATH =
"virtual_network_interface_requirements#nic_io_requirements#logical_node_requirements";
private static final String BASIC_CAPABILITIES_HPA_FEATURE = "basicCapabilities";
private static final String HUGE_PAGES_HPA_FEATURE = "hugePages";
@@ -85,10 +87,10 @@ public class ExtractFromNode {
* @throws PolicyDecodingException if extract fails
*/
public Content extractInfo(final NodeTemplate node) throws PolicyDecodingException {
- Metadata metaData = sdcCsarHelper.getNodeTemplateMetadata(node);
- LOGGER.debug("the meta data of this nodetemplate = " + metaData);
+ final Metadata metaData = sdcCsarHelper.getNodeTemplateMetadata(node);
+ LOGGER.debug("the meta data of this nodetemplate = {}", metaData);
final List<NodeTemplate> lnodeChild = sdcCsarHelper.getNodeTemplateChildren(node);
- LOGGER.debug("the size of lnodeChild = " + lnodeChild.size());
+ LOGGER.debug("the size of lnodeChild = {}", lnodeChild.size());
// Store all the VDUs under one VNF
final List<NodeTemplate> lnodeVdu = new ArrayList<>();
@@ -96,16 +98,16 @@ public class ExtractFromNode {
final List<NodeTemplate> lnodeVduCp = new ArrayList<>();
for (final NodeTemplate nodeChild : lnodeChild) {
final String type = sdcCsarHelper.getTypeOfNodeTemplate(nodeChild);
- LOGGER.debug("the type of this nodeChild = " + type);
- LOGGER.debug("the meta data of this nodeChild = " + sdcCsarHelper.getNodeTemplateMetadata(nodeChild));
+ LOGGER.debug("the type of this nodeChild = {}", type);
+ LOGGER.debug("the meta data of this nodeChild = {}", sdcCsarHelper.getNodeTemplateMetadata(nodeChild));
if (type.equalsIgnoreCase(VDU_TYPE)) {
lnodeVdu.add(nodeChild);
} else if (type.equalsIgnoreCase(VDU_CP_TYPE)) {
lnodeVduCp.add(nodeChild);
}
}
- LOGGER.debug("the size of vdu is =" + lnodeVdu.size());
- LOGGER.debug("the size of cp is =" + lnodeVduCp.size());
+ LOGGER.debug("the size of vdu is = {}", lnodeVdu.size());
+ LOGGER.debug("the size of cp is = {}", lnodeVduCp.size());
final Content content = new Content();
content.getResources().add(metaData.getValue("name"));
@@ -137,7 +139,7 @@ public class ExtractFromNode {
flavorDirective.getAttributes().add(flavorAttribute);
final FlavorFeature flavorFeature = new FlavorFeature();
flavorFeature.setId(node.toString());
- LOGGER.debug("the name of node =" + node.toString());
+ LOGGER.debug("the name of node = {}", node);
flavorFeature.getDirectives().add(flavorDirective);
final CapabilityAssignments capabilityAssignments = sdcCsarHelper.getCapabilitiesOf(node);
@@ -164,7 +166,7 @@ public class ExtractFromNode {
final String virtualMemSize =
sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, VIRTUAL_MEM_SIZE_PATH);
if (virtualMemSize != null) {
- LOGGER.debug("the virtualMemSize = " + virtualMemSize);
+ LOGGER.debug("the virtualMemSize = {}", virtualMemSize);
final HpaFeatureAttribute hpaFeatureAttribute =
generateHpaFeatureAttribute("virtualMemSize", virtualMemSize);
final FlavorProperty flavorProperty = new FlavorProperty();
@@ -177,7 +179,7 @@ public class ExtractFromNode {
final String numVirtualCpu =
sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, NUM_VIRTUAL_CPU_PATH);
if (numVirtualCpu != null) {
- LOGGER.debug("the numVirtualCpu = " + numVirtualCpu);
+ LOGGER.debug("the numVirtualCpu = {}", numVirtualCpu);
final HpaFeatureAttribute hpaFeatureAttribute = generateHpaFeatureAttribute("numVirtualCpu", numVirtualCpu);
final String cpuArchitecture =
sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, CPU_ARCHITECTURE_PATH);
@@ -207,15 +209,17 @@ public class ExtractFromNode {
final String modifiedValue = featureValue.replace(" ", "");
final Matcher matcher = PATTERN.matcher(modifiedValue);
if (matcher.find()) {
- LOGGER.debug("operator " + matcher.group(1) + ", value = " + matcher.group(2)
- + ", unit = " + matcher.group(3));
- if ( matcher.group(1).length() == 0 ) {
+ final String matcher1 = matcher.group(1);
+ final String matcher2 = matcher.group(2);
+ final String matcher3 = matcher.group(3);
+ LOGGER.debug("operator {} , value = {} , unit = {}", matcher1, matcher2, matcher3);
+ if (matcher.group(1).length() == 0) {
hpaFeatureAttribute.setOperator("=");
} else {
- hpaFeatureAttribute.setOperator(matcher.group(1));
+ hpaFeatureAttribute.setOperator(matcher1);
}
- hpaFeatureAttribute.setHpaAttributeValue(matcher.group(2));
- hpaFeatureAttribute.setUnit(matcher.group(3));
+ hpaFeatureAttribute.setHpaAttributeValue(matcher2);
+ hpaFeatureAttribute.setUnit(matcher3);
}
return hpaFeatureAttribute;
}
@@ -232,11 +236,11 @@ public class ExtractFromNode {
private void generateHugePages(final CapabilityAssignment capabilityAssignment, final FlavorFeature flavorFeature) {
final String memoryPageSize =
sdcCsarHelper.getCapabilityPropertyLeafValue(capabilityAssignment, MEMORY_PAGE_SIZE_PATH);
- LOGGER.debug("the memoryPageSize = " + memoryPageSize);
+ LOGGER.debug("the memoryPageSize = {}", memoryPageSize);
if (memoryPageSize != null) {
final Map<String, String> retMap =
gson.fromJson(memoryPageSize, new TypeToken<HashMap<String, String>>() {}.getType());
- LOGGER.debug("the retMap = " + retMap);
+ LOGGER.debug("the retMap = {}", retMap);
final String memoryPageSizeValue = retMap.get(CONFIGURATION_VALUE);
final String mandatory = retMap.get("mandatory");
if (memoryPageSizeValue == null) {
@@ -268,35 +272,47 @@ public class ExtractFromNode {
// each CP will binds to a VDU so need the vdu flavor map info.
final Map<String, FlavorFeature> vduFlavorMap = new HashMap<>();
for (final FlavorFeature flavorFeature : content.getFlavorFeatures()) {
- LOGGER.debug("the id = " + flavorFeature.getId());
+ LOGGER.debug("the id = {}", flavorFeature.getId());
vduFlavorMap.put(flavorFeature.getId(), flavorFeature);
}
+ parseNodeVduCp(lnodeVduCp, vduFlavorMap);
+ }
+
+ /**
+ * Parse the VduCp list.
+ *
+ * @param lnodeVduCp the lnodeVduCp
+ * @param vduFlavorMap the vduFlavorMap
+ * @throws PolicyDecodingException if any error occurs
+ */
+ private void parseNodeVduCp(final List<NodeTemplate> lnodeVduCp, final Map<String, FlavorFeature> vduFlavorMap)
+ throws PolicyDecodingException {
for (final NodeTemplate node : lnodeVduCp) {
final String interfaceType =
sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, NETWORK_INTERFACE_TYPE_PATH);
- LOGGER.debug("the interfaceType = " + interfaceType);
+ LOGGER.debug("the interfaceType = {}", interfaceType);
Map<String, Object> retMap = new HashMap<>();
if (interfaceType != null) {
retMap = gson.fromJson(interfaceType, new TypeToken<HashMap<String, Object>>() {}.getType());
- LOGGER.debug("the retMap = " + retMap);
+ LOGGER.debug("the retMap = {}", retMap);
}
String networkHpaFeature;
if (retMap.containsKey(CONFIGURATION_VALUE)
- && NETWORK_HPA_FEATURE_MAP.containsKey(retMap.get(CONFIGURATION_VALUE).toString())) {
+ && NETWORK_HPA_FEATURE_MAP.containsKey(retMap.get(CONFIGURATION_VALUE).toString())) {
final String interfaceTypeValue = retMap.get(CONFIGURATION_VALUE).toString();
networkHpaFeature = NETWORK_HPA_FEATURE_MAP.get(interfaceTypeValue);
- LOGGER.debug(" the networkHpaFeature is =" + networkHpaFeature);
+ LOGGER.debug(" the networkHpaFeature is = {}", networkHpaFeature);
} else {
LOGGER.debug(" no networkHpaFeature defined in interfaceType");
continue;
}
final RequirementAssignments requriements =
- sdcCsarHelper.getRequirementsOf(node).getRequirementsByName("virtual_binding");
- for (final RequirementAssignment requriement: requriements.getAll()) {
+ sdcCsarHelper.getRequirementsOf(node).getRequirementsByName("virtual_binding");
+ for (final RequirementAssignment requriement : requriements.getAll()) {
final String nodeTemplateName = requriement.getNodeTemplateName();
- LOGGER.debug("getNodeTemplateName =" + nodeTemplateName);
+ LOGGER.debug("getNodeTemplateName = {}", nodeTemplateName);
if (nodeTemplateName == null) {
continue;
}
@@ -323,11 +339,11 @@ public class ExtractFromNode {
flavorProperty.setHpaFeature(networkHpaFeature);
final String[] pciKeys = { "pciVendorId", "pciDeviceId", "pciNumDevices", "physicalNetwork" };
for (final String pciKey : pciKeys) {
- LOGGER.debug("the pciKey = " + pciKey);
+ LOGGER.debug("the pciKey = {}", pciKey);
final String pciKeyPath = NETWORK_PCI_PATH + "#" + pciKey;
final String pciValue = sdcCsarHelper.getNodeTemplatePropertyLeafValue(node, pciKeyPath);
if (pciValue != null) {
- LOGGER.debug("the pciValue = " + pciValue);
+ LOGGER.debug("the pciValue = {}", pciValue);
final Map<String, String> retMap =
gson.fromJson(pciValue, new TypeToken<HashMap<String, String>>() {}.getType());
final String pciConfigValue = retMap.get(CONFIGURATION_VALUE);
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
index 7a73c831..705968ae 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/pdpx/PolicyDecoderCsarPdpx.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,12 +23,12 @@ package org.onap.policy.distribution.reception.decoding.pdpx;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.model.OptimizationPolicy;
@@ -37,13 +38,15 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
import org.onap.sdc.toscaparser.api.NodeTemplate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Decodes PDP-X policies from a CSAR file.
*/
public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPolicy> {
- private static final Logger LOGGER = FlexLogger.getLogger(PolicyDecoderCsarPdpx.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderCsarPdpx.class);
private final Gson gson = new GsonBuilder().serializeNulls().disableHtmlEscaping().create();
private PolicyDecoderCsarPdpxConfigurationParameterGroup decoderParameters;
@@ -52,11 +55,11 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
final List<OptimizationPolicy> policys = new ArrayList<>();
final ISdcCsarHelper sdcCsarHelper = parseCsar(csar);
final List<NodeTemplate> lnodeVf = sdcCsarHelper.getServiceVfList();
- LOGGER.debug("the size of Vf = " + lnodeVf.size());
+ LOGGER.debug("the size of Vf = {}", lnodeVf.size());
final ExtractFromNode extractFromNode = new ExtractFromNode();
extractFromNode.setSdcCsarHelper(sdcCsarHelper);
final String serviceName = sdcCsarHelper.getServiceMetadata().getValue("name");
- LOGGER.debug("the name of the service = " + serviceName);
+ LOGGER.debug("the name of the service = {}", serviceName);
for (final NodeTemplate node : lnodeVf) {
final Content content = extractFromNode.extractInfo(node);
if (content != null) {
@@ -64,7 +67,7 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
final String policyName = decoderParameters.getPolicyNamePrefix() + "." + content.getIdentity();
policy.setOnapName(decoderParameters.getOnapName());
policy.setPolicyName(policyName);
- ConfigBody configBody = new ConfigBody();
+ final ConfigBody configBody = new ConfigBody();
configBody.setService("hpaPolicy");
configBody.setPolicyName(policyName);
configBody.setDescription("OOF Policy");
@@ -101,7 +104,7 @@ public class PolicyDecoderCsarPdpx implements PolicyDecoder<Csar, OptimizationPo
ISdcCsarHelper sdcCsarHelper;
try {
final SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();
- LOGGER.debug("Csar File Path = " + csar.getCsarPath());
+ LOGGER.debug("Csar File Path = {}", csar.getCsarPath());
final File csarFile = new File(csar.getCsarPath());
sdcCsarHelper = factory.getSdcCsarHelper(csarFile.getAbsolutePath());
} catch (final Exception exp) {
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java
index 482ac80b..22b626f8 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/decoding/policy/file/PolicyDecoderFileInCsarToPolicy.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,14 +30,14 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import org.apache.commons.io.IOUtils;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.model.PolicyAsString;
import org.onap.policy.distribution.model.PolicyInput;
import org.onap.policy.distribution.reception.decoding.PolicyDecoder;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class extracts policy files from a CSAR file.
@@ -45,7 +46,7 @@ import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
*/
public class PolicyDecoderFileInCsarToPolicy implements PolicyDecoder<Csar, PolicyAsString> {
- private static final Logger LOGGER = FlexLogger.getLogger(PolicyDecoderFileInCsarToPolicy.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderFileInCsarToPolicy.class);
PolicyDecoderFileInCsarToPolicyParameterGroup decoderParameters;
/**
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java
index f8e57747..fd4f69cc 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileClientHandler.java
@@ -22,8 +22,8 @@ package org.onap.policy.distribution.reception.handling.file;
import java.io.IOException;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* This class implements Runnable interface for creating new thread which will be used as file watcher.
@@ -32,7 +32,7 @@ import org.onap.policy.common.logging.flexlogger.Logger;
*/
public class FileClientHandler implements Runnable {
- private static final Logger LOGGER = FlexLogger.getLogger(FileClientHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileClientHandler.class);
private FileSystemReceptionHandler fileReceptionHandler;
private String watchPath;
@@ -55,7 +55,7 @@ public class FileClientHandler implements Runnable {
try {
fileReceptionHandler.initFileWatcher(watchPath);
} catch (final IOException ex) {
- LOGGER.error(ex);
+ LOGGER.error("Failed initializing file watcher thread", ex);
}
}
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
index 3cb167f3..a3f6fab0 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/file/FileSystemReceptionHandler.java
@@ -34,20 +34,20 @@ import java.nio.file.WatchService;
import java.util.concurrent.TimeUnit;
import java.util.zip.ZipFile;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Handles reception of inputs from File System which can be used to decode policies.
*/
public class FileSystemReceptionHandler extends AbstractReceptionHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(FileSystemReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(FileSystemReceptionHandler.class);
private boolean running = false;
/**
@@ -63,7 +63,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
final Thread fileWatcherThread = new Thread(fileClientHandler);
fileWatcherThread.start();
} catch (final Exception ex) {
- LOGGER.error(ex);
+ LOGGER.error("FileSystemReceptionHandler initialization failed", ex);
}
}
@@ -93,10 +93,10 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
try (final WatchService watcher = FileSystems.getDefault().newWatchService()) {
final Path dir = Paths.get(watchPath);
dir.register(watcher, ENTRY_CREATE);
- LOGGER.debug("Watch Service registered for dir: " + dir.getFileName());
+ LOGGER.debug("Watch Service registered for dir: {}", dir.getFileName());
startWatchService(watcher, dir);
} catch (final InterruptedException ex) {
- LOGGER.debug(ex);
+ LOGGER.error("FileWatcher initialization failed", ex);
Thread.currentThread().interrupt();
}
}
@@ -118,12 +118,12 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
for (final WatchEvent<?> event : key.pollEvents()) {
final WatchEvent<Path> ev = (WatchEvent<Path>) event;
final Path fileName = ev.context();
- LOGGER.debug("new CSAR found: " + fileName);
+ LOGGER.debug("new CSAR found: {}", fileName);
DistributionStatisticsManager.updateTotalDistributionCount();
final String fullFilePath = dir.toString() + File.separator + fileName.toString();
waitForFileToBeReady(fullFilePath);
createPolicyInputAndCallHandler(fullFilePath);
- LOGGER.debug("CSAR complete: " + fileName);
+ LOGGER.debug("CSAR complete: {}", fileName);
}
final boolean valid = key.reset();
if (!valid) {
@@ -148,7 +148,7 @@ public class FileSystemReceptionHandler extends AbstractReceptionHandler {
} catch (final PolicyDecodingException ex) {
DistributionStatisticsManager.updateDownloadFailureCount();
DistributionStatisticsManager.updateDistributionFailureCount();
- LOGGER.error(ex);
+ LOGGER.error("Policy creation failed", ex);
}
}
diff --git a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
index 0d100f8f..c3d7e43b 100644
--- a/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
+++ b/plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,8 +27,6 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.model.Csar;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
@@ -46,13 +45,15 @@ import org.onap.sdc.api.results.IDistributionClientResult;
import org.onap.sdc.impl.DistributionClientFactory;
import org.onap.sdc.utils.DistributionActionResultEnum;
import org.onap.sdc.utils.DistributionStatusEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Handles reception of inputs from ONAP Service Design and Creation (SDC) from which policies may be decoded.
*/
public class SdcReceptionHandler extends AbstractReceptionHandler implements INotificationCallback {
- private static final Logger LOGGER = FlexLogger.getLogger(SdcReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(SdcReceptionHandler.class);
private static final String SECONDS = "Seconds";
private SdcReceptionHandlerStatus sdcReceptionHandlerStatus = SdcReceptionHandlerStatus.STOPPED;
@@ -85,11 +86,11 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
@Override
public void activateCallback(final INotificationData notificationData) {
- LOGGER.debug("Receieved the notification from SDC with ID: " + notificationData.getDistributionID());
+ LOGGER.debug("Receieved the notification from SDC with ID: {}", notificationData.getDistributionID());
changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.BUSY);
processCsarServiceArtifacts(notificationData);
changeSdcReceptionHandlerStatus(SdcReceptionHandlerStatus.IDLE);
- LOGGER.debug("Processed the notification from SDC with ID: " + notificationData.getDistributionID());
+ LOGGER.debug("Processed the notification from SDC with ID: {}", notificationData.getDistributionID());
}
/**
@@ -137,8 +138,8 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
}
final IDistributionClientResult clientResult = distributionClient.init(sdcConfig, this);
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- LOGGER.error("SDC client initialization failed with reason:" + clientResult.getDistributionMessageResult()
- + ". Initialization will be retried after " + retryDelay + SECONDS);
+ LOGGER.error("SDC client initialization failed with reason: {}. Initialization will be retried after {} {}",
+ clientResult.getDistributionMessageResult(), retryDelay, SECONDS);
return;
}
LOGGER.debug("SDC Client is initialized successfully");
@@ -158,8 +159,8 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
}
final IDistributionClientResult clientResult = distributionClient.start();
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- LOGGER.error("SDC client start failed with reason:" + clientResult.getDistributionMessageResult()
- + ". Start will be retried after " + retryDelay + SECONDS);
+ LOGGER.error("SDC client start failed with reason: {}. Start will be retried after {} {}",
+ clientResult.getDistributionMessageResult(), retryDelay, SECONDS);
return;
}
LOGGER.debug("SDC Client is started successfully");
@@ -175,8 +176,8 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
LOGGER.debug("Going to stop the SDC Client...");
final IDistributionClientResult clientResult = distributionClient.stop();
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- LOGGER.error("SDC client stop failed with reason:" + clientResult.getDistributionMessageResult()
- + ". Stop will be retried after " + retryDelay + SECONDS);
+ LOGGER.error("SDC client stop failed with reason: {}. Stop will be retried after {} {}",
+ clientResult.getDistributionMessageResult(), retryDelay, SECONDS);
return;
}
LOGGER.debug("SDC Client is stopped successfully");
@@ -324,10 +325,10 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
}
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
loggerMessage.insert(0, "Failed sending ");
- LOGGER.debug(loggerMessage);
+ LOGGER.debug("Failed sending {}", loggerMessage);
} else {
loggerMessage.insert(0, "Successfully Sent ");
- LOGGER.debug(loggerMessage);
+ LOGGER.debug("Successfully Sent {}", loggerMessage);
}
}
@@ -358,11 +359,9 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
loggerMessage.append(" ErrorReason: ").append(errorReason);
}
if (!clientResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- loggerMessage.insert(0, "Failed sending ");
- LOGGER.debug(loggerMessage);
+ LOGGER.debug("Failed sending {}", loggerMessage);
} else {
- loggerMessage.insert(0, "Successfully Sent ");
- LOGGER.debug(loggerMessage);
+ LOGGER.debug("Successfully Sent {}", loggerMessage);
}
}
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
index 28408700..fdb01007 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/file/TestFileSystemReceptionHandler.java
@@ -43,11 +43,11 @@ import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of {@link FileSystemReceptionHandler}.
@@ -55,7 +55,7 @@ import org.onap.policy.distribution.reception.statistics.DistributionStatisticsM
@RunWith(MockitoJUnitRunner.class)
public class TestFileSystemReceptionHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(TestFileSystemReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestFileSystemReceptionHandler.class);
@Rule
public TemporaryFolder tempFolder = new TemporaryFolder();
@@ -97,7 +97,7 @@ public class TestFileSystemReceptionHandler {
try {
sypHandler.initializeReception(pssdConfigParameters.getName());
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testInit failed", exp);
fail("Test should not throw any exception");
}
}
@@ -110,7 +110,7 @@ public class TestFileSystemReceptionHandler {
sypHandler.initializeReception(pssdConfigParameters.getName());
sypHandler.destroy();
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testDestroy failed", exp);
fail("Test should not throw any exception");
}
@@ -143,7 +143,7 @@ public class TestFileSystemReceptionHandler {
try {
sypHandler.initFileWatcher(watchPath);
} catch (final IOException ex) {
- LOGGER.error(ex);
+ LOGGER.error("testMain failed", ex);
}
});
@@ -170,7 +170,7 @@ public class TestFileSystemReceptionHandler {
th.interrupt();
th.join();
} catch (final InterruptedException ex) {
- LOGGER.error(ex);
+ LOGGER.error("testMain failed", ex);
}
Mockito.verify(sypHandler, Mockito.times(1)).createPolicyInputAndCallHandler(Mockito.isA(String.class));
diff --git a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
index 557a7683..3118f95d 100644
--- a/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
+++ b/plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Intel. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +45,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.policy.common.logging.flexlogger.FlexLogger;
-import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.common.parameters.ParameterService;
import org.onap.policy.distribution.forwarding.PolicyForwarder;
import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters;
@@ -63,6 +62,8 @@ import org.onap.sdc.api.results.IDistributionClientDownloadResult;
import org.onap.sdc.api.results.IDistributionClientResult;
import org.onap.sdc.impl.mock.DistributionClientStubImpl;
import org.onap.sdc.utils.DistributionActionResultEnum;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Class to perform unit test of {@link SdcReceptionHandler}.
@@ -72,7 +73,7 @@ import org.onap.sdc.utils.DistributionActionResultEnum;
@RunWith(MockitoJUnitRunner.class)
public class TestSdcReceptionHandler {
- private static final Logger LOGGER = FlexLogger.getLogger(TestSdcReceptionHandler.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(TestSdcReceptionHandler.class);
private static final String DUMMY_SERVICE_CSAR = "dummyService.csar";
@Mock
@@ -145,7 +146,7 @@ public class TestSdcReceptionHandler {
try {
sypHandler.initializeReception(pssdConfigParameters.getName());
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testInitializeSdcClient failed", exp);
fail("Test should not throw any exception");
}
}
@@ -158,7 +159,7 @@ public class TestSdcReceptionHandler {
try {
sypHandler.initializeReception(pssdConfigParameters.getName());
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testInitializeSdcClient_Failure failed", exp);
fail("Test should not throw any exception");
}
}
@@ -170,7 +171,7 @@ public class TestSdcReceptionHandler {
.thenReturn(successfulClientInitResult);
sypHandler.initializeReception(pssdConfigParameters.getName());
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testStartSdcClient_Failure failed", exp);
fail("Test should not throw any exception");
}
}
@@ -181,7 +182,7 @@ public class TestSdcReceptionHandler {
sypHandler.initializeReception(pssdConfigParameters.getName());
sypHandler.destroy();
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testStopSdcClient failed", exp);
fail("Test should not throw any exception");
}
@@ -196,7 +197,7 @@ public class TestSdcReceptionHandler {
try {
sypHandler.destroy();
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testStopSdcClient_Failure failed", exp);
fail("Test should not throw any exception");
}
}
@@ -206,7 +207,7 @@ public class TestSdcReceptionHandler {
try {
sypHandler.destroy();
} catch (final Exception exp) {
- LOGGER.error(exp);
+ LOGGER.error("testStopSdcClientWithoutStart", exp);
fail("Test should not throw any exception");
}