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);
}
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);
}
Aggregations