Search in sources :

Example 21 with SimulationJobStatus

use of cbit.vcell.server.SimulationJobStatus in project vcell by virtualcell.

the class AdminJobsRestlet method handle.

@Override
public void handle(Request req, Response response) {
    if (req.getMethod().equals(Method.GET)) {
        try {
            VCellApiApplication application = ((VCellApiApplication) getApplication());
            // User vcellUser = application.getVCellUser(req.getChallengeResponse(),AuthenticationPolicy.prohibitInvalidCredentials);
            // User adminUser = new User(PropertyLoader.ADMINISTRATOR_ACCOUNT, new KeyValue(PropertyLoader.ADMINISTRATOR_ID));
            // if (!vcellUser.equals(adminUser)) {
            // getLogger().severe("AdminJobsRestlet: user '"+vcellUser.toString()+"' is not authorized");
            // response.setStatus(Status.CLIENT_ERROR_UNAUTHORIZED);
            // response.setEntity("not authorized for this service", MediaType.TEXT_PLAIN);
            // return;
            // }
            HttpRequest request = (HttpRequest) req;
            Form form = request.getResourceRef().getQueryAsForm();
            String jsonQuery = form.getFirstValue(PARAM_JSON_QUERY, true);
            Gson gson = new Gson();
            SimpleJobStatusQuerySpec querySpec = new SimpleJobStatusQuerySpec();
            if (jsonQuery != null) {
                querySpec = gson.fromJson(jsonQuery, SimpleJobStatusQuerySpec.class);
            } else {
                querySpec.submitLowMS = getLongParam(form, PARAM_SUBMIT_LOW, null);
                querySpec.submitHighMS = getLongParam(form, PARAM_SUBMIT_HIGH, null);
                querySpec.startLowMS = getLongParam(form, PARAM_START_LOW, null);
                querySpec.startHighMS = getLongParam(form, PARAM_START_HIGH, null);
                querySpec.endLowMS = getLongParam(form, PARAM_END_LOW, null);
                querySpec.endHighMS = getLongParam(form, PARAM_END_HIGH, null);
                querySpec.startRow = getIntegerParam(form, PARAM_START_ROW, 0);
                querySpec.maxRows = getIntegerParam(form, PARAM_MAX_ROWS, 100);
                querySpec.serverId = getStringParam(form, PARAM_SERVERID, null);
                querySpec.computeHost = getStringParam(form, PARAM_COMPUTEHOST, null);
                querySpec.userid = getStringParam(form, PARAM_USERID, null);
                querySpec.simId = getLongParam(form, PARAM_SIMID, null);
                querySpec.jobId = getLongParam(form, PARAM_JOBID, null);
                querySpec.taskId = getLongParam(form, PARAM_TASKID, null);
                querySpec.hasData = getBooleanParam(form, PARAM_HAS_DATA, null);
                querySpec.waiting = getBooleanParam(form, PARAM_STATUS_WAITING, true);
                querySpec.queued = getBooleanParam(form, PARAM_STATUS_QUEUED, true);
                querySpec.dispatched = getBooleanParam(form, PARAM_STATUS_DISPATCHED, true);
                querySpec.running = getBooleanParam(form, PARAM_STATUS_RUNNING, true);
                querySpec.completed = getBooleanParam(form, PARAM_STATUS_COMPLETED, true);
                querySpec.failed = getBooleanParam(form, PARAM_STATUS_FAILED, true);
                querySpec.stopped = getBooleanParam(form, PARAM_STATUS_STOPPED, true);
            }
            if (querySpec.serverId != null) {
                querySpec.serverId = querySpec.serverId.toLowerCase();
            }
            AdminService adminService = application.getAdminService();
            SimulationJobStatus[] jobStatusArray = adminService.query(querySpec);
            SimpleJobStatusRepresentation[] reps = new SimpleJobStatusRepresentation[jobStatusArray.length];
            for (int i = 0; i < jobStatusArray.length; i++) {
                reps[i] = jobStatusArray[i].toRep();
            }
            String jobStatusArrayJson = gson.toJson(reps);
            response.setStatus(Status.SUCCESS_OK);
            response.setEntity(new JsonRepresentation(jobStatusArrayJson));
        } catch (Exception e) {
            getLogger().severe("failed to retrieve job status: " + e.getMessage());
            e.printStackTrace();
            response.setStatus(Status.SERVER_ERROR_INTERNAL);
            response.setEntity("failed to retrieve job status: " + e.getMessage(), MediaType.TEXT_PLAIN);
        }
    }
}
Also used : HttpRequest(org.restlet.engine.adapter.HttpRequest) SimpleJobStatusQuerySpec(cbit.vcell.server.SimpleJobStatusQuerySpec) SimpleJobStatusRepresentation(org.vcell.api.common.SimpleJobStatusRepresentation) Form(org.restlet.data.Form) Gson(com.google.gson.Gson) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) VCellApiApplication(org.vcell.rest.VCellApiApplication) JsonRepresentation(org.restlet.ext.json.JsonRepresentation)

Example 22 with SimulationJobStatus

use of cbit.vcell.server.SimulationJobStatus in project vcell by virtualcell.

the class SimulationStatusDetails method getSimulationStatusDisplay.

/**
 * Comment
 */
Object getSimulationStatusDisplay(int index) {
    SimulationStatus simStatus = simWorkspace.getSimulationStatus(sim);
    if (simStatus != null) {
        SimulationJobStatus jobStatus = simStatus.getJobStatus(index);
        Double progress = simStatus.getProgressAt(index);
        if (jobStatus != null) {
            if (progress != null && jobStatus.getSchedulerStatus().isRunning() && progress.doubleValue() > 0) {
                statusBars[index].setValue((int) (progress.doubleValue() * 100));
                return statusBars[index];
            } else {
                return jobStatus.getSimulationMessage().getDisplayMessage();
            }
        } else {
            return simStatus.getDetails();
        }
    }
    return null;
}
Also used : SimulationStatus(cbit.vcell.server.SimulationStatus) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus)

Example 23 with SimulationJobStatus

use of cbit.vcell.server.SimulationJobStatus in project vcell by virtualcell.

the class SimulationJobStatusEvent method fromJsonRep.

public static SimulationJobStatusEvent fromJsonRep(Object eventSource, SimulationJobStatusEventRepresentation eventRep) {
    String simid = Simulation.createSimulationID(new KeyValue(eventRep.jobStatus.simulationKey));
    int jobIndex = eventRep.jobStatus.jobIndex;
    int taskID = eventRep.jobStatus.taskID;
    VCellServerID serverID = VCellServerID.getServerID(eventRep.jobStatus.vcellServerID);
    KeyValue simkey = new KeyValue(eventRep.jobStatus.simulationKey);
    User owner = new User(eventRep.jobStatus.owner_userid, new KeyValue(eventRep.jobStatus.onwer_userkey));
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simkey, owner);
    Date submitDate = eventRep.jobStatus.submitDate;
    SchedulerStatus schedulerStatus = null;
    if (eventRep.jobStatus.schedulerStatus != null) {
        schedulerStatus = SchedulerStatus.valueOf(eventRep.jobStatus.schedulerStatus.name());
    }
    HtcJobID htcJobID = null;
    Long htcJobNumber = eventRep.jobStatus.htcJobNumber;
    SimulationJobStatusRepresentation.BatchSystemType htcBatchSystemType = eventRep.jobStatus.htcBatchSystemType;
    if (htcJobNumber != null) {
        htcJobID = new HtcJobID(htcJobNumber.toString(), BatchSystemType.valueOf(htcBatchSystemType.name()));
    }
    SimulationMessage simMessage = null;
    DetailedState detailedState = DetailedState.valueOf(eventRep.jobStatus.detailedState.name());
    String message = eventRep.jobStatus.detailedStateMessage;
    if (detailedState != null) {
        simMessage = SimulationMessage.create(detailedState, message, htcJobID);
    }
    SimulationQueueEntryStatus simQueueStatus = null;
    Date queueDate = eventRep.jobStatus.queueDate;
    Integer queuePriority = eventRep.jobStatus.queuePriority;
    SimulationJobStatusRepresentation.SimulationQueueID queueId2 = eventRep.jobStatus.queueId;
    if (queueDate != null && queuePriority != null) {
        simQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationQueueID.valueOf(queueId2.name()));
    }
    SimulationExecutionStatus simExeStatus = null;
    Date startDate = eventRep.jobStatus.simexe_startDate;
    String computeHost = eventRep.jobStatus.computeHost;
    Date latestUpdateDate = eventRep.jobStatus.simexe_latestUpdateDate;
    Date endDate = eventRep.jobStatus.simexe_endDate;
    Boolean hasData = eventRep.jobStatus.hasData;
    if (latestUpdateDate != null) {
        simExeStatus = new SimulationExecutionStatus(startDate, computeHost, latestUpdateDate, endDate, hasData, htcJobID);
    }
    SimulationJobStatus jobStatus = new SimulationJobStatus(serverID, vcSimID, jobIndex, submitDate, schedulerStatus, taskID, simMessage, simQueueStatus, simExeStatus);
    Double progress = eventRep.progress;
    Double timepoint = eventRep.timePoint;
    String username = eventRep.username;
    SimulationJobStatusEvent event = new SimulationJobStatusEvent(eventSource, simid, jobStatus, progress, timepoint, username);
    return event;
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) SimulationJobStatusRepresentation(org.vcell.api.common.events.SimulationJobStatusRepresentation) DetailedState(cbit.vcell.solver.server.SimulationMessage.DetailedState) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) VCellServerID(org.vcell.util.document.VCellServerID) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) HtcJobID(cbit.vcell.server.HtcJobID)

Example 24 with SimulationJobStatus

use of cbit.vcell.server.SimulationJobStatus in project vcell by virtualcell.

the class SimulationControllerImpl method onServiceControlTopic_StopSimulation.

private void onServiceControlTopic_StopSimulation(VCMessage message) {
    KeyValue simKey = new KeyValue(String.valueOf(message.getLongProperty(MessageConstants.SIMKEY_PROPERTY)));
    int jobIndex = message.getIntProperty(MessageConstants.JOBINDEX_PROPERTY);
    int taskID = message.getIntProperty(MessageConstants.TASKID_PROPERTY);
    try {
        SimulationTaskID simTaskInfo = new SimulationTaskID(simKey, jobIndex, taskID);
        LocalSolverController solverController = solverControllerHash.get(simTaskInfo);
        if (solverController != null) {
            // can only start after updating the database is done
            solverController.stopSimulationJob();
        }
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
        VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, localVCellConnection.getUserLoginInfo().getUser());
        SimulationJobStatus newJobStatus = new SimulationJobStatus(VCellServerID.getSystemServerID(), vcSimID, jobIndex, null, SchedulerStatus.FAILED, taskID, SimulationMessage.jobFailed(e.getMessage()), null, null);
        SimulationJobStatusEvent event = new SimulationJobStatusEvent(this, Simulation.createSimulationID(simKey), newJobStatus, null, null, vcSimID.getOwner().getName());
        fireSimulationJobStatusEvent(event);
    }
}
Also used : LocalSolverController(cbit.vcell.solvers.LocalSolverController) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue) SimulationTaskID(cbit.vcell.server.SimulationTaskID) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) SQLException(java.sql.SQLException) VCMessagingException(cbit.vcell.message.VCMessagingException) SolverException(cbit.vcell.solver.SolverException) AuthenticationException(org.vcell.util.AuthenticationException) DataAccessException(org.vcell.util.DataAccessException) JMSException(javax.jms.JMSException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) ConfigurationException(org.vcell.util.ConfigurationException)

Example 25 with SimulationJobStatus

use of cbit.vcell.server.SimulationJobStatus in project vcell by virtualcell.

the class SimulationControllerImpl method onWorkerEvent.

/**
 * Insert the method's description here.
 * Creation date: (3/11/2004 10:44:18 AM)
 * @param newJobStatus cbit.vcell.messaging.db.SimulationJobStatus
 * @param progress java.lang.Double
 * @param timePoint java.lang.Double
 */
public void onWorkerEvent(WorkerEvent workerEvent) {
    try {
        LocalVCMessageListener localVCMessageListener = new LocalVCMessageListener() {

            public void onLocalVCMessage(VCDestination destination, VCMessage objectMessage) {
                if (destination == VCellTopic.ClientStatusTopic && objectMessage.getObjectContent() instanceof SimulationJobStatus) {
                    onClientStatusTopic_SimulationJobStatus(objectMessage);
                } else {
                    throw new RuntimeException("SimulationControllerImpl.onWorkerEvent().localMessageListener::  expecting object message with SimulationJobStatus to topic " + VCellTopic.ClientStatusTopic.getName() + ": received \"" + objectMessage.show() + "\"");
                }
            }
        };
        LocalVCMessageAdapter vcMessageSession = new LocalVCMessageAdapter(localVCMessageListener);
        simulationDispatcherEngine.onWorkerEvent(workerEvent, simulationDatabase, vcMessageSession);
        vcMessageSession.deliverAll();
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
    }
}
Also used : VCDestination(cbit.vcell.message.VCDestination) LocalVCMessageListener(cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener) VCMessage(cbit.vcell.message.VCMessage) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) SQLException(java.sql.SQLException) VCMessagingException(cbit.vcell.message.VCMessagingException) SolverException(cbit.vcell.solver.SolverException) AuthenticationException(org.vcell.util.AuthenticationException) DataAccessException(org.vcell.util.DataAccessException) JMSException(javax.jms.JMSException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) ConfigurationException(org.vcell.util.ConfigurationException) LocalVCMessageAdapter(cbit.vcell.message.local.LocalVCMessageAdapter)

Aggregations

SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)29 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)9 KeyValue (org.vcell.util.document.KeyValue)9 StatusMessage (cbit.vcell.message.messages.StatusMessage)7 SimulationExecutionStatus (cbit.vcell.server.SimulationExecutionStatus)7 SimulationQueueEntryStatus (cbit.vcell.server.SimulationQueueEntryStatus)7 Date (java.util.Date)6 SimulationJobStatusEvent (cbit.rmi.event.SimulationJobStatusEvent)5 ArrayList (java.util.ArrayList)5 VCellServerID (org.vcell.util.document.VCellServerID)5 VCMessage (cbit.vcell.message.VCMessage)4 VCMessagingException (cbit.vcell.message.VCMessagingException)4 HtcJobID (cbit.vcell.server.HtcJobID)4 SimulationStatus (cbit.vcell.server.SimulationStatus)4 VCDestination (cbit.vcell.message.VCDestination)3 LocalVCMessageAdapter (cbit.vcell.message.local.LocalVCMessageAdapter)3 LocalVCMessageListener (cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener)3 SchedulerStatus (cbit.vcell.server.SimulationJobStatus.SchedulerStatus)3 SimulationJobStatusPersistent (cbit.vcell.server.SimulationJobStatusPersistent)3 SolverException (cbit.vcell.solver.SolverException)3