public class SdcSingleController {\r
\r
private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcSingleController.class);\r
- protected boolean isAsdcClientAutoManaged = false;\r
- protected CsarInstaller csarInstaller;\r
- protected ClampProperties refProp;\r
+ private boolean isAsdcClientAutoManaged = false;\r
+ private CsarInstaller csarInstaller;\r
+ private ClampProperties refProp;\r
public static final String CONFIG_SDC_FOLDER = "sdc.csarFolder";\r
+ private int nbOfNotificationsOngoing = 0;\r
+ private SdcSingleControllerStatus controllerStatus = SdcSingleControllerStatus.STOPPED;\r
+ private SdcSingleControllerConfiguration sdcConfig;\r
+ private IDistributionClient distributionClient;\r
\r
/**\r
* Inner class for Notification callback\r
}\r
}\r
\r
- // ***** Controller STATUS code\r
- protected int nbOfNotificationsOngoing = 0;\r
-\r
public int getNbOfNotificationsOngoing() {\r
return nbOfNotificationsOngoing;\r
}\r
\r
- private SdcSingleControllerStatus controllerStatus = SdcSingleControllerStatus.STOPPED;\r
+ private void changeControllerStatusIdle() {\r
+ if (this.nbOfNotificationsOngoing > 1) {\r
+ --this.nbOfNotificationsOngoing;\r
+ } else {\r
+ this.nbOfNotificationsOngoing = 0;\r
+ this.controllerStatus = SdcSingleControllerStatus.IDLE;\r
+ }\r
+ }\r
\r
protected final synchronized void changeControllerStatus(SdcSingleControllerStatus newControllerStatus) {\r
switch (newControllerStatus) {\r
this.controllerStatus = newControllerStatus;\r
break;\r
case IDLE:\r
- if (this.nbOfNotificationsOngoing > 1) {\r
- --this.nbOfNotificationsOngoing;\r
- } else {\r
- this.nbOfNotificationsOngoing = 0;\r
- this.controllerStatus = newControllerStatus;\r
- }\r
+ this.changeControllerStatusIdle();\r
break;\r
default:\r
this.controllerStatus = newControllerStatus;\r
return this.controllerStatus;\r
}\r
\r
- // ***** END of Controller STATUS code\r
- protected SdcSingleControllerConfiguration sdcConfig;\r
- private IDistributionClient distributionClient;\r
-\r
public SdcSingleController(ClampProperties clampProp, CsarInstaller csarInstaller,\r
SdcSingleControllerConfiguration sdcSingleConfig, boolean isClientAutoManaged) {\r
this.isAsdcClientAutoManaged = isClientAutoManaged;\r
e.getMessage(), System.currentTimeMillis());\r
} catch (CsarHandlerException e) {\r
logger.error("CsarHandlerException exception caught during the notification processing", e);\r
- this.sendASDCNotification(NotificationType.DOWNLOAD, csar.getArtifactElement().getArtifactURL(),\r
- sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DOWNLOAD_ERROR,\r
- e.getMessage(), System.currentTimeMillis());\r
+ this.sendASDCNotification(NotificationType.DOWNLOAD, null, sdcConfig.getConsumerID(),\r
+ iNotif.getDistributionID(), DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage(),\r
+ System.currentTimeMillis());\r
} catch (SdcToscaParserException e) {\r
+ logger.error("SdcToscaParserException exception caught during the notification processing", e);\r
this.sendASDCNotification(NotificationType.DEPLOY, csar.getArtifactElement().getArtifactURL(),\r
sdcConfig.getConsumerID(), iNotif.getDistributionID(), DistributionStatusEnum.DEPLOY_ERROR,\r
e.getMessage(), System.currentTimeMillis());\r
status, timestamp);\r
switch (notificationType) {\r
case DOWNLOAD:\r
- if (errorReason != null) {\r
- this.distributionClient.sendDownloadStatus(message, errorReason);\r
- } else {\r
- this.distributionClient.sendDownloadStatus(message);\r
- }\r
+ this.sendDownloadStatus(message, errorReason);\r
action = "sendDownloadStatus";\r
break;\r
case DEPLOY:\r
- if (errorReason != null) {\r
- this.distributionClient.sendDeploymentStatus(message, errorReason);\r
- } else {\r
- this.distributionClient.sendDeploymentStatus(message);\r
- }\r
+ this.sendDeploymentStatus(message, errorReason);\r
action = "sendDeploymentdStatus";\r
break;\r
default:\r
}\r
logger.info("Sdc Notification sent successfully(" + action + ")");\r
}\r
+\r
+ private void sendDownloadStatus(IDistributionStatusMessage message, String errorReason) {\r
+ if (errorReason != null) {\r
+ this.distributionClient.sendDownloadStatus(message, errorReason);\r
+ } else {\r
+ this.distributionClient.sendDownloadStatus(message);\r
+ }\r
+ }\r
+\r
+ private void sendDeploymentStatus(IDistributionStatusMessage message, String errorReason) {\r
+ if (errorReason != null) {\r
+ this.distributionClient.sendDeploymentStatus(message, errorReason);\r
+ } else {\r
+ this.distributionClient.sendDeploymentStatus(message);\r
+ }\r
+ }\r
}\r