Search in sources :

Example 1 with SimulationJobStatusEventRepresentation

use of org.vcell.api.common.events.SimulationJobStatusEventRepresentation in project vcell by virtualcell.

the class SimulationJobStatusEvent method toJsonRep.

public SimulationJobStatusEventRepresentation toJsonRep() {
    String vcellServerID = this.jobStatus.getServerID().toString();
    Date timeDateStamp = this.jobStatus.getTimeDateStamp();
    String simulationKey = this.jobStatus.getVCSimulationIdentifier().getSimulationKey().toString();
    int taskID = this.jobStatus.getTaskID();
    int jobIndex = this.jobStatus.getJobIndex();
    Date submitDate = this.jobStatus.getSubmitDate();
    String owner_userid = this.username;
    String onwer_userkey = this.jobStatus.getVCSimulationIdentifier().getOwner().getID().toString();
    SimulationJobStatusRepresentation.SchedulerStatus schedulerStatus = SimulationJobStatusRepresentation.SchedulerStatus.valueOf(this.jobStatus.getSchedulerStatus().name());
    SimulationJobStatusRepresentation.DetailedState detailedState = SimulationJobStatusRepresentation.DetailedState.valueOf(this.jobStatus.getSimulationMessage().getDetailedState().name());
    String detailedStateMessage = this.jobStatus.getSimulationMessage().getDisplayMessage();
    Long htcJobNumber = null;
    String htcComputeServer = null;
    SimulationJobStatusRepresentation.BatchSystemType htcBatchSystemType = null;
    Date simexe_startDate = null;
    Date simexe_latestUpdateDate = null;
    Date simexe_endDate = null;
    String computeHost = null;
    Boolean hasData = null;
    SimulationExecutionStatus simExeStatus = this.jobStatus.getSimulationExecutionStatus();
    if (simExeStatus != null) {
        HtcJobID htcJobID = simExeStatus.getHtcJobID();
        if (htcJobID != null) {
            htcJobNumber = htcJobID.getJobNumber();
            htcComputeServer = htcJobID.getServer();
            htcBatchSystemType = SimulationJobStatusRepresentation.BatchSystemType.valueOf(htcJobID.getBatchSystemType().name());
        }
        simexe_startDate = simExeStatus.getStartDate();
        simexe_latestUpdateDate = simExeStatus.getLatestUpdateDate();
        simexe_endDate = simExeStatus.getEndDate();
        computeHost = simExeStatus.getComputeHost();
        hasData = simExeStatus.hasData();
    }
    Integer queuePriority = null;
    Date queueDate = null;
    SimulationJobStatusRepresentation.SimulationQueueID queueId = null;
    SimulationQueueEntryStatus simQueueStatus = this.jobStatus.getSimulationQueueEntryStatus();
    if (simQueueStatus != null) {
        queuePriority = simQueueStatus.getQueuePriority();
        queueDate = simQueueStatus.getQueueDate();
        queueId = SimulationJobStatusRepresentation.SimulationQueueID.valueOf(simQueueStatus.getQueueID().name());
    }
    SimulationJobStatusRepresentation jobStatus = new SimulationJobStatusRepresentation(vcellServerID, timeDateStamp, simulationKey, taskID, jobIndex, submitDate, owner_userid, onwer_userkey, schedulerStatus, detailedState, detailedStateMessage, htcJobNumber, htcComputeServer, htcBatchSystemType, queuePriority, queueDate, queueId, simexe_startDate, simexe_latestUpdateDate, simexe_endDate, computeHost, hasData);
    SimulationJobStatusEventRepresentation eventRep = new SimulationJobStatusEventRepresentation(jobStatus, progress, timePoint, username);
    return eventRep;
}
Also used : SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) SimulationJobStatusRepresentation(org.vcell.api.common.events.SimulationJobStatusRepresentation) SimulationJobStatusEventRepresentation(org.vcell.api.common.events.SimulationJobStatusEventRepresentation) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) HtcJobID(cbit.vcell.server.HtcJobID)

Example 2 with SimulationJobStatusEventRepresentation

use of org.vcell.api.common.events.SimulationJobStatusEventRepresentation in project vcell by virtualcell.

the class RestEventService method newEventMessage.

private void newEventMessage(MessageEvent event) {
    System.out.println(getClass().getName() + ".newEventMessage(" + event.getClass().getSimpleName() + ": " + event);
    if (event instanceof ExportEvent) {
        ExportEvent exportEvent = (ExportEvent) event;
        try {
            ExportEventRepresentation exportEventRep = exportEvent.toJsonRep();
            ExportEvent event2 = ExportEvent.fromJsonRep(this, exportEventRep);
            if (!Compare.isEqual(event2.getFormat(), exportEvent.getFormat())) {
                throw new RuntimeException("Export event round-trip failed");
            }
            if (!Compare.isEqual(event2.getJobID(), exportEvent.getJobID())) {
                throw new RuntimeException("Export event round-trip failed");
            }
            Gson gson = new Gson();
            String eventJSON = gson.toJson(exportEventRep);
            insert(exportEventRep.username, EventType.ExportEvent, eventJSON);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (event instanceof SimulationJobStatusEvent) {
        SimulationJobStatusEvent simJobEvent = (SimulationJobStatusEvent) event;
        try {
            SimulationJobStatusEventRepresentation simJobEventRep = simJobEvent.toJsonRep();
            SimulationJobStatusEvent event2 = SimulationJobStatusEvent.fromJsonRep(this, simJobEventRep);
            if (!Compare.isEqual(event2.getJobStatus(), simJobEvent.getJobStatus())) {
                throw new RuntimeException("SimulationJobStatus event round-trip failed");
            }
            if (!Compare.isEqual(event2.getProgress(), simJobEvent.getProgress())) {
                throw new RuntimeException("SimulationJobStatus <PROGRESS> event round-trip failed");
            }
            Gson gson = new Gson();
            String eventJSON = gson.toJson(simJobEventRep);
            insert(simJobEventRep.username, EventType.SimJob, eventJSON);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else if (event instanceof VCellMessageEvent) {
        VCellMessageEvent vcellMessageEvent = (VCellMessageEvent) event;
        lg.error("event of type VCellMessageEvent not supported");
    } else if (event instanceof WorkerEvent) {
        lg.error("event of type WorkerEvent not supported");
        WorkerEvent workerEvent = (WorkerEvent) event;
    } else if (event instanceof PerformanceMonitorEvent) {
        lg.error("event of type PerformanceMonitorEvent not supported");
        PerformanceMonitorEvent performanceMonitorEvent = (PerformanceMonitorEvent) event;
    } else if (event instanceof DataJobEvent) {
        lg.error("event of type DataJobEvent not supported");
        DataJobEvent dataJobEvent = (DataJobEvent) event;
        try {
            DataJobEventRepresentation dataJobEventRep = dataJobEvent.toJsonRep();
            DataJobEvent event2 = DataJobEvent.fromJsonRep(this, dataJobEventRep);
            if (!Compare.isEqual(event2.getDataIdString(), dataJobEvent.getDataIdString())) {
                throw new RuntimeException("DataJob event round-trip failed");
            }
            if (!Compare.isEqual(event2.getProgress(), dataJobEvent.getProgress())) {
                throw new RuntimeException("DataJob <PROGRESS> event round-trip failed");
            }
            Gson gson = new Gson();
            String eventJSON = gson.toJson(dataJobEventRep);
            insert(dataJobEventRep.username, EventType.DataJob, eventJSON);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
Also used : ExportEventRepresentation(org.vcell.api.common.events.ExportEventRepresentation) ExportEvent(cbit.rmi.event.ExportEvent) SimulationJobStatusEventRepresentation(org.vcell.api.common.events.SimulationJobStatusEventRepresentation) Gson(com.google.gson.Gson) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) DataJobEvent(cbit.rmi.event.DataJobEvent) DataJobEventRepresentation(org.vcell.api.common.events.DataJobEventRepresentation) WorkerEvent(cbit.rmi.event.WorkerEvent) VCellMessageEvent(cbit.rmi.event.VCellMessageEvent) PerformanceMonitorEvent(cbit.rmi.event.PerformanceMonitorEvent)

Aggregations

SimulationJobStatusEventRepresentation (org.vcell.api.common.events.SimulationJobStatusEventRepresentation)2 DataJobEvent (cbit.rmi.event.DataJobEvent)1 ExportEvent (cbit.rmi.event.ExportEvent)1 PerformanceMonitorEvent (cbit.rmi.event.PerformanceMonitorEvent)1 SimulationJobStatusEvent (cbit.rmi.event.SimulationJobStatusEvent)1 VCellMessageEvent (cbit.rmi.event.VCellMessageEvent)1 WorkerEvent (cbit.rmi.event.WorkerEvent)1 HtcJobID (cbit.vcell.server.HtcJobID)1 SimulationExecutionStatus (cbit.vcell.server.SimulationExecutionStatus)1 SimulationQueueEntryStatus (cbit.vcell.server.SimulationQueueEntryStatus)1 Gson (com.google.gson.Gson)1 Date (java.util.Date)1 DataJobEventRepresentation (org.vcell.api.common.events.DataJobEventRepresentation)1 ExportEventRepresentation (org.vcell.api.common.events.ExportEventRepresentation)1 SimulationJobStatusRepresentation (org.vcell.api.common.events.SimulationJobStatusRepresentation)1