Search in sources :

Example 1 with PaaSMessageMonitorEvent

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());
}
Also used : PaaSDeploymentStatusMonitorEvent(alien4cloud.paas.model.PaaSDeploymentStatusMonitorEvent) PaaSMessageMonitorEvent(alien4cloud.paas.model.PaaSMessageMonitorEvent) Date(java.util.Date)

Example 2 with PaaSMessageMonitorEvent

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

Example 3 with PaaSMessageMonitorEvent

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);
}
Also used : PaaSMessageMonitorEvent(alien4cloud.paas.model.PaaSMessageMonitorEvent) Date(java.util.Date) PaaSDeploymentLog(alien4cloud.paas.model.PaaSDeploymentLog)

Example 4 with PaaSMessageMonitorEvent

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;
}
Also used : PaaSDeploymentStatusMonitorEvent(alien4cloud.paas.model.PaaSDeploymentStatusMonitorEvent) PaaSMessageMonitorEvent(alien4cloud.paas.model.PaaSMessageMonitorEvent) DeploymentStatus(alien4cloud.paas.model.DeploymentStatus) Date(java.util.Date) PaaSDeploymentLog(alien4cloud.paas.model.PaaSDeploymentLog)

Example 5 with PaaSMessageMonitorEvent

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);
}
Also used : PaaSMessageMonitorEvent(alien4cloud.paas.model.PaaSMessageMonitorEvent)

Aggregations

PaaSMessageMonitorEvent (alien4cloud.paas.model.PaaSMessageMonitorEvent)5 Date (java.util.Date)4 PaaSDeploymentLog (alien4cloud.paas.model.PaaSDeploymentLog)2 PaaSDeploymentStatusMonitorEvent (alien4cloud.paas.model.PaaSDeploymentStatusMonitorEvent)2 Deployment (alien4cloud.model.deployment.Deployment)1 DeploymentStatus (alien4cloud.paas.model.DeploymentStatus)1 InstanceInformation (alien4cloud.paas.model.InstanceInformation)1 PaaSInstancePersistentResourceMonitorEvent (alien4cloud.paas.model.PaaSInstancePersistentResourceMonitorEvent)1 PaaSInstanceStateMonitorEvent (alien4cloud.paas.model.PaaSInstanceStateMonitorEvent)1