use of cbit.vcell.server.SimulationJobStatus.SchedulerStatus in project vcell by virtualcell.
the class ViewJobsPanel method initialize.
private void initialize() {
try {
setName("ViewSimulationJobsPanel");
getRefreshAllButton().addActionListener(eventHandler);
// ----------------------------------------------------------------------------------
// filters, buttons
JPanel top = new JPanel();
// table with results
JPanel bottom = new JPanel();
Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
TitledBorder titleTop = BorderFactory.createTitledBorder(loweredEtchedBorder, " Query Filters ");
titleTop.setTitleJustification(TitledBorder.LEFT);
titleTop.setTitlePosition(TitledBorder.TOP);
TitledBorder titleBottom = BorderFactory.createTitledBorder(loweredEtchedBorder, " Query Results ");
titleBottom.setTitleJustification(TitledBorder.LEFT);
titleBottom.setTitlePosition(TitledBorder.TOP);
top.setBorder(titleTop);
bottom.setBorder(titleBottom);
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
// top, left, bottom, right
gbc.insets = new Insets(5, 2, 2, 3);
add(top, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
add(bottom, gbc);
// --------------------------------------- top panel (filters, button) --------------
// filters
JPanel left = new JPanel();
JPanel center = new SeparatedJPanel();
// buttons
JPanel right = new SeparatedJPanel();
top.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 3);
top.add(left, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
top.add(center, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 2, 2, 3);
top.add(right, gbc);
// ------------------------------------ left panel (of top panel) -------------
left.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 0);
left.add(getWaitingButton(), gbc);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 3);
JLabel label = new JLabel(waitingIcon);
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 15, 2, 0);
left.add(getQueuedButton(), gbc);
gbc.gridx = 3;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 10);
label = new JLabel(queuedIcon);
left.add(label, gbc);
// -------------------------------------
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 0);
left.add(getDispatchedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 3);
label = new JLabel(dispatchedIcon);
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 15, 2, 0);
left.add(getRunningButton(), gbc);
gbc.gridx = 3;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 10);
label = new JLabel(runningIcon);
left.add(label, gbc);
// -------------------------------------
gbc.gridx = 0;
gbc.gridy = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 0);
left.add(getCompletedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 3);
label = new JLabel(completedIcon);
left.add(label, gbc);
gbc.gridx = 2;
gbc.gridy = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 15, 2, 3);
left.add(getFailedButton(), gbc);
gbc.gridx = 3;
gbc.gridy = 2;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 10);
label = new JLabel(failedIcon);
left.add(label, gbc);
// -------------------------------------
gbc.gridx = 0;
gbc.gridy = 3;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 2, 2, 0);
left.add(getStoppedButton(), gbc);
gbc.gridx = 1;
gbc.gridy = 3;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 0, 2, 3);
label = new JLabel(stoppedIcon);
left.add(label, gbc);
// ---------------------------------------- center panel (of top panel) ------------
center.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 15, 4, 4);
center.add(new JLabel("Max # of results "), gbc);
textFieldJobsLimit = new JTextField();
textFieldJobsLimit.addActionListener(eventHandler);
// textFieldJobsLimit.getDocument().addDocumentListener(eventHandler);
textFieldJobsLimit.setText(maxRows + "");
Dimension d = textFieldJobsLimit.getPreferredSize();
d.width = 80;
textFieldJobsLimit.setPreferredSize(d);
textFieldJobsLimit.setMaximumSize(d);
gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 0, 4, 4);
center.add(textFieldJobsLimit, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 2;
gbc.gridy = 0;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 15, 2, 3);
center.add(getOrphanedButton(), gbc);
// gbc = new GridBagConstraints();
// gbc.weighty = 1.0;
// gbc.gridx = 0;
// gbc.gridy = 2;
// // gbc.gridheight = GridBagConstraints.REMAINDER;
// gbc.anchor = GridBagConstraints.WEST;
// gbc.fill = java.awt.GridBagConstraints.VERTICAL;
// gbc.insets = new Insets(4,4,4,4);
// center.add(new JLabel("---"), gbc); // fake vertical
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 2;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = java.awt.GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 11, 4, 4);
center.add(getSubmitDatePanel(), gbc);
gbc = new GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 3;
gbc.gridy = 2;
gbc.anchor = GridBagConstraints.EAST;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 4);
// fake horizontal
center.add(new JLabel("-"), gbc);
// ---------------------------------------- right panel (of top panel) -------------
right.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.weighty = 1.0;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.anchor = GridBagConstraints.WEST;
gbc.fill = java.awt.GridBagConstraints.VERTICAL;
// fake vertical
right.add(new JLabel(""), gbc);
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 0;
gbc.weighty = 0;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 12, 4, 8);
right.add(getRefreshAllButton(), gbc);
getCompletedButton().setSelected(false);
getDispatchedButton().setSelected(true);
getFailedButton().setSelected(true);
getQueuedButton().setSelected(true);
getRunningButton().setSelected(true);
getStoppedButton().setSelected(true);
getWaitingButton().setSelected(true);
getOrphanedButton().setSelected(false);
getSubmitBetweenButton().setSelected(false);
// ----------------------------------------- bottom panel (the table) -------------------
table = new EditorScrollTable();
model = new SimulationJobsTableModel(table, this);
table.setModel(model);
table.getSelectionModel().addListSelectionListener(eventHandler);
table.getModel().addTableModelListener(eventHandler);
table.addMouseMotionListener(new // add toolTipText for each table cell
MouseMotionAdapter() {
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
int row = table.rowAtPoint(p);
int column = table.columnAtPoint(p);
table.setToolTipText(String.valueOf(table.getValueAt(row, column)));
}
});
bottom.setLayout(new GridBagLayout());
int gridy = 0;
gbc = new java.awt.GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.gridwidth = 8;
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(4, 4, 4, 4);
// table.setPreferredScrollableViewportSize(new Dimension(700,350)); // apparently useless
bottom.add(table.getEnclosingScrollPane(), gbc);
gridy++;
gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = gridy;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.insets = new Insets(4, 4, 4, 4);
bottom.add(new JLabel("Search "), gbc);
textFieldSearch = new JTextField(70);
textFieldSearch.addActionListener(eventHandler);
textFieldSearch.getDocument().addDocumentListener(eventHandler);
textFieldSearch.putClientProperty("JTextField.variant", "search");
gbc = new java.awt.GridBagConstraints();
gbc.weightx = 1.0;
gbc.gridx = 1;
gbc.gridy = gridy;
gbc.gridwidth = 3;
gbc.anchor = GridBagConstraints.LINE_START;
gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 0, 4, 4);
bottom.add(textFieldSearch, gbc);
gbc = new GridBagConstraints();
gbc.gridx = 4;
gbc.gridy = gridy;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(4, 4, 4, 10);
bottom.add(countLabel, gbc);
// renderer for the status icon; the tooltip gives the text
DefaultScrollTableCellRenderer statusCellRenderer = new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus js = (SimpleJobStatus) selectedObject;
SchedulerStatus ss1 = js.jobStatus.getSchedulerStatus();
switch(ss1) {
case WAITING:
setIcon(waitingIcon);
break;
case QUEUED:
setIcon(queuedIcon);
break;
case DISPATCHED:
setIcon(dispatchedIcon);
break;
case RUNNING:
setIcon(runningIcon);
break;
case COMPLETED:
setIcon(completedIcon);
break;
case STOPPED:
setIcon(stoppedIcon);
break;
case FAILED:
setIcon(failedIcon);
break;
default:
setIcon(failedIcon);
break;
}
// setText("");
setToolTipText(ss1.getDescription());
setHorizontalTextPosition(SwingConstants.RIGHT);
}
}
return this;
}
};
// statusCellRenderer.setHorizontalAlignment(JLabel.RIGHT);
DefaultScrollTableCellRenderer dateTimeCellRenderer = new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
DateFormat df = new SimpleDateFormat("MM.dd.yyyy HH:MM:SS");
Date date = sjs.jobStatus.getStartDate();
String str = df.format(date);
setToolTipText(str);
}
}
return this;
}
};
DefaultScrollTableCellRenderer hasDataCellRenderer = new DefaultScrollTableCellRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
setText((String) value);
if (table.getModel() instanceof VCellSortTableModel<?>) {
Object selectedObject = null;
if (table.getModel() == model) {
selectedObject = model.getValueAt(row);
}
if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
if (sjs.jobStatus.hasData()) {
setIcon(dataYesIcon);
} else {
setIcon(dataNoIcon);
}
}
}
return this;
}
};
table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setCellRenderer(statusCellRenderer);
table.getColumnModel().getColumn(SimulationJobsTableModel.iColSubmitDate).setCellRenderer(dateTimeCellRenderer);
table.getColumnModel().getColumn(SimulationJobsTableModel.iColHasData).setCellRenderer(hasDataCellRenderer);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColDepiction).setMinWidth(400);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setPreferredWidth(30);
// table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setMaxWidth(30);
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
refreshInterface();
} catch (java.lang.Throwable ivjExc) {
handleException(ivjExc);
}
}
use of cbit.vcell.server.SimulationJobStatus.SchedulerStatus in project vcell by virtualcell.
the class SimulationDatabaseDirect method translateToSimulationJobStatusTransient.
private SimulationJobStatus translateToSimulationJobStatusTransient(SimulationJobStatusPersistent simJobStatus) {
VCellServerID serverID = simJobStatus.getServerID();
VCSimulationIdentifier vcSimID = simJobStatus.getVCSimulationIdentifier();
int jobIndex = simJobStatus.getJobIndex();
Date submitDate = simJobStatus.getSubmitDate();
SchedulerStatus schedulerStatus = SimulationJobStatus.SchedulerStatus.valueOf(simJobStatus.getSchedulerStatus().name());
int taskID = simJobStatus.getTaskID();
SimulationMessage simMessage = SimulationMessage.fromSerializedMessage(simJobStatus.getSimulationMessage().toSerialization());
Date queueDate = simJobStatus.getSimulationQueueEntryStatus().getQueueDate();
int queuePriority = simJobStatus.getSimulationQueueEntryStatus().getQueuePriority();
SimulationQueueID queueId = SimulationJobStatus.SimulationQueueID.valueOf(simJobStatus.getSimulationQueueEntryStatus().getQueueID().name());
SimulationQueueEntryStatus simQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, queueId);
SimulationExecutionStatus simExecStatus = new SimulationExecutionStatus(simJobStatus.getSimulationExecutionStatus().getStartDate(), simJobStatus.getSimulationExecutionStatus().getComputeHost(), simJobStatus.getSimulationExecutionStatus().getLatestUpdateDate(), simJobStatus.getSimulationExecutionStatus().getEndDate(), simJobStatus.getSimulationExecutionStatus().hasData(), simJobStatus.getSimulationExecutionStatus().getHtcJobID());
SimulationJobStatus simJobStatusTransient = new SimulationJobStatus(serverID, vcSimID, jobIndex, submitDate, schedulerStatus, taskID, simMessage, simQueueStatus, simExecStatus);
return simJobStatusTransient;
}
use of cbit.vcell.server.SimulationJobStatus.SchedulerStatus in project vcell by virtualcell.
the class SimulationStateMachine method onWorkerEvent.
public synchronized void onWorkerEvent(WorkerEvent workerEvent, SimulationDatabase simulationDatabase, VCMessageSession session) throws DataAccessException, VCMessagingException, SQLException {
updateSolverProcessTimestamp();
WorkerEventMessage workerEventMessage = new WorkerEventMessage(workerEvent);
VCMongoMessage.sendWorkerEvent(workerEventMessage);
// as the filter of the client
String userName = workerEvent.getUserName();
int workerEventTaskID = workerEvent.getTaskID();
if (lg.isTraceEnabled())
lg.trace("onWorkerEventMessage[" + workerEvent.getEventTypeID() + "," + workerEvent.getSimulationMessage() + "][simid=" + workerEvent.getVCSimulationDataIdentifier() + ",job=" + jobIndex + ",task=" + workerEventTaskID + "]");
VCSimulationDataIdentifier vcSimDataID = workerEvent.getVCSimulationDataIdentifier();
if (vcSimDataID == null) {
VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent - no SimID in message): " + workerEvent.show());
return;
}
KeyValue simKey = vcSimDataID.getSimulationKey();
SimulationJobStatus oldSimulationJobStatus = simulationDatabase.getLatestSimulationJobStatus(simKey, jobIndex);
if (oldSimulationJobStatus == null) {
VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent, no current SimulationJobStatus: " + workerEvent.show());
return;
}
if (oldSimulationJobStatus == null || oldSimulationJobStatus.getSchedulerStatus().isDone() || oldSimulationJobStatus.getTaskID() > workerEventTaskID) {
VCMongoMessage.sendInfo("onWorkerEvent() ignoring outdated WorkerEvent, (currState=" + oldSimulationJobStatus.getSchedulerStatus().getDescription() + "): " + workerEvent.show());
return;
}
int taskID = oldSimulationJobStatus.getTaskID();
SchedulerStatus oldSchedulerStatus = oldSimulationJobStatus.getSchedulerStatus();
//
// status information (initialized as if new record)
//
Date startDate = null;
Date lastUpdateDate = null;
Date endDate = null;
boolean hasData = false;
HtcJobID htcJobID = null;
String computeHost = null;
VCellServerID vcServerID = VCellServerID.getSystemServerID();
Date submitDate = null;
Date queueDate = null;
int queuePriority = PRIORITY_DEFAULT;
SimulationJobStatus.SimulationQueueID simQueueID = SimulationJobStatus.SimulationQueueID.QUEUE_ID_WAITING;
//
// update using previously stored status (if available).
//
SimulationExecutionStatus oldSimExeStatus = oldSimulationJobStatus.getSimulationExecutionStatus();
if (oldSimExeStatus != null && oldSimExeStatus.getStartDate() != null) {
startDate = oldSimExeStatus.getStartDate();
}
if (oldSimExeStatus != null && oldSimExeStatus.getLatestUpdateDate() != null) {
lastUpdateDate = oldSimExeStatus.getLatestUpdateDate();
}
if (oldSimExeStatus != null && oldSimExeStatus.getEndDate() != null) {
endDate = oldSimExeStatus.getEndDate();
}
if (oldSimExeStatus != null && oldSimExeStatus.hasData()) {
hasData = true;
}
if (oldSimExeStatus != null && oldSimExeStatus.getComputeHost() != null) {
computeHost = oldSimExeStatus.getComputeHost();
}
if (oldSimExeStatus != null && oldSimExeStatus.getHtcJobID() != null) {
htcJobID = oldSimExeStatus.getHtcJobID();
}
vcServerID = oldSimulationJobStatus.getServerID();
submitDate = oldSimulationJobStatus.getSubmitDate();
SimulationQueueEntryStatus oldQueueStatus = oldSimulationJobStatus.getSimulationQueueEntryStatus();
if (oldQueueStatus != null && oldQueueStatus.getQueueDate() != null) {
queueDate = oldQueueStatus.getQueueDate();
}
if (oldQueueStatus != null) {
queuePriority = oldQueueStatus.getQueuePriority();
}
if (oldQueueStatus != null && oldQueueStatus.getQueueID() != null) {
simQueueID = oldQueueStatus.getQueueID();
}
//
if (workerEvent.getHtcJobID() != null) {
htcJobID = workerEvent.getHtcJobID();
}
if (workerEvent.getHostName() != null) {
computeHost = workerEvent.getHostName();
}
SimulationMessage workerEventSimulationMessage = workerEvent.getSimulationMessage();
if (workerEventSimulationMessage.getHtcJobId() != null) {
htcJobID = workerEventSimulationMessage.getHtcJobId();
}
SimulationJobStatus newJobStatus = null;
if (workerEvent.isAcceptedEvent()) {
//
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
lastUpdateDate = new Date();
startDate = lastUpdateDate;
endDate = null;
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.DISPATCHED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
} else if (workerEvent.isStartingEvent()) {
// only update database when the job event changes from started to running. The later progress event will not be recorded.
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
lastUpdateDate = new Date();
if (startDate == null) {
startDate = lastUpdateDate;
}
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
} else if (workerEvent.isNewDataEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
if (!oldSchedulerStatus.isRunning() || simQueueID != SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL || hasData == false) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
if (startDate == null) {
startDate = lastUpdateDate;
}
hasData = true;
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
}
} else if (workerEvent.isProgressEvent() || workerEvent.isWorkerAliveEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
if (!oldSchedulerStatus.isRunning() || simQueueID != SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
if (startDate == null) {
startDate = lastUpdateDate;
}
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
} else if (oldSchedulerStatus.isRunning()) {
if (oldSimExeStatus != null) {
// Date latestUpdate = oldSimExeStatus.getLatestUpdateDate();
// if (System.currentTimeMillis() - latestUpdate.getTime() >= MessageConstants.INTERVAL_PING_SERVER_MS * 3 / 5) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
// }
}
}
} else if (workerEvent.isCompletedEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
endDate = new Date();
hasData = true;
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.COMPLETED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
} else if (workerEvent.isFailedEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
endDate = new Date();
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.FAILED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
}
} else if (workerEvent.isWorkerExitErrorEvent()) {
if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
// new queue status
SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
// new exe status
endDate = new Date();
SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
SimulationMessage simulationMessage = SimulationMessage.workerFailure("solver stopped unexpectedly, " + workerEventSimulationMessage.getDisplayMessage());
newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.FAILED, taskID, simulationMessage, newQueueStatus, newExeStatus);
}
}
if (newJobStatus != null) {
if (!newJobStatus.compareEqual(oldSimulationJobStatus) || workerEvent.isProgressEvent() || workerEvent.isNewDataEvent()) {
Double progress = workerEvent.getProgress();
Double timepoint = workerEvent.getTimePoint();
RunningStateInfo runningStateInfo = null;
if (progress != null && timepoint != null) {
runningStateInfo = new RunningStateInfo(progress, timepoint);
}
simulationDatabase.updateSimulationJobStatus(newJobStatus, runningStateInfo);
StatusMessage msgForClient = new StatusMessage(newJobStatus, userName, progress, timepoint);
msgForClient.sendToClient(session);
if (lg.isTraceEnabled())
lg.trace("Send status to client: " + msgForClient);
} else {
simulationDatabase.updateSimulationJobStatus(newJobStatus);
StatusMessage msgForClient = new StatusMessage(newJobStatus, userName, null, null);
msgForClient.sendToClient(session);
if (lg.isTraceEnabled())
lg.trace("Send status to client: " + msgForClient);
}
} else if (workerEvent.isProgressEvent() || workerEvent.isNewDataEvent()) {
Double progress = workerEvent.getProgress();
Double timepoint = workerEvent.getTimePoint();
RunningStateInfo runningStateInfo = null;
if (progress != null && timepoint != null) {
runningStateInfo = new RunningStateInfo(progress, timepoint);
}
simulationDatabase.updateSimulationJobStatus(oldSimulationJobStatus, runningStateInfo);
StatusMessage msgForClient = new StatusMessage(oldSimulationJobStatus, userName, progress, timepoint);
msgForClient.sendToClient(session);
if (lg.isTraceEnabled())
lg.trace("Send status to client: " + msgForClient);
} else {
VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent (currState=" + oldSchedulerStatus.getDescription() + "): " + workerEvent.show());
}
// addStateMachineTransition(new StateMachineTransition(new WorkerStateMachineEvent(taskID, workerEvent), oldSimulationJobStatus, newJobStatus));
}
use of cbit.vcell.server.SimulationJobStatus.SchedulerStatus in project vcell by virtualcell.
the class SimulationStateMachine method onStopRequest.
public synchronized void onStopRequest(User user, SimulationJobStatus simJobStatus, SimulationDatabase simulationDatabase, VCMessageSession session) throws VCMessagingException, DataAccessException, SQLException {
updateSolverProcessTimestamp();
if (!user.equals(simJobStatus.getVCSimulationIdentifier().getOwner())) {
lg.error(user + " is not authorized to stop simulation (key=" + simKey + ")");
StatusMessage message = new StatusMessage(new SimulationJobStatus(VCellServerID.getSystemServerID(), simJobStatus.getVCSimulationIdentifier(), 0, null, SchedulerStatus.FAILED, 0, SimulationMessage.workerFailure("You are not authorized to stop this simulation!"), null, null), user.getName(), null, null);
message.sendToClient(session);
VCMongoMessage.sendInfo("onStopRequest(" + simJobStatus.getVCSimulationIdentifier() + ") ignoring stop simulation request - wrong user)");
return;
}
// stop latest task if active
SchedulerStatus schedulerStatus = simJobStatus.getSchedulerStatus();
int taskID = simJobStatus.getTaskID();
if (schedulerStatus.isActive()) {
SimulationQueueEntryStatus simQueueEntryStatus = simJobStatus.getSimulationQueueEntryStatus();
SimulationExecutionStatus simExeStatus = simJobStatus.getSimulationExecutionStatus();
SimulationJobStatus newJobStatus = new SimulationJobStatus(simJobStatus.getServerID(), simJobStatus.getVCSimulationIdentifier(), jobIndex, simJobStatus.getSubmitDate(), SchedulerStatus.STOPPED, taskID, SimulationMessage.solverStopped("simulation stopped by user"), simQueueEntryStatus, simExeStatus);
//
if (lg.isTraceEnabled())
lg.trace("send " + MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE + " to " + VCellTopic.ServiceControlTopic.getName() + " topic");
VCMessage msg = session.createMessage();
msg.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE);
msg.setLongProperty(MessageConstants.SIMKEY_PROPERTY, Long.parseLong(simKey + ""));
msg.setIntProperty(MessageConstants.JOBINDEX_PROPERTY, jobIndex);
msg.setIntProperty(MessageConstants.TASKID_PROPERTY, taskID);
msg.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, user.getName());
if (simExeStatus.getHtcJobID() != null) {
msg.setStringProperty(MessageConstants.HTCJOBID_PROPERTY, simExeStatus.getHtcJobID().toDatabase());
}
session.sendTopicMessage(VCellTopic.ServiceControlTopic, msg);
simulationDatabase.updateSimulationJobStatus(newJobStatus);
// addStateMachineTransition(new StateMachineTransition(new StopStateMachineEvent(taskID), simJobStatus, newJobStatus));
// update client
StatusMessage message = new StatusMessage(newJobStatus, user.getName(), null, null);
message.sendToClient(session);
}
}
use of cbit.vcell.server.SimulationJobStatus.SchedulerStatus 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;
}
Aggregations