Search in sources :

Example 1 with PaaSDeploymentLog

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

the class MockPaaSProvider method changeInstanceState.

private void changeInstanceState(String id, String nodeId, String instanceId, InstanceInformation information, Iterator<Entry<String, InstanceInformation>> iterator) {
    String currentState = information.getState();
    String nextState = getNextState(currentState);
    if (nextState != null) {
        information.setState(nextState);
        if ("started".equals(nextState)) {
            information.setInstanceStatus(InstanceStatus.SUCCESS);
        }
        if ("terminated".equals(nextState)) {
            iterator.remove();
            notifyInstanceRemoved(id, nodeId, instanceId, 2);
        } else {
            notifyInstanceStateChanged(id, nodeId, instanceId, information, 2);
        }
        PaaSDeploymentLog deploymentLog = new PaaSDeploymentLog();
        deploymentLog.setContent("Change state to " + nextState);
        deploymentLog.setDeploymentId(paaSDeploymentIdToAlienDeploymentIdMap.get(id));
        deploymentLog.setDeploymentPaaSId(id);
        deploymentLog.setInstanceId(instanceId);
        deploymentLog.setNodeId(nodeId);
        deploymentLog.setInterfaceName("Standard");
        deploymentLog.setOperationName("changeState");
        deploymentLog.setLevel(PaaSDeploymentLogLevel.INFO);
        deploymentLog.setTimestamp(new Date());
        deploymentLog.setType("state_change");
        deploymentLog.setWorkflowId("install");
        alienMonitorDao.save(deploymentLog);
        alienMonitorDao.getClient().admin().indices().prepareRefresh(PaaSDeploymentLog.class.getSimpleName().toLowerCase()).execute().actionGet();
    }
}
Also used : Date(java.util.Date) PaaSDeploymentLog(alien4cloud.paas.model.PaaSDeploymentLog)

Example 2 with PaaSDeploymentLog

use of alien4cloud.paas.model.PaaSDeploymentLog 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 3 with PaaSDeploymentLog

use of alien4cloud.paas.model.PaaSDeploymentLog 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 4 with PaaSDeploymentLog

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

the class LogListenerTask method toPaasDeploymentLog.

private PaaSDeploymentLog toPaasDeploymentLog(final LogEvent pLogEvent) {
    PaaSDeploymentLog deploymentLog = new PaaSDeploymentLog();
    deploymentLog.setDeploymentId(pLogEvent.getDeploymentId());
    deploymentLog.setContent(pLogEvent.getContent());
    deploymentLog.setExecutionId(pLogEvent.getExecutionId());
    deploymentLog.setInstanceId(pLogEvent.getInstanceId());
    deploymentLog.setInterfaceName(pLogEvent.getInterfaceName());
    deploymentLog.setLevel(PaaSDeploymentLogLevel.fromLevel(pLogEvent.getLevel().toLowerCase()));
    deploymentLog.setType(pLogEvent.getType());
    deploymentLog.setNodeId(pLogEvent.getNodeId());
    deploymentLog.setTimestamp(pLogEvent.getDate());
    deploymentLog.setWorkflowId(pLogEvent.getWorkflowId());
    deploymentLog.setOperationName(pLogEvent.getOperationName());
    return deploymentLog;
}
Also used : PaaSDeploymentLog(alien4cloud.paas.model.PaaSDeploymentLog)

Aggregations

PaaSDeploymentLog (alien4cloud.paas.model.PaaSDeploymentLog)4 Date (java.util.Date)3 PaaSMessageMonitorEvent (alien4cloud.paas.model.PaaSMessageMonitorEvent)2 DeploymentStatus (alien4cloud.paas.model.DeploymentStatus)1 PaaSDeploymentStatusMonitorEvent (alien4cloud.paas.model.PaaSDeploymentStatusMonitorEvent)1