summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-05-11 18:28:24 +0200
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>2018-05-11 18:28:24 +0200
commit86848b8bf5182be52fff9346412743f92e3d9e6a (patch)
tree34ac3bb6e9c813155543bf5c85c4b40cb0f747d1 /src/main/java
parenta176ab885edbffbdf28a7afecf1f174175066173 (diff)
Fix Sdc Controller
Remove artifact types that clamp does not need so that it's correct in SDC UI + add notifications for all artifact types Issue-ID: CLAMP-151 Change-Id: Iada581cdb2b17b355dd3a607cbe6930bba7a6931 Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java2
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java76
2 files changed, 45 insertions, 33 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
index 2afc3d91b..ca756aa09 100644
--- a/src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
@@ -81,7 +81,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
public static final String TOSCA_CSAR = "TOSCA_CSAR";
public static final String VF_MODULES_METADATA = "VF_MODULES_METADATA";
private static final String[] SUPPORTED_ARTIFACT_TYPES = {
- HEAT, HEAT_ARTIFACT, HEAT_ENV, HEAT_NESTED, HEAT_NET, HEAT_VOL, OTHER, TOSCA_CSAR, VF_MODULES_METADATA
+ TOSCA_CSAR, VF_MODULES_METADATA
};
public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST = Collections
.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES));
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
index c9bbd0679..3421ee9e8 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java
@@ -27,6 +27,7 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import java.util.Date;
+import java.util.Map.Entry;
import java.util.concurrent.ThreadLocalRandom;
import org.onap.clamp.clds.config.ClampProperties;
@@ -36,6 +37,7 @@ import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerExceptio
import org.onap.clamp.clds.exception.sdc.controller.SdcControllerException;
import org.onap.clamp.clds.exception.sdc.controller.SdcDownloadException;
import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException;
+import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact;
import org.onap.clamp.clds.sdc.controller.installer.CsarHandler;
import org.onap.clamp.clds.sdc.controller.installer.CsarInstaller;
import org.onap.clamp.clds.util.LoggingUtils;
@@ -191,6 +193,29 @@ public class SdcSingleController {
this.changeControllerStatus(SdcSingleControllerStatus.STOPPED);
}
+ private void sendAllNotificationForCsarHandler(INotificationData iNotif, CsarHandler csar,
+ NotificationType notificationType, DistributionStatusEnum distributionStatus, String errorMessage) {
+ if (csar != null) {
+ // Notify for the CSAR
+ this.sendSdcNotification(notificationType, csar.getArtifactElement().getArtifactURL(),
+ sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
+ System.currentTimeMillis());
+ // Notify for all VF resources found
+ for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
+ // Normally always 1 artifact in resource for Clamp as we
+ // specified
+ // only VF_METADATA type
+ this.sendSdcNotification(notificationType,
+ blueprint.getValue().getResourceAttached().getArtifacts().get(0).getArtifactURL(),
+ sdcConfig.getConsumerID(), iNotif.getDistributionID(), distributionStatus, errorMessage,
+ System.currentTimeMillis());
+ }
+ } else {
+ this.sendSdcNotification(notificationType, null, sdcConfig.getConsumerID(), iNotif.getDistributionID(),
+ distributionStatus, errorMessage, System.currentTimeMillis());
+ }
+ }
+
/**
* This method processes the notification received from Sdc.
*
@@ -202,54 +227,41 @@ public class SdcSingleController {
try {
// wait for a random time, so that 2 running Clamp will not treat
// the same Notification at the same time
- long i = ThreadLocalRandom.current().nextInt(1, 5);
- Thread.sleep(i * 1000L);
+ Thread.sleep(ThreadLocalRandom.current().nextInt(1, 10) * 1000L);
logger.info("Notification received for service UUID:" + iNotif.getServiceUUID());
this.changeControllerStatus(SdcSingleControllerStatus.BUSY);
csar = new CsarHandler(iNotif, this.sdcConfig.getSdcControllerName(),
refProp.getStringValue(CONFIG_SDC_FOLDER));
csar.save(downloadTheArtifact(csar.getArtifactElement()));
if (csarInstaller.isCsarAlreadyDeployed(csar)) {
- this.sendSdcNotification(NotificationType.DOWNLOAD, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(),
- DistributionStatusEnum.ALREADY_DOWNLOADED, null, System.currentTimeMillis());
- this.sendSdcNotification(NotificationType.DOWNLOAD, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.ALREADY_DEPLOYED,
- null, System.currentTimeMillis());
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
+ DistributionStatusEnum.ALREADY_DOWNLOADED, null);
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
+ DistributionStatusEnum.ALREADY_DEPLOYED, null);
} else {
- this.sendSdcNotification(NotificationType.DOWNLOAD, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DOWNLOAD_OK, null,
- System.currentTimeMillis());
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
+ DistributionStatusEnum.DOWNLOAD_OK, null);
csarInstaller.installTheCsar(csar);
- this.sendSdcNotification(NotificationType.DEPLOY, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DEPLOY_OK, null,
- System.currentTimeMillis());
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
+ DistributionStatusEnum.DEPLOY_OK, null);
}
- } catch (SdcArtifactInstallerException e) {
+ } catch (SdcArtifactInstallerException | SdcToscaParserException e) {
logger.error("SdcArtifactInstallerException exception caught during the notification processing", e);
- this.sendSdcNotification(NotificationType.DEPLOY, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DEPLOY_ERROR,
- e.getMessage(), System.currentTimeMillis());
- } catch (SdcDownloadException e) {
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
+ } catch (SdcDownloadException | CsarHandlerException e) {
logger.error("SdcDownloadException exception caught during the notification processing", e);
- this.sendSdcNotification(NotificationType.DOWNLOAD, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DOWNLOAD_ERROR,
- e.getMessage(), System.currentTimeMillis());
- } catch (CsarHandlerException e) {
- logger.error("CsarHandlerException exception caught during the notification processing", e);
- this.sendSdcNotification(NotificationType.DOWNLOAD, null, sdcConfig.getConsumerID(),
- iNotif.getDistributionID(), DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage(),
- System.currentTimeMillis());
- } catch (SdcToscaParserException e) {
- logger.error("SdcToscaParserException exception caught during the notification processing", e);
- this.sendSdcNotification(NotificationType.DEPLOY, csar.getArtifactElement().getArtifactURL(),
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DEPLOY_ERROR,
- e.getMessage(), System.currentTimeMillis());
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DOWNLOAD,
+ DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage());
} catch (InterruptedException e) {
logger.error("Interrupt exception caught during the notification processing", e);
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
Thread.currentThread().interrupt();
} catch (RuntimeException e) {
logger.error("Unexpected exception caught during the notification processing", e);
+ sendAllNotificationForCsarHandler(iNotif, csar, NotificationType.DEPLOY,
+ DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
} finally {
this.changeControllerStatus(SdcSingleControllerStatus.IDLE);
}