+ participant:
+ myparameter: my parameter
+ intermediaryParameters:
+ reportingTimeIntervalMs: 120000
+ description: Participant Description
+ participantId: 101c62b3-8918-41b9-a747-d21eb79c6c90
+ clampAutomationCompositionTopics:
+ topicSources:
+ - topic: POLICY-ACRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
+ fetchTimeout: 15000
+ topicSinks:
+ - topic: POLICY-ACRUNTIME-PARTICIPANT
+ servers:
+ - ${topicServer:localhost}
+ topicCommInfrastructure: dmaap
+ participantSupportedElementTypes:
+ -
+ typeName: org.onap.policy.clamp.acm.MyFirstAutomationCompositionElement
+ typeVersion: 1.0.0
+
+
+The following example shows the Handler implementation and how could be the implemented the mandatory notifications.
+
+.. code-block:: java
+
+ @Component
+ @RequiredArgsConstructor
+ public class MyFirstAcElementHandler implements AutomationCompositionElementListener {
+
+ private final ParticipantIntermediaryApi intermediaryApi;
+
+ @Override
+ public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws PfModelException {
+
+ // TODO deploy process
+
+ if (isDeploySuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, "Deploy failed!");
+ }
+ }
+
+ @Override
+ public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+ LOGGER.debug("undeploy call");
+
+ // TODO undeploy process
+
+ if (isUndeploySuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR,
+ "Undeployed");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.DEPLOYED, null, StateChangeResult.FAILED,
+ "Undeploy failed!");
+ }
+ }
+
+ @Override
+ public void lock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+
+ // TODO lock process
+
+ if (isLockSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, null, LockState.LOCKED, StateChangeResult.NO_ERROR, "Locked");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, null, LockState.UNLOCKED, StateChangeResult.FAILED, "Lock failed!");
+ }
+ }
+
+ @Override
+ public void unlock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+
+ // TODO unlock process
+
+ if (isUnlockSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, null, LockState.UNLOCKED, StateChangeResult.NO_ERROR, "Unlocked");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, null, LockState.LOCKED, StateChangeResult.FAILED, "Unlock failed!");
+ }
+ }
+
+ @Override
+ public void delete(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException {
+
+ // TODO delete process
+
+ if (isDeleteSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.DELETED, null, StateChangeResult.NO_ERROR, "Deleted");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId,
+ automationCompositionElementId, DeployState.UNDEPLOYED, null, StateChangeResult.FAILED,
+ "Delete failed!");
+ }
+ }
+
+ @Override
+ public void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws PfModelException {
+
+ // TODO update process
+
+ if (isUpdateSuccess()) {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Updated");
+ } else {
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ DeployState.DEPLOYED, null, StateChangeResult.FAILED, "Update failed!");
+ }
+ }
+
+ @Override
+ public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
+ throws PfModelException {
+
+ // TODO prime process
+
+ if (isPrimeSuccess()) {
+ intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR,
+ "Primed");
+ } else {
+ intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.FAILED,
+ "Prime failed!");
+ }
+ }
+
+ @Override
+ public void deprime(UUID compositionId) throws PfModelException {
+
+ // TODO deprime process
+
+ if (isDeprimeSuccess()) {
+ intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR,
+ "Deprimed");
+ } else {
+ intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.FAILED,
+ "Deprime failed!");
+ }
+ }
+
+
+ @Override
+ public void handleRestartComposition(UUID compositionId,
+ List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state)
+ throws PfModelException {
+
+ switch (state) {
+ case PRIMING:
+ prime(compositionId, elementDefinitionList);
+ break;
+
+ case DEPRIMING:
+ // TODO restart process
+
+ deprime(compositionId);
+ break;
+
+ default:
+ // TODO restart process
+
+ intermediaryApi.updateCompositionState(compositionId, state, StateChangeResult.NO_ERROR, "Restarted");
+ }
+ }
+
+ @Override
+ public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
+ Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
+
+ // TODO restart process
+
+ if (DeployState.DEPLOYING.equals(deployState)) {
+ deploy(automationCompositionId, element, properties);
+ return;
+ }
+ if (DeployState.UNDEPLOYING.equals(deployState)) {
+ undeploy(automationCompositionId, element.getId());
+ return;
+ }
+ if (DeployState.UPDATING.equals(deployState)) {
+ update(automationCompositionId, element, properties);
+ return;
+ }
+ if (DeployState.DELETING.equals(deployState)) {
+ delete(automationCompositionId, element.getId());
+ return;
+ }
+ if (LockState.LOCKING.equals(lockState)) {
+ lock(automationCompositionId, element.getId());
+ return;
+ }
+ if (LockState.UNLOCKING.equals(lockState)) {
+ unlock(automationCompositionId, element.getId());
+ return;
+ }
+ intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(),
+ deployState, lockState, StateChangeResult.NO_ERROR, "Restarted");
+ }