本文整理汇总了Java中org.ggf.drmaa.Session类的典型用法代码示例。如果您正苦于以下问题:Java Session类的具体用法?Java Session怎么用?Java Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Session类属于org.ggf.drmaa包,在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: execute
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public void execute(ServletContext servletContext, PlanBuilder planBuilder, Run run, boolean async) {
SessionFactory sessionFactory = SessionFactory.getFactory();
Session session = sessionFactory.getSession();
try {
session.init("");
JobTemplate jobTemplate = createJobTemplate(servletContext, session, run);
String jobId = enqueue(session, run, jobTemplate);
if (async) {
String status = waitForStatus(session, jobId);
if (status != null) {
run.addStatus(status, "", true);
}
}
session.deleteJobTemplate(jobTemplate);
session.exit();
}
catch (DrmaaException e) {
throw new RuntimeException(e);
}
}
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:22,代码来源:DRMAAExecutor.java
示例2: createJobTemplate
import org.ggf.drmaa.Session; //导入依赖的package包/类
private static JobTemplate createJobTemplate(ServletContext servletContext, Session session, Run run) throws DrmaaException {
JobTemplate result = session.createJobTemplate();
result.setRemoteCommand("java");
result.setArgs(Arrays.asList(
"-cp",
DRMAAContextParameter.JARS_PATH.getStringValue(servletContext),
DRMAAExecutor.class.getCanonicalName(),
AlvisNLPContextParameter.ROOT_PROCESSING_DIR.getStringValue(servletContext),
AlvisNLPContextParameter.RESOURCE_DIR.getStringValue(servletContext),
AlvisNLPContextParameter.PLAN_DIR.getStringValue(servletContext),
run.getId()
));
String nativeSpecification = DRMAAContextParameter.NATIVE_SPECIFICATION.getStringValue(servletContext);
if (nativeSpecification != null && !nativeSpecification.isEmpty()) {
result.setNativeSpecification(nativeSpecification);
}
return result;
}
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:19,代码来源:DRMAAExecutor.java
示例3: cancel
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public void cancel(Run run) {
String jobId = run.getProperty(DRMAA_JOB_ID_PROPERTY);
if (jobId == null) {
return;
}
SessionFactory sessionFactory = SessionFactory.getFactory();
Session session = sessionFactory.getSession();
try {
session.init("");
session.control(jobId, Session.TERMINATE);
session.exit();
}
catch (DrmaaException e) {
e.printStackTrace();
}
}
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:18,代码来源:DRMAAExecutor.java
示例4: statustoString
import org.ggf.drmaa.Session; //导入依赖的package包/类
public String statustoString(int jobstatus) {
switch (jobstatus) {
case Session.QUEUED_ACTIVE:
return "Job is pending";
case Session.SYSTEM_ON_HOLD:
return "Job is on hold by system.";
case Session.USER_ON_HOLD:
return "Job is on hold by user.";
case Session.USER_SYSTEM_ON_HOLD:
return "Job is on hold by system or user.";
case Session.RUNNING:
return "Job is running";
case Session.SYSTEM_SUSPENDED:
return "Job is suspended by system.";
case Session.USER_SUSPENDED:
return "Job is suspended by user.";
case Session.USER_SYSTEM_SUSPENDED:
return "Job is suspended by system or user.";
case Session.DONE:
return "Job has completed";
case Session.FAILED:
return "Job has failed.";
}
return "Job status is unknown";
}
开发者ID:BiBiServ,项目名称:jobproxy,代码行数:26,代码来源:DRMAA.java
示例5: getCompletedInstances
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public int getCompletedInstances() {
int comp = 0;
try {
for (String job : jobs) {
int status = session.getJobProgramStatus(job);
//if( status == session.FAILED )
//System.err.println( "[" + job + "] failed." );
if (status == Session.DONE || status == Session.FAILED) {
comp += 1;
}
}
} catch (DrmaaException e) {
return 0;
}
return comp;
}
开发者ID:teanalab,项目名称:demidovii,代码行数:21,代码来源:DRMAAStageExecutor.java
示例6: getRunningInstances
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public int getRunningInstances() {
int comp = 0;
try {
for (String job : jobs) {
int status = session.getJobProgramStatus(job);
comp += 1;
//if( status == session.FAILED )
//System.err.println( "[" + job + "] failed." );
if (status == Session.QUEUED_ACTIVE || status == Session.DONE || status == Session.FAILED) {
comp -= 1;
}
}
} catch (DrmaaException e) {
return 0;
}
return comp;
}
开发者ID:teanalab,项目名称:demidovii,代码行数:23,代码来源:DRMAAStageExecutor.java
示例7: getQueuedInstances
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public int getQueuedInstances() {
int queued = 0;
try {
for (String job : jobs) {
int status = session.getJobProgramStatus(job);
if (status == Session.QUEUED_ACTIVE) {
queued += 1;
}
}
} catch (DrmaaException e) {
return 0;
}
return queued;
}
开发者ID:teanalab,项目名称:demidovii,代码行数:18,代码来源:DRMAAStageExecutor.java
示例8: getRunTimes
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public synchronized List<Double> getRunTimes() {
ArrayList<Double> times = new ArrayList<>();
long current;
if (startTimes != null) {
for (String jobid : startTimes.keySet()) {
try {
int status = session.getJobProgramStatus(jobid);
long start = startTimes.get(jobid);
if (status == Session.DONE || status == Session.FAILED) {
if (!stopTimes.containsKey(jobid)) {
stopTimes.put(jobid, System.currentTimeMillis());
}
current = stopTimes.get(jobid);
} else {
current = System.currentTimeMillis();
}
double diff = (current - start + 0.0) / 1000.0;
times.add(diff);
} catch (DrmaaException e) {
logger.log(Level.WARNING, e.getMessage(), e);
}
}
}
return times;
}
开发者ID:teanalab,项目名称:demidovii,代码行数:27,代码来源:DRMAAStageExecutor.java
示例9: runExperiments
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public ImmutableMap<SimulationInputs, Simulation> runExperiments(
Set<SimulationInputs> simulationInputsSet, List<RandomTrial> randomTrials) {
Map<SimulationInputs, List<SimulationDrmaaJobInfo>> jobsByInput = Maps
.newHashMap();
List<String> allJobIds = Lists.newArrayList();
for (SimulationInputs experiment : simulationInputsSet) {
List<SimulationDrmaaJobInfo> jobs = makeJobs(experiment, randomTrials);
jobsByInput.put(experiment, jobs);
allJobIds.addAll(submitJobs(jobs));
}
try {
session.synchronize(allJobIds, Session.TIMEOUT_WAIT_FOREVER, true);
} catch (DrmaaException e) {
throw new RuntimeException(e);
}
System.out.println("All jobs finished");
ImmutableMap.Builder<SimulationInputs, Simulation> ans = ImmutableMap
.builder();
for (Map.Entry<SimulationInputs, List<SimulationDrmaaJobInfo>> entry : jobsByInput
.entrySet()) {
ans.put(entry.getKey(), mergeResults(entry.getValue(), 0));
}
return ans.build();
}
开发者ID:rma350,项目名称:kidneyExchange,代码行数:26,代码来源:DrmaaExperimentRunner.java
示例10: control
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public void control(String jobId, int action) throws DrmaaException {
LOGGER.log(Level.FINEST, "Control");
// TODO implement other actions
switch (action) {
// case Session.SUSPEND: suspendJob(jobId); break;
// case Session.RESUME: resumeJob(jobId); break;
// case Session.HOLD: holdJob(jobId); break;
// case Session.RELEASE: releaseJob(jobId); break;
case Session.TERMINATE:
stopJob(jobId);
break;
default:
throw new InvalidJobException("Drmma Action not implemented yet" + action);
}
}
开发者ID:biouno,项目名称:drmaa-pbs,代码行数:17,代码来源:SessionImpl.java
示例11: attachShutDownHook
import org.ggf.drmaa.Session; //导入依赖的package包/类
/**
* Add a shutdown hook that will close the DRMAA session upon program termination
* This should be added to every main method that will use a Scheduler
* @param drmaaSession
* @throws DrmaaException
*/
public static void attachShutDownHook(final Session drmaaSession) throws DrmaaException {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
logger.info("Ending DRMAA session");
drmaaSession.exit();
} catch (DrmaaException e) {
e.printStackTrace();
logger.warn("DRMAA session might not be closed");
}
}
});
logger.info("Attached shutdown hook to close DRMAA session upon JVM exit.");
}
开发者ID:mgarber,项目名称:scriptureV2,代码行数:22,代码来源:OGSUtils.java
示例12: enqueue
import org.ggf.drmaa.Session; //导入依赖的package包/类
private static String enqueue(Session session, Run run, JobTemplate jobTemplate) throws DrmaaException {
String result = session.runJob(jobTemplate);
run.addStatus(RunStatus.QUEUED, result, false);
run.setProperty(DRMAA_JOB_ID_PROPERTY, result);
run.write();
return result;
}
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:8,代码来源:DRMAAExecutor.java
示例13: waitForStatus
import org.ggf.drmaa.Session; //导入依赖的package包/类
private static String waitForStatus(Session session, String jobId) throws DrmaaException {
JobInfo jobInfo = session.wait(jobId, Session.TIMEOUT_WAIT_FOREVER);
if (jobInfo.wasAborted()) {
return RunStatus.ABORTED;
}
if (jobInfo.hasExited()) {
return null;
}
if (jobInfo.hasSignaled()) {
return RunStatus.SIGNALLED;
}
return RunStatus.DISAPPEARED;
}
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:14,代码来源:DRMAAExecutor.java
示例14: clear
import org.ggf.drmaa.Session; //导入依赖的package包/类
public void clear() throws DrmaaException {
logger.info("terminating all remaining jobs");
session.control(Session.JOB_IDS_SESSION_ALL, Session.TERMINATE);
currentJobs.clear();
failedJobs.clear();
shallStop = false;
}
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:8,代码来源:JobPool.java
示例15: checkJob
import org.ggf.drmaa.Session; //导入依赖的package包/类
private void checkJob(FailAction fail, JobSpecification js) throws DrmaaException {
String id = js.getJobId();
int status = session.getJobProgramStatus(id);
if (status == Session.DONE) {
JobInfo info = session.wait(id, Session.TIMEOUT_NO_WAIT);
if (info.wasAborted()) {
logger.warning(js.getJobMessage("was aborted"));
fail(fail, js);
return;
}
if (info.hasSignaled()) {
logger.warning(js.getJobMessage("signalled " + info.getTerminatingSignal()));
fail(fail, js);
return;
}
if (info.getExitStatus() != 0) {
logger.warning(js.getJobMessage("exited with status " + info.getExitStatus()));
fail(fail, js);
return;
}
logger.info(js.getJobMessage("is done"));
currentJobs.remove(id);
return;
}
if (status == Session.FAILED) {
logger.warning(js.getJobMessage("failed somehow"));
fail(fail, js);
}
}
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:30,代码来源:JobPool.java
示例16: DrmaaSimpleModuleExecutor
import org.ggf.drmaa.Session; //导入依赖的package包/类
private DrmaaSimpleModuleExecutor(Session drmaaSession, Path jobIOBasePath, CommandProvider commandProvider,
NativeSpecificationProvider nativeSpecificationProvider, InstanceProvider instanceProvider,
long waitTimeoutSeconds, long errorWaitMilliseconds, Executor shortTasksExecutor,
ScheduledExecutorService longLivedExecutorService) {
this.drmaaSession = drmaaSession;
this.jobIOBasePath = jobIOBasePath;
this.commandProvider = commandProvider;
this.nativeSpecificationProvider = nativeSpecificationProvider;
this.instanceProvider = instanceProvider;
this.waitTimeoutSeconds = waitTimeoutSeconds;
this.errorWaitMilliseconds = errorWaitMilliseconds;
this.shortTasksExecutor = shortTasksExecutor;
this.longLivedExecutorService = longLivedExecutorService;
}
开发者ID:cloudkeeper-project,项目名称:cloudkeeper,代码行数:15,代码来源:DrmaaSimpleModuleExecutor.java
示例17: delTask
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public void delTask(String id) throws FrameworkException {
taskhash.remove(id);
try {
session.control(id, Session.TERMINATE);
} catch (DrmaaException e) {
throw new FrameworkException("DRMAA exception occurred while call 'delTask'", e);
}
}
开发者ID:BiBiServ,项目名称:jobproxy,代码行数:10,代码来源:DRMAA.java
示例18: runExperiment
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public Simulation runExperiment(SimulationInputs simulationInputs,
List<RandomTrial> randomTrials) {
List<SimulationDrmaaJobInfo> jobs = makeJobs(simulationInputs, randomTrials);
List<String> jobIds = submitJobs(jobs);
try {
session.synchronize(jobIds, Session.TIMEOUT_WAIT_FOREVER, true);
} catch (DrmaaException e) {
throw new RuntimeException(e);
}
System.out.println("All jobs finished");
return mergeResults(jobs, 0);
}
开发者ID:rma350,项目名称:kidneyExchange,代码行数:14,代码来源:DrmaaExperimentRunner.java
示例19: runSimulationJob
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public Simulation runSimulationJob(SimulationJob simulationJob) {
List<SimulationDrmaaJobInfo> jobs = splitInputJob(simulationJob);
List<String> jobIds = submitJobs(jobs);
try {
session.synchronize(jobIds, Session.TIMEOUT_WAIT_FOREVER, true);
} catch (DrmaaException e) {
throw new RuntimeException(e);
}
System.out.println("All jobs finished");
return mergeResults(jobs, simulationJob.getIndexWithinAllTrials());
}
开发者ID:rma350,项目名称:kidneyExchange,代码行数:13,代码来源:DrmaaExperimentRunner.java
示例20: runSimulationJobs
import org.ggf.drmaa.Session; //导入依赖的package包/类
@Override
public ImmutableMap<SimulationJob, Simulation> runSimulationJobs(
Set<SimulationJob> simulationJobs) {
Map<SimulationJob, List<SimulationDrmaaJobInfo>> jobsByInput = Maps
.newHashMap();
List<String> allJobIds = Lists.newArrayList();
for (SimulationJob experiment : simulationJobs) {
List<SimulationDrmaaJobInfo> jobs = splitInputJob(experiment);
jobsByInput.put(experiment, jobs);
allJobIds.addAll(submitJobs(jobs));
}
try {
session.synchronize(allJobIds, Session.TIMEOUT_WAIT_FOREVER, true);
} catch (DrmaaException e) {
throw new RuntimeException(e);
}
System.out.println("All jobs finished");
ImmutableMap.Builder<SimulationJob, Simulation> ans = ImmutableMap
.builder();
for (Map.Entry<SimulationJob, List<SimulationDrmaaJobInfo>> entry : jobsByInput
.entrySet()) {
ans.put(
entry.getKey(),
mergeResults(entry.getValue(), entry.getKey()
.getIndexWithinAllTrials()));
}
return ans.build();
}
开发者ID:rma350,项目名称:kidneyExchange,代码行数:30,代码来源:DrmaaExperimentRunner.java
注:本文中的org.ggf.drmaa.Session类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论