Search in sources :

Example 1 with PaaSInstanceStateMonitorEvent

use of alien4cloud.paas.model.PaaSInstanceStateMonitorEvent in project yorc-a4c-plugin by ystia.

the class YorcPaaSProvider method updateInstanceState.

/**
 * Update Instance State and notify alien4cloud if needed
 * @param paasId Deployment PaaS Id
 * @param nodeId
 * @param instanceId
 * @param iinfo
 * @param state
 */
public void updateInstanceState(String paasId, String nodeId, String instanceId, InstanceInformation iinfo, String state) {
    log.debug("paasId=" + paasId + " : set instance state:  " + instanceId + "=" + state);
    // update InstanceInformation
    InstanceStatus status = getInstanceStatusFromState(state);
    iinfo.setState(state);
    iinfo.setInstanceStatus(status);
    // Notify a4c
    PaaSInstanceStateMonitorEvent event = new PaaSInstanceStateMonitorEvent();
    event.setInstanceId(instanceId);
    event.setInstanceState(state);
    event.setInstanceStatus(status);
    event.setNodeTemplateId(nodeId);
    event.setRuntimeProperties(iinfo.getRuntimeProperties());
    event.setAttributes(iinfo.getAttributes());
    postEvent(event, paasId);
}
Also used : PaaSInstanceStateMonitorEvent(alien4cloud.paas.model.PaaSInstanceStateMonitorEvent) InstanceStatus(alien4cloud.paas.model.InstanceStatus)

Example 2 with PaaSInstanceStateMonitorEvent

use of alien4cloud.paas.model.PaaSInstanceStateMonitorEvent in project alien4cloud by alien4cloud.

the class MockPaaSProvider method notifyInstanceStateChanged.

private void notifyInstanceStateChanged(final String deploymentPaaSId, final String nodeId, final String instanceId, final InstanceInformation information, long delay) {
    final InstanceInformation cloned = new InstanceInformation();
    cloned.setAttributes(information.getAttributes());
    cloned.setInstanceStatus(information.getInstanceStatus());
    cloned.setRuntimeProperties(information.getRuntimeProperties());
    cloned.setState(information.getState());
    executorService.schedule(new Runnable() {

        @Override
        public void run() {
            final MockRuntimeDeploymentInfo deploymentInfo = runtimeDeploymentInfos.get(deploymentPaaSId);
            Deployment deployment = deploymentInfo.getDeploymentContext().getDeployment();
            PaaSInstanceStateMonitorEvent event;
            event = new PaaSInstanceStateMonitorEvent();
            event.setInstanceId(instanceId.toString());
            event.setInstanceState(cloned.getState());
            event.setInstanceStatus(cloned.getInstanceStatus());
            event.setNodeTemplateId(nodeId);
            event.setDate((new Date()).getTime());
            event.setDeploymentId(paaSDeploymentIdToAlienDeploymentIdMap.get(deploymentPaaSId));
            event.setRuntimeProperties(cloned.getRuntimeProperties());
            event.setAttributes(cloned.getAttributes());
            toBeDeliveredEvents.add(event);
            if (deployment.getSourceName().equals(BLOCKSTORAGE_APPLICATION) && cloned.getState().equalsIgnoreCase("created")) {
                PaaSInstancePersistentResourceMonitorEvent prme = new PaaSInstancePersistentResourceMonitorEvent(nodeId, instanceId.toString(), MapUtil.newHashMap(new String[] { NormativeBlockStorageConstants.VOLUME_ID }, new Object[] { UUID.randomUUID().toString() }));
                prme.setDeploymentId(deployment.getId());
                toBeDeliveredEvents.add(prme);
            }
            PaaSMessageMonitorEvent messageMonitorEvent = new PaaSMessageMonitorEvent();
            messageMonitorEvent.setDate((new Date()).getTime());
            messageMonitorEvent.setDeploymentId(paaSDeploymentIdToAlienDeploymentIdMap.get(deploymentPaaSId));
            messageMonitorEvent.setMessage("APPLICATIONS.RUNTIME.EVENTS.MESSAGE_EVENT.INSTANCE_STATE_CHANGED");
            toBeDeliveredEvents.add(messageMonitorEvent);
        }
    }, delay, TimeUnit.SECONDS);
}
Also used : PaaSInstanceStateMonitorEvent(alien4cloud.paas.model.PaaSInstanceStateMonitorEvent) PaaSInstancePersistentResourceMonitorEvent(alien4cloud.paas.model.PaaSInstancePersistentResourceMonitorEvent) InstanceInformation(alien4cloud.paas.model.InstanceInformation) Deployment(alien4cloud.model.deployment.Deployment) PaaSMessageMonitorEvent(alien4cloud.paas.model.PaaSMessageMonitorEvent) Date(java.util.Date)

Aggregations

PaaSInstanceStateMonitorEvent (alien4cloud.paas.model.PaaSInstanceStateMonitorEvent)2 Deployment (alien4cloud.model.deployment.Deployment)1 InstanceInformation (alien4cloud.paas.model.InstanceInformation)1 InstanceStatus (alien4cloud.paas.model.InstanceStatus)1 PaaSInstancePersistentResourceMonitorEvent (alien4cloud.paas.model.PaaSInstancePersistentResourceMonitorEvent)1 PaaSMessageMonitorEvent (alien4cloud.paas.model.PaaSMessageMonitorEvent)1 Date (java.util.Date)1