From b5f4934afdc2601c925e83458d0e3d136c36cf1c Mon Sep 17 00:00:00 2001 From: ramverma Date: Tue, 5 Feb 2019 15:34:35 +0000 Subject: Change policy/distribution logging to slf4j 1) Changed logging from FlexLogger to SLF4J with logback 2) Fixed test cases of distribution REST endpoints having infinite while loop Change-Id: I1551873b3d348f9a7d2b4f8dfc3ae5dd6462bdb8 Issue-ID: POLICY-1346 Signed-off-by: ramverma --- .../reception/decoding/pdpx/ExtractFromNode.java | 80 +++++++++++++--------- .../decoding/pdpx/PolicyDecoderCsarPdpx.java | 17 +++-- .../file/PolicyDecoderFileInCsarToPolicy.java | 7 +- .../reception/handling/file/FileClientHandler.java | 8 +-- .../handling/file/FileSystemReceptionHandler.java | 18 ++--- .../handling/sdc/SdcReceptionHandler.java | 33 +++++---- 6 files changed, 91 insertions(+), 72 deletions(-) (limited to 'plugins/reception-plugins/src/main') 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 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 lnodeVdu = new ArrayList<>(); @@ -96,16 +98,16 @@ public class ExtractFromNode { final List 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 retMap = gson.fromJson(memoryPageSize, new TypeToken>() {}.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 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 lnodeVduCp, final Map 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 retMap = new HashMap<>(); if (interfaceType != null) { retMap = gson.fromJson(interfaceType, new TypeToken>() {}.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 retMap = gson.fromJson(pciValue, new TypeToken>() {}.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 { - 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 policys = new ArrayList<>(); final ISdcCsarHelper sdcCsarHelper = parseCsar(csar); final List 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 { - 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 ev = (WatchEvent) 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); } } -- cgit 1.2.3-korg