use of alien4cloud.paas.model.PaaSMessageMonitorEvent in project alien4cloud by alien4cloud.
the class PaaSProviderPollingMonitorTest method initEvents.
private void initEvents() throws JsonProcessingException, InterruptedException {
// add 2 message events
PaaSMessageMonitorEvent eventMessage = null;
String eventJson = null;
int i = 0;
for (i = 0; i < 2; i++) {
eventMessage = new PaaSMessageMonitorEvent();
eventMessage.setOrchestratorId("CloudID");
eventMessage.setDate(addMinutesToDate(2, new Date()).getTime());
eventMessage.setDeploymentId("ID-XXX+" + i);
eventMessage.setMessage("EVENT MESSAGE : " + eventMessage.getDate());
eventJson = jsonMapper.writeValueAsString(eventMessage);
nodeClient.prepareIndex("deploymentmonitorevents", PaaSMessageMonitorEvent.class.getSimpleName().toLowerCase()).setSource(eventJson).setRefresh(true).execute().actionGet();
}
// add 3 deployment status events
PaaSDeploymentStatusMonitorEvent eventDeploymentStatus = null;
for (i = 0; i < 3; i++) {
eventDeploymentStatus = new PaaSDeploymentStatusMonitorEvent();
eventDeploymentStatus.setOrchestratorId("CloudID");
eventDeploymentStatus.setDate(addMinutesToDate(2, new Date()).getTime());
eventDeploymentStatus.setDeploymentId("DEP_ID-" + i);
eventDeploymentStatus.setDeploymentStatus(DeploymentStatus.DEPLOYED);
eventJson = jsonMapper.writeValueAsString(eventDeploymentStatus);
nodeClient.prepareIndex("deploymentmonitorevents", PaaSDeploymentStatusMonitorEvent.class.getSimpleName().toLowerCase()).setSource(eventJson).setRefresh(true).execute().actionGet();
}
// save the last inserted date (PaaSDeploymentStatusMonitorEvent should be generated from alien only and never from the orchestrator).
latestEventDate = new Date(eventMessage.getDate());
latestStatusDate = new Date(eventDeploymentStatus.getDate());
}
use of alien4cloud.paas.model.PaaSMessageMonitorEvent 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);
}
use of alien4cloud.paas.model.PaaSMessageMonitorEvent in project alien4cloud by alien4cloud.
the class DeployService method log.
private void log(Deployment deployment, String message, String stack, PaaSDeploymentLogLevel level) {
PaaSDeploymentLog deploymentLog = new PaaSDeploymentLog();
deploymentLog.setDeploymentId(deployment.getId());
deploymentLog.setDeploymentPaaSId(deployment.getOrchestratorDeploymentId());
String content = stack == null ? message : message + "\n" + stack;
deploymentLog.setContent(content);
deploymentLog.setLevel(level);
deploymentLog.setTimestamp(new Date());
deploymentLoggingService.save(deploymentLog);
PaaSMessageMonitorEvent messageMonitorEvent = new PaaSMessageMonitorEvent();
messageMonitorEvent.setDeploymentId(deploymentLog.getDeploymentId());
messageMonitorEvent.setOrchestratorId(deploymentLog.getDeploymentPaaSId());
messageMonitorEvent.setMessage(message);
messageMonitorEvent.setDate(deploymentLog.getTimestamp().getTime());
alienMonitorDao.save(messageMonitorEvent);
}
use of alien4cloud.paas.model.PaaSMessageMonitorEvent in project alien4cloud by alien4cloud.
the class MockPaaSProvider method doChangeStatus.
@Override
protected synchronized DeploymentStatus doChangeStatus(final String deploymentPaaSId, final DeploymentStatus status) {
MockRuntimeDeploymentInfo runtimeDeploymentInfo = runtimeDeploymentInfos.get(deploymentPaaSId);
DeploymentStatus oldDeploymentStatus = runtimeDeploymentInfo.getStatus();
log.info("Deployment [" + deploymentPaaSId + "] moved from status [" + oldDeploymentStatus + "] to [" + status + "]");
runtimeDeploymentInfo.setStatus(status);
PaaSDeploymentLog deploymentLog = new PaaSDeploymentLog();
deploymentLog.setDeploymentId(paaSDeploymentIdToAlienDeploymentIdMap.get(deploymentPaaSId));
deploymentLog.setContent("Change deployment status to " + status);
deploymentLog.setDeploymentPaaSId(deploymentPaaSId);
deploymentLog.setLevel(PaaSDeploymentLogLevel.INFO);
deploymentLog.setTimestamp(new Date());
deploymentLog.setType("deployment_status_change");
deploymentLog.setWorkflowId("install");
alienMonitorDao.getClient().admin().indices().prepareRefresh(PaaSDeploymentLog.class.getSimpleName().toLowerCase()).execute().actionGet();
deploymentLoggingService.save(deploymentLog);
executorService.schedule(new Runnable() {
@Override
public void run() {
PaaSDeploymentStatusMonitorEvent event = new PaaSDeploymentStatusMonitorEvent();
event.setDeploymentStatus(status);
event.setDate((new Date()).getTime());
event.setDeploymentId(paaSDeploymentIdToAlienDeploymentIdMap.get(deploymentPaaSId));
toBeDeliveredEvents.add(event);
PaaSMessageMonitorEvent messageMonitorEvent = new PaaSMessageMonitorEvent();
messageMonitorEvent.setDate((new Date()).getTime());
messageMonitorEvent.setDeploymentId(paaSDeploymentIdToAlienDeploymentIdMap.get(deploymentPaaSId));
messageMonitorEvent.setMessage("APPLICATIONS.RUNTIME.EVENTS.MESSAGE_EVENT.STATUS_DEPLOYMENT_CHANGED");
toBeDeliveredEvents.add(messageMonitorEvent);
}
}, 2, TimeUnit.SECONDS);
return oldDeploymentStatus;
}
use of alien4cloud.paas.model.PaaSMessageMonitorEvent in project yorc-a4c-plugin by ystia.
the class YorcPaaSProvider method sendMessage.
/**
* Deliver a PaaSMessageMonitorEvent to alien4cloud
* @param paasId
* @param message
*/
protected void sendMessage(final String paasId, final String message) {
PaaSMessageMonitorEvent event = new PaaSMessageMonitorEvent();
event.setMessage(message);
postEvent(event, paasId);
}
Aggregations