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