use of org.onap.so.asdc.client.exceptions.ASDCControllerException in project so by onap.
the class ASDCController method initASDC.
/**
* This method initializes the ASDC Controller and the ASDC Client.
*
* @throws ASDCControllerException It throws an exception if the ASDC Client cannot be instantiated or if an init
* attempt is done when already initialized
* @throws ASDCParametersException If there is an issue with the parameters provided
* @throws IOException In case of issues when trying to load the key file
*/
public void initASDC() throws ASDCControllerException {
logger.debug("Initialize the ASDC Controller");
if (!isStopped()) {
throw new ASDCControllerException("The controller is already initialized, call the closeASDC method first");
}
if (asdcConfig != null) {
asdcConfig.setAsdcControllerName(controllerName);
}
if (this.distributionClient == null) {
distributionClient = DistributionClientFactory.createDistributionClient();
}
IDistributionClientResult result = this.distributionClient.init(asdcConfig, asdcNotificationCallBack, asdcStatusCallBack);
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
String endEvent = "ASDC distribution client init failed with reason:" + result.getDistributionMessageResult();
logger.debug(endEvent);
this.changeControllerStatus(ASDCControllerStatus.STOPPED);
throw new ASDCControllerException("Initialization of the ASDC Controller failed with reason: " + result.getDistributionMessageResult());
}
result = this.distributionClient.start();
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
String endEvent = "ASDC distribution client start failed with reason:" + result.getDistributionMessageResult();
logger.debug(endEvent);
this.changeControllerStatus(ASDCControllerStatus.STOPPED);
throw new ASDCControllerException("Startup of the ASDC Controller failed with reason: " + result.getDistributionMessageResult());
}
this.changeControllerStatus(ASDCControllerStatus.IDLE);
logger.info(LoggingAnchor.THREE, MessageEnum.ASDC_INIT_ASDC_CLIENT_SUC.toString(), "ASDC", "changeControllerStatus");
}
use of org.onap.so.asdc.client.exceptions.ASDCControllerException in project so by onap.
the class ASDCControllerSingleton method periodicControllerTask.
@ScheduledLogging
@Scheduled(fixedRate = 50000)
public void periodicControllerTask() throws ScheduledTaskException {
try {
final int randomNumber = new SecureRandom().nextInt(Integer.MAX_VALUE);
asdcController.setControllerName("mso-controller" + randomNumber);
if (asdcController.isStopped()) {
logger.info("{} not running will try to initialize it, currrent status: {}", asdcController.getClass().getName(), asdcController.getControllerStatus());
asdcController.initASDC();
}
} catch (final ASDCControllerException controllerException) {
throw new ScheduledTaskException(ErrorCode.UnknownError, controllerException.getMessage(), controllerException);
}
}
use of org.onap.so.asdc.client.exceptions.ASDCControllerException in project so by onap.
the class ASDCControllerITTest method setUp.
@Before
public void setUp() {
distributionId = UUID.randomUUID().toString();
artifactUuid = UUID.randomUUID().toString();
logger.info("Using distributionId: {}, artifactUUID: {} for testcase: {}", distributionId, artifactUuid, testName.getMethodName());
distributionClient = new DistributionClientEmulator();
distributionClient.setResourcePath("src/test/resources");
asdcController.setDistributionClient(distributionClient);
try {
asdcController.initASDC();
} catch (ASDCControllerException e) {
logger.error(e.getMessage(), e);
fail(e.getMessage());
}
}
Aggregations