use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class HtcSimulationWorker method initQueueConsumer.
private void initQueueConsumer() {
this.sharedMessageProducer = vcMessagingService.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);
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 (sharedMessageProducer) {
WorkerEventMessage.sendAccepted(sharedMessageProducer, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), pbsId);
}
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 (sharedMessageProducer) {
WorkerEventMessage.sendFailed(sharedMessageProducer, 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 = new VCPooledQueueConsumer(queueListener, numHtcworkerThreads, sharedMessageProducer);
this.pooledQueueConsumer.initThreadPool();
VCellQueue queue = VCellQueue.SimJobQueue;
VCMessageSelector selector = vcMessagingService.createSelector(getJobSelector());
String threadName = "SimJob Queue Consumer";
queueConsumer = new VCQueueConsumer(queue, pooledQueueConsumer, selector, threadName, MessageConstants.PREFETCH_LIMIT_SIM_JOB_HTC);
vcMessagingService.addMessageConsumer(queueConsumer);
}
use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class SolverPostprocessor method main.
public static void main(java.lang.String[] args) {
if (args.length < NUM_STD_ARGS) {
System.out.println("Usage: " + SolverPostprocessor.class.getName() + " simKey username userKey jobindex taskid solverExitCode [postProcessorCommandFile]");
System.exit(1);
}
Logging.init();
Log4jSessionLog log = new Log4jSessionLog(LOG_NAME);
Logger lg = log.getLogger();
VCMessagingService vcMessagingService = null;
try {
PropertyLoader.loadProperties(POST_PROCESSOR_PROPERTIES);
ResourceUtil.setNativeLibraryDirectory();
NativeLoader.setOsType(OsType.LINUX);
KeyValue simKey = new KeyValue(args[0]);
String userName = args[1];
KeyValue userKey = new KeyValue(args[2]);
int jobIndex = Integer.parseInt(args[3]);
int taskID = Integer.parseInt(args[4]);
int solverExitCode = Integer.parseInt(args[5]);
User owner = new User(userName, userKey);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
String hostName = ManageUtils.getHostName();
VCMongoMessage.serviceStartup(ServiceName.solverPostprocessor, Integer.valueOf(simKey.toString()), args);
//
// JMX registration
//
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new VCellServiceMXBeanImpl(), new ObjectName(VCellServiceMXBean.jmxObjectName));
vcMessagingService = VCellServiceHelper.getInstance().loadService(VCMessagingService.class);
vcMessagingService.setDelegate(new ServerMessagingDelegate());
VCMessageSession session = vcMessagingService.createProducerSession();
WorkerEventMessage workerEventMessage;
if (solverExitCode == 0) {
Exception postProcessingException = null;
if (args.length > NUM_STD_ARGS) {
String fname = args[NUM_STD_ARGS];
if (lg.isDebugEnabled()) {
lg.debug("processing " + fname);
}
postProcessingException = runPostprocessingCommands(fname, lg);
}
if (lg.isDebugEnabled()) {
lg.debug("postProcessingException is " + postProcessingException);
}
if (postProcessingException == null) {
lg.debug("sendWorkerExitNormal");
workerEventMessage = WorkerEventMessage.sendWorkerExitNormal(session, SolverPostprocessor.class.getName(), hostName, vcSimID, jobIndex, taskID, solverExitCode);
} else {
lg.debug("sendWorkerExitError postprocessing");
workerEventMessage = WorkerEventMessage.sendWorkerExitError(session, postProcessingException, hostName, vcSimID, jobIndex, taskID, SimulationMessage.WorkerExited(postProcessingException));
}
} else {
// solverExitCode != 0
lg.debug("sendWorkerExitError solverExitCode");
workerEventMessage = WorkerEventMessage.sendWorkerExitError(session, SolverPostprocessor.class.getName(), hostName, vcSimID, jobIndex, taskID, solverExitCode);
}
lg.debug(workerEventMessage);
VCMongoMessage.sendWorkerEvent(workerEventMessage);
} catch (Throwable e) {
log.exception(e);
} finally {
if (vcMessagingService != null) {
try {
vcMessagingService.close();
} catch (VCMessagingException e) {
e.printStackTrace();
}
}
ApplicationTerminator.beginCountdown(TimeUnit.SECONDS, 10, 0);
VCMongoMessage.shutdown();
System.exit(0);
}
}
use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class SolverPreprocessor method main.
public static void main(java.lang.String[] args) {
if (args.length < 2) {
System.out.print(SolverPreprocessor.class.getName() + " ");
System.out.println(Arrays.toString(args));
System.out.println("Missing arguments: " + SolverPreprocessor.class.getName() + " [simulationTaskFile] [userdir] <parallel dir> ");
System.exit(1);
}
File parallelDirectory = null;
if (args.length >= 3) {
parallelDirectory = new File(args[2]);
if (!parallelDirectory.exists()) {
parallelDirectory.mkdirs();
}
if (!parallelDirectory.isDirectory() || !parallelDirectory.canWrite()) {
throw new IllegalArgumentException(parallelDirectory.getAbsolutePath() + " is not a writeable directory");
}
}
Logging.init();
try {
PropertyLoader.loadProperties();
//
File simulationFile = new File(args[0]);
final SimulationTask simTask = XmlHelper.XMLToSimTask(FileUtils.readFileToString(simulationFile));
if (parallelDirectory != null) {
// simulation task needs to be written to the "parallel directory" (a temporary directory) here (it is local to the cluster).
FileUtils.copyFile(simulationFile, new File(parallelDirectory, simulationFile.getName()));
}
File userDirectory = new File(args[1]);
final String hostName = null;
VCMongoMessage.serviceStartup(ServiceName.solverPreprocessor, Integer.valueOf(simTask.getSimKey().toString()), args);
//
// JMX registration
//
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new VCellServiceMXBeanImpl(), new ObjectName(VCellServiceMXBean.jmxObjectName));
final HTCSolver htcSolver = new HTCSolver(simTask, userDirectory, parallelDirectory) {
public void startSolver() {
try {
super.initialize();
} catch (Exception e) {
e.printStackTrace();
SimulationMessage simMessage = SimulationMessage.jobFailed(e.getMessage());
try {
sendFailureAndExit(this, simTask, hostName, simMessage);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
public void stopSolver() {
}
public double getCurrentTime() {
return 0;
}
public double getProgress() {
return 0;
}
};
SolverListener solverListener = new SolverListener() {
public void solverStopped(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
try {
sendFailureAndExit(htcSolver, simTask, hostName, event.getSimulationMessage());
} catch (Exception e) {
e.printStackTrace();
}
}
public void solverStarting(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
}
public void solverProgress(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
}
public void solverPrinted(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
}
public void solverFinished(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
}
public void solverAborted(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
try {
sendFailureAndExit(htcSolver, simTask, hostName, event.getSimulationMessage());
} catch (VCMessagingException e) {
e.printStackTrace();
}
}
};
htcSolver.addSolverListener(solverListener);
htcSolver.startSolver();
VCMongoMessage.sendInfo("preprocessor done");
exitWithCode(0);
} catch (Throwable e) {
lg.error(e.getMessage(), e);
exitWithCode(-1);
}
}
use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class VCMessagingServiceEmbedded method init.
private void init() throws VCMessagingException {
this.broker = new BrokerService();
this.broker.setPersistent(false);
this.broker.setUseJmx(false);
try {
// TransportConnector connector = new TransportConnector();
// String jmsUrl = PropertyLoader.getRequiredProperty(PropertyLoader.jmsURL);
// connector.setUri(new URI(jmsUrl));
// broker.addConnector(connector);
broker.start();
} catch (Exception e) {
e.printStackTrace();
throw new VCMessagingException(e.getMessage(), e);
}
}
use of cbit.vcell.message.VCMessagingException in project vcell by virtualcell.
the class SimDataServer method exportMessage.
/**
* Insert the method's description here.
* Creation date: (7/29/2003 10:34:11 AM)
* @param event cbit.rmi.event.ExportEvent
*/
public void exportMessage(cbit.rmi.event.ExportEvent event) {
try {
VCMessageSession dataSession = vcMessagingService.createProducerSession();
VCMessage exportEventMessage = dataSession.createObjectMessage(event);
exportEventMessage.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_EXPORT_EVENT_VALUE);
exportEventMessage.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, event.getUser().getName());
dataSession.sendTopicMessage(VCellTopic.ClientStatusTopic, exportEventMessage);
dataSession.close();
} catch (VCMessagingException ex) {
lg.error(ex.getMessage(), ex);
}
}
Aggregations