use of cbit.vcell.message.VCMessage in project vcell by virtualcell.
the class VCellServices method dataJobMessage.
public void dataJobMessage(cbit.rmi.event.DataJobEvent event) {
synchronized (dataSession) {
try {
// VCMessageSession dataSession = vcMessagingService.createProducerSession();
VCMessage dataEventMessage = dataSession.createObjectMessage(event);
dataEventMessage.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_DATA_EVENT_VALUE);
dataEventMessage.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, event.getUser().getName());
dataSession.sendTopicMessage(VCellTopic.ClientStatusTopic, dataEventMessage);
// dataSession.close();
} catch (VCMessagingException ex) {
lg.error(ex.getMessage(), ex);
}
}
}
use of cbit.vcell.message.VCMessage in project vcell by virtualcell.
the class VCellServices method exportMessage.
public void exportMessage(cbit.rmi.event.ExportEvent event) {
synchronized (exportSession) {
try {
// VCMessageSession dataSession = vcMessagingService.createProducerSession();
VCMessage exportEventMessage = exportSession.createObjectMessage(event);
exportEventMessage.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_EXPORT_EVENT_VALUE);
exportEventMessage.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, event.getUser().getName());
exportSession.sendTopicMessage(VCellTopic.ClientStatusTopic, exportEventMessage);
// dataSession.close();
} catch (VCMessagingException ex) {
lg.error(ex.getMessage(), ex);
}
}
}
use of cbit.vcell.message.VCMessage in project vcell by virtualcell.
the class HtcSimulationWorker method initQueueConsumer.
// ------------------------------Job Monitor Section END
private void initQueueConsumer() {
startJobMonitor();
this.messageProducer_sim = vcMessagingService_sim.createProducerSession();
this.messageProducer_int = vcMessagingService_int.createProducerSession();
QueueListener queueListener = new QueueListener() {
@Override
public void onQueueMessage(VCMessage vcMessage, VCMessageSession session) throws RollbackException {
SimulationTask simTask = null;
try {
SimulationTaskMessage simTaskMessage = new SimulationTaskMessage(vcMessage);
simTask = simTaskMessage.getSimulationTask();
if (lg.isInfoEnabled()) {
lg.info("onQueueMessage() run simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName());
}
PostProcessingChores rd = choresFor(simTask);
HtcProxy clonedHtcProxy = htcProxy.cloneThreadsafe();
if (lg.isInfoEnabled()) {
lg.info("onQueueMessage() submit job: simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName());
}
HtcJobID pbsId = submit2PBS(simTask, clonedHtcProxy, rd);
addMonitorJob(pbsId.getJobNumber(), simTask, false);
if (lg.isInfoEnabled()) {
lg.info("onQueueMessage() sending 'accepted' message for job: simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName());
}
synchronized (messageProducer_sim) {
WorkerEventMessage.sendAccepted(messageProducer_sim, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), pbsId);
WorkerEventMessage.sendStarting(messageProducer_sim, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), SimulationMessage.MESSAGE_WORKEREVENT_STARTING);
WorkerEventMessage.sendProgress(messageProducer_sim, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), 0, 0, SimulationMessage.MESSAGE_JOB_RUNNING_UNKNOWN);
}
if (lg.isInfoEnabled()) {
lg.info("onQueueMessage() sent 'accepted' message for job: simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName());
}
} catch (Exception e) {
lg.error(e.getMessage(), e);
if (simTask != null) {
try {
lg.error("failed to process simTask request: " + e.getMessage() + " for simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName(), e);
synchronized (messageProducer_sim) {
WorkerEventMessage.sendFailed(messageProducer_sim, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), SimulationMessage.jobFailed(e.getMessage()));
}
lg.error("sent 'failed' message for simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName(), e);
} catch (VCMessagingException e1) {
lg.error(e1.getMessage(), e);
}
} else {
lg.error("failed to process simTask request: " + e.getMessage(), e);
}
}
}
};
int numHtcworkerThreads = Integer.parseInt(PropertyLoader.getProperty(PropertyLoader.htcworkerThreadsProperty, "5"));
this.pooledQueueConsumer_int = new VCPooledQueueConsumer(queueListener, numHtcworkerThreads, messageProducer_int);
this.pooledQueueConsumer_int.initThreadPool();
VCellQueue queue = VCellQueue.SimJobQueue;
VCMessageSelector selector = vcMessagingService_int.createSelector(getJobSelector());
String threadName = "SimJob Queue Consumer";
queueConsumer = new VCQueueConsumer(queue, pooledQueueConsumer_int, selector, threadName, MessageConstants.PREFETCH_LIMIT_SIM_JOB_HTC);
vcMessagingService_int.addMessageConsumer(queueConsumer);
}
use of cbit.vcell.message.VCMessage in project vcell by virtualcell.
the class SimulationControllerImpl method startSimulation.
/**
* This method was created by a SmartGuide.
* @exception java.rmi.RemoteException The exception description.
*/
public void startSimulation(Simulation simulation) throws Exception {
LocalVCMessageListener localVCMessageListener = new LocalVCMessageListener() {
public void onLocalVCMessage(VCDestination destination, VCMessage vcMessage) {
if (destination == VCellTopic.ClientStatusTopic && vcMessage.getObjectContent() instanceof SimulationJobStatus) {
onClientStatusTopic_SimulationJobStatus(vcMessage);
} else if (destination == VCellQueue.SimJobQueue && vcMessage.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY).equals(MessageConstants.MESSAGE_TYPE_SIMULATION_JOB_VALUE)) {
onSimJobQueue_SimulationTask(vcMessage);
} else {
throw new RuntimeException("SimulationControllerImpl.startSimulation().objectMessageListener:: expecting object message with SimulationJobStatus to topic " + VCellTopic.ClientStatusTopic.getName() + ": received \"" + vcMessage.show() + "\"");
}
}
};
LocalVCMessageAdapter vcMessageSession = new LocalVCMessageAdapter(localVCMessageListener);
removeSimulationJobStatusListener(localVCellConnection.getMessageCollector());
addSimulationJobStatusListener(localVCellConnection.getMessageCollector());
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simulation.getKey(), simulation.getVersion().getOwner());
simulationDispatcherEngine.onStartRequest(vcSimID, localVCellConnection.getUserLoginInfo().getUser(), simulation.getScanCount(), simulationDatabase, vcMessageSession, vcMessageSession);
vcMessageSession.deliverAll();
for (int jobIndex = 0; jobIndex < simulation.getScanCount(); jobIndex++) {
SimulationJobStatus latestSimJobStatus = simulationDatabase.getLatestSimulationJobStatus(simulation.getKey(), jobIndex);
simulationDispatcherEngine.onDispatch(simulation, latestSimJobStatus, simulationDatabase, vcMessageSession);
vcMessageSession.deliverAll();
}
}
use of cbit.vcell.message.VCMessage in project vcell by virtualcell.
the class SimulationControllerImpl method stopSimulation.
/**
* This method was created by a SmartGuide.
* @throws JMSException
* @throws AuthenticationException
* @throws DataAccessException
* @throws SQLException
* @throws FileNotFoundException
* @exception java.rmi.RemoteException The exception description.
* @throws VCMessagingException
*/
public void stopSimulation(Simulation simulation) throws FileNotFoundException, SQLException, DataAccessException, AuthenticationException, JMSException, VCMessagingException {
LocalVCMessageListener localVCMessageListener = new LocalVCMessageListener() {
public void onLocalVCMessage(VCDestination destination, VCMessage objectMessage) {
String messageTypeProperty = VCMessagingConstants.MESSAGE_TYPE_PROPERTY;
String stopSimulationValue = MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE;
if (destination == VCellTopic.ClientStatusTopic && objectMessage.getObjectContent() instanceof SimulationJobStatus) {
onClientStatusTopic_SimulationJobStatus(objectMessage);
} else if (destination == VCellTopic.ServiceControlTopic && objectMessage.getStringProperty(messageTypeProperty).equals(stopSimulationValue)) {
lg.error("SimulationControllerImpl.stopSimulation() exercising serviceControl topic ... should be removed");
onServiceControlTopic_StopSimulation(objectMessage);
} else {
throw new RuntimeException("SimulationControllerImpl.startSimulation().objectMessageListener:: expecting message with SimulationJobStatus to topic " + VCellTopic.ClientStatusTopic.getName() + ": received \"" + objectMessage.show() + "\" on destination \"" + destination + "\"");
}
}
};
LocalVCMessageAdapter vcMessageSession = new LocalVCMessageAdapter(localVCMessageListener);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simulation.getKey(), simulation.getVersion().getOwner());
simulationDispatcherEngine.onStopRequest(vcSimID, localVCellConnection.getUserLoginInfo().getUser(), simulationDatabase, vcMessageSession);
vcMessageSession.deliverAll();
}
Aggregations