use of cbit.vcell.server.SimpleJobStatusQuerySpec in project vcell by virtualcell.
the class ServerManageConsole method query.
/**
* Insert the method's description here.
* Creation date: (9/3/2003 8:00:07 AM)
*/
private void query() {
boolean bOtherConditions = false;
getRemoveFromListButton().setEnabled(false);
getSubmitSelectedButton().setEnabled(false);
getStopSelectedButton().setEnabled(false);
SimpleJobStatusQuerySpec querySpec = new SimpleJobStatusQuerySpec();
querySpec.maxRows = 1000;
String text = getQuerySimField().getText();
if (text != null && text.trim().length() > 0) {
try {
bOtherConditions = true;
long simID = Long.parseLong(text);
querySpec.simId = simID;
} catch (NumberFormatException ex) {
}
}
text = getQueryHostField().getText();
if (text != null && text.trim().length() > 0) {
bOtherConditions = true;
querySpec.computeHost = text.toLowerCase();
}
text = getQueryServerIDField().getText();
if (text != null && text.trim().length() > 0) {
bOtherConditions = true;
querySpec.serverId = text.toLowerCase();
}
text = getQueryUserField().getText();
if (text != null && text.trim().length() > 0) {
bOtherConditions = true;
querySpec.userid = text;
}
boolean bAllStatus = getQueryAllStatusCheck().isSelected();
querySpec.waiting = bAllStatus || getQueryWaitingCheck().isSelected();
querySpec.queued = bAllStatus || getQueryQueuedCheck().isSelected();
querySpec.dispatched = bAllStatus || getQueryDispatchedCheck().isSelected();
querySpec.running = bAllStatus || getQueryRunningCheck().isSelected();
querySpec.completed = bAllStatus || getQueryCompletedCheck().isSelected();
querySpec.stopped = bAllStatus || getQueryStoppedCheck().isSelected();
querySpec.failed = bAllStatus || getQueryFailedCheck().isSelected();
if (getQuerySubmitDateCheck().isSelected()) {
bOtherConditions = true;
// first second of day low time
querySpec.submitLowMS = getQuerySubmitFromDate().getDate().getTime();
// last second of dat high time
querySpec.submitHighMS = getQuerySubmitToDate().getDate().getTime() + TimeUnit.DAYS.toMillis(1) - 1;
}
if (getQueryStartDateCheck().isSelected()) {
bOtherConditions = true;
// first second of day low time
querySpec.startLowMS = getQueryStartFromDate().getDate().getTime();
// last second of dat high time
querySpec.startHighMS = getQueryStartToDate().getDate().getTime() + TimeUnit.DAYS.toMillis(1) - 1;
}
if (getQueryEndDateCheck().isSelected()) {
bOtherConditions = true;
// first second of day low time
querySpec.endLowMS = getQueryEndFromDate().getDate().getTime();
// last second of dat high time
querySpec.endHighMS = getQueryEndToDate().getDate().getTime() + TimeUnit.DAYS.toMillis(1) - 1;
}
if (getQueryCompletedCheck().isSelected() && !bOtherConditions) {
int n = javax.swing.JOptionPane.showConfirmDialog(this, "You are gonna get all the completed simulation jobs in the database, which is gonna be huge . Continue?", "Confirm", javax.swing.JOptionPane.YES_NO_OPTION);
if (n == javax.swing.JOptionPane.NO_OPTION) {
getNumResultsLabel().setText("0");
getNumSelectedLabel().setText("0");
((JobTableModel) getQueryResultTable().getModel()).setData(null);
return;
}
}
try {
SimulationDatabase simDatabase = new SimulationDatabaseDirect(adminDbTop, dbServerImpl, false);
SimpleJobStatus[] resultList = simDatabase.getSimpleJobStatus(null, querySpec);
getNumResultsLabel().setText("" + resultList.length);
getNumSelectedLabel().setText("0");
((JobTableModel) getQueryResultTable().getModel()).setData(Arrays.asList(resultList));
} catch (Exception ex) {
getNumResultsLabel().setText("Query failed, please try again!");
((JobTableModel) getQueryResultTable().getModel()).setData(null);
}
}
use of cbit.vcell.server.SimpleJobStatusQuerySpec in project vcell by virtualcell.
the class RestDatabaseService method query.
public SimpleJobStatus[] query(SimulationTasksServerResource resource, User vcellUser) throws SQLException, DataAccessException {
if (vcellUser == null) {
vcellUser = VCellApiApplication.DUMMY_USER;
}
String userID = vcellUser.getName();
SimpleJobStatusQuerySpec simQuerySpec = new SimpleJobStatusQuerySpec();
simQuerySpec.userid = userID;
simQuerySpec.simId = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_SIM_ID);
simQuerySpec.jobId = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_JOB_ID);
simQuerySpec.taskId = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_TASK_ID);
simQuerySpec.computeHost = resource.getQueryValue(SimulationTasksServerResource.PARAM_COMPUTE_HOST);
simQuerySpec.serverId = resource.getQueryValue(SimulationTasksServerResource.PARAM_SERVER_ID);
String hasData = resource.getQueryValue(SimulationTasksServerResource.PARAM_HAS_DATA);
if (hasData != null && hasData.equals("yes")) {
simQuerySpec.hasData = true;
} else if (hasData != null && hasData.equals("no")) {
simQuerySpec.hasData = false;
} else {
simQuerySpec.hasData = null;
}
simQuerySpec.waiting = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_WAITING, false);
simQuerySpec.queued = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_QUEUED, false);
simQuerySpec.dispatched = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_DISPATCHED, false);
simQuerySpec.running = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_RUNNING, false);
simQuerySpec.completed = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_COMPLETED, false);
simQuerySpec.failed = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_FAILED, false);
simQuerySpec.stopped = resource.getBooleanQueryValue(SimulationTasksServerResource.PARAM_STATUS_STOPPED, false);
simQuerySpec.submitLowMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_SUBMIT_LOW);
simQuerySpec.submitHighMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_SUBMIT_HIGH);
simQuerySpec.startLowMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_START_LOW);
simQuerySpec.startHighMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_START_HIGH);
simQuerySpec.endLowMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_END_LOW);
simQuerySpec.endHighMS = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_END_HIGH);
Long startRowParam = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_START_ROW);
// default
simQuerySpec.startRow = 1;
if (startRowParam != null) {
simQuerySpec.startRow = startRowParam.intValue();
}
Long maxRowsParam = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_MAX_ROWS);
// default
simQuerySpec.maxRows = 10;
if (maxRowsParam != null) {
simQuerySpec.maxRows = maxRowsParam.intValue();
}
VCMessageSession rpcSession = vcMessagingService.createProducerSession();
try {
UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(), null);
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
e.printStackTrace();
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
SimpleJobStatus[] simpleJobStatusArray = rpcSimServerProxy.getSimpleJobStatus(vcellUser, simQuerySpec);
return simpleJobStatusArray;
} finally {
rpcSession.close();
}
}
use of cbit.vcell.server.SimpleJobStatusQuerySpec in project vcell by virtualcell.
the class RestDatabaseService method query.
public SimulationStatusRepresentation[] query(SimulationStatusServerResource resource, User vcellUser) throws SQLException, DataAccessException {
if (vcellUser == null) {
vcellUser = VCellApiApplication.DUMMY_USER;
}
String userID = vcellUser.getName();
SimpleJobStatusQuerySpec simQuerySpec = new SimpleJobStatusQuerySpec();
simQuerySpec.userid = userID;
simQuerySpec.simId = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SIM_ID);
String hasData = resource.getQueryValue(SimulationStatusServerResource.PARAM_HAS_DATA);
if (hasData != null && hasData.equals("yes")) {
simQuerySpec.hasData = true;
} else if (hasData != null && hasData.equals("no")) {
simQuerySpec.hasData = false;
} else {
simQuerySpec.hasData = null;
}
simQuerySpec.waiting = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
simQuerySpec.queued = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
simQuerySpec.dispatched = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
simQuerySpec.running = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_ACTIVE, false);
simQuerySpec.completed = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_COMPLETED, false);
simQuerySpec.failed = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_FAILED, false);
simQuerySpec.stopped = resource.getBooleanQueryValue(SimulationStatusServerResource.PARAM_STATUS_STOPPED, false);
simQuerySpec.submitLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SUBMIT_LOW);
simQuerySpec.submitHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_SUBMIT_HIGH);
simQuerySpec.startLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_LOW);
simQuerySpec.startHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_HIGH);
simQuerySpec.endLowMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_END_LOW);
simQuerySpec.endHighMS = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_END_HIGH);
Long startRowParam = resource.getLongQueryValue(SimulationStatusServerResource.PARAM_START_ROW);
// default
simQuerySpec.startRow = 1;
if (startRowParam != null) {
simQuerySpec.startRow = startRowParam.intValue();
}
Long maxRowsParam = resource.getLongQueryValue(SimulationTasksServerResource.PARAM_MAX_ROWS);
// default
simQuerySpec.maxRows = 10;
if (maxRowsParam != null) {
simQuerySpec.maxRows = maxRowsParam.intValue();
}
SimulationStatus[] simStatuses = null;
HashMap<KeyValue, SimulationDocumentLink> simDocLinks = new HashMap<KeyValue, SimulationDocumentLink>();
//
// ask server for simJobStatuses with above query spec.
// find set of simulation IDs from the result set of simJobStatus
// ask server for simulationStatuses from list of sim IDs.
//
VCMessageSession rpcSession = vcMessagingService.createProducerSession();
try {
UserLoginInfo userLoginInfo = new UserLoginInfo(vcellUser.getName(), null);
try {
userLoginInfo.setUser(vcellUser);
} catch (Exception e) {
e.printStackTrace();
throw new DataAccessException(e.getMessage());
}
RpcSimServerProxy rpcSimServerProxy = new RpcSimServerProxy(userLoginInfo, rpcSession);
SimpleJobStatus[] simpleJobStatusArray = rpcSimServerProxy.getSimpleJobStatus(vcellUser, simQuerySpec);
// gather unique simIDs and go back and ask server for SimulationStatuses
for (SimpleJobStatus simpleJobStatus : simpleJobStatusArray) {
KeyValue simulationKey = simpleJobStatus.jobStatus.getVCSimulationIdentifier().getSimulationKey();
SimulationDocumentLink simulationDocumentLink = simpleJobStatus.simulationDocumentLink;
simDocLinks.put(simulationKey, simulationDocumentLink);
}
KeyValue[] simKeys = simDocLinks.keySet().toArray(new KeyValue[0]);
if (simKeys.length > 0) {
simStatuses = rpcSimServerProxy.getSimulationStatus(vcellUser, simKeys);
}
} finally {
rpcSession.close();
}
ArrayList<SimulationStatusRepresentation> simStatusReps = new ArrayList<SimulationStatusRepresentation>();
for (int i = 0; simStatuses != null && i < simStatuses.length; i++) {
KeyValue simulationKey = simStatuses[i].getVCSimulationIdentifier().getSimulationKey();
SimulationRep simRep = getSimulationRep(simulationKey);
try {
SimulationRepresentation simRepresentation = new SimulationRepresentation(simRep, simDocLinks.get(simulationKey));
simStatusReps.add(new SimulationStatusRepresentation(simRepresentation, simStatuses[i]));
} catch (ExpressionException e) {
e.printStackTrace(System.out);
}
}
return simStatusReps.toArray(new SimulationStatusRepresentation[0]);
}
use of cbit.vcell.server.SimpleJobStatusQuerySpec 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();
SimpleJobStatus[] 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);
}
}
}
Aggregations