aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/reception-plugins/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/reception-plugins/src')
-rw-r--r--plugins/reception-plugins/src/main/java/org/onap/policy/distribution/reception/handling/sdc/SdcReceptionHandler.java8
-rw-r--r--plugins/reception-plugins/src/test/java/org/onap/policy/distribution/reception/handling/sdc/TestSdcReceptionHandler.java14
2 files changed, 21 insertions, 1 deletions
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 14b0f1ec..443235b7 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
@@ -35,6 +35,7 @@ import org.onap.policy.distribution.reception.decoding.PluginTerminationExceptio
import org.onap.policy.distribution.reception.decoding.PolicyDecodingException;
import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
import org.onap.policy.distribution.reception.handling.sdc.exceptions.ArtifactDownloadException;
+import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
import org.onap.sdc.api.consumer.IDistributionStatusMessage;
@@ -180,7 +181,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
*/
public void processCsarServiceArtifacts(final INotificationData notificationData) {
boolean artifactsProcessedSuccessfully = true;
-
+ DistributionStatisticsManager.updateTotalDistributionCount();
for (final IArtifactInfo artifact : notificationData.getServiceArtifacts()) {
try {
final IDistributionClientDownloadResult resultArtifact =
@@ -200,9 +201,11 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
}
}
if (artifactsProcessedSuccessfully) {
+ DistributionStatisticsManager.updateDistributionSuccessCount();
sendComponentDoneStatus(notificationData.getDistributionID(), DistributionStatusEnum.COMPONENT_DONE_OK,
null);
} else {
+ DistributionStatisticsManager.updateDistributionFailureCount();
sendComponentDoneStatus(notificationData.getDistributionID(), DistributionStatusEnum.COMPONENT_DONE_ERROR,
"Failed to process the artifact");
}
@@ -218,8 +221,10 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
private IDistributionClientDownloadResult downloadTheArtifact(final IArtifactInfo artifact,
final INotificationData notificationData) throws ArtifactDownloadException {
+ DistributionStatisticsManager.updateTotalDownloadCount();
final IDistributionClientDownloadResult downloadResult = distributionClient.download(artifact);
if (!downloadResult.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
+ DistributionStatisticsManager.updateDownloadFailureCount();
final String message = "Failed to download artifact with name: " + artifact.getArtifactName() + " due to: "
+ downloadResult.getDistributionMessageResult();
LOGGER.error(message);
@@ -227,6 +232,7 @@ public class SdcReceptionHandler extends AbstractReceptionHandler implements INo
notificationData.getDistributionID(), DistributionStatusEnum.DOWNLOAD_ERROR, message);
throw new ArtifactDownloadException(message);
}
+ DistributionStatisticsManager.updateDownloadSuccessCount();
sendDistributionStatus(DistributionStatusType.DOWNLOAD, artifact.getArtifactURL(),
notificationData.getDistributionID(), DistributionStatusEnum.DOWNLOAD_OK, null);
return downloadResult;
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 c4020a41..a8d15cb7 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
@@ -57,6 +57,7 @@ import org.onap.policy.distribution.reception.handling.AbstractReceptionHandler;
import org.onap.policy.distribution.reception.handling.PluginHandler;
import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters;
import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters;
+import org.onap.policy.distribution.reception.statistics.DistributionStatisticsManager;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
@@ -99,6 +100,7 @@ public class TestSdcReceptionHandler {
*/
@Before
public final void init() throws IOException {
+ DistributionStatisticsManager.resetAllStatistics();
final Gson gson = new GsonBuilder().create();
pssdConfigParameters = gson.fromJson(new FileReader("src/test/resources/handling-sdc.json"),
SdcReceptionHandlerConfigurationParameterGroup.class);
@@ -237,6 +239,12 @@ public class TestSdcReceptionHandler {
assertTrue(policyDecoder.getDecodedPolicy().getPolicyName().contains(DUMMY_SERVICE_CSAR));
assertEquals(1, policyForwarder.getNumberOfPoliciesReceived());
assertTrue(policyForwarder.receivedPolicyWithGivenType(DummyDecoder.DUMMY_POLICY));
+ assertEquals(1, DistributionStatisticsManager.getTotalDistributionCount());
+ assertEquals(1, DistributionStatisticsManager.getDistributionSuccessCount());
+ assertEquals(0, DistributionStatisticsManager.getDistributionFailureCount());
+ assertEquals(1, DistributionStatisticsManager.getTotalDownloadCount());
+ assertEquals(1, DistributionStatisticsManager.getDownloadSuccessCount());
+ assertEquals(0, DistributionStatisticsManager.getDownloadFailureCount());
}
@Test
@@ -260,6 +268,12 @@ public class TestSdcReceptionHandler {
assertEquals(null, policyDecoder.getDecodedPolicy());
assertEquals(0, policyForwarder.getNumberOfPoliciesReceived());
+ assertEquals(1, DistributionStatisticsManager.getTotalDistributionCount());
+ assertEquals(0, DistributionStatisticsManager.getDistributionSuccessCount());
+ assertEquals(1, DistributionStatisticsManager.getDistributionFailureCount());
+ assertEquals(1, DistributionStatisticsManager.getTotalDownloadCount());
+ assertEquals(0, DistributionStatisticsManager.getDownloadSuccessCount());
+ assertEquals(1, DistributionStatisticsManager.getDownloadFailureCount());
}
@Test