本文整理汇总了Java中org.globus.gram.GramJob类的典型用法代码示例。如果您正苦于以下问题:Java GramJob类的具体用法?Java GramJob怎么用?Java GramJob使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GramJob类属于org.globus.gram包,在下文中一共展示了GramJob类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testActiveJobs
import org.globus.gram.GramJob; //导入依赖的package包/类
public void testActiveJobs() throws Exception {
GramJob job1 = new GramJob(util.get("job.long"));
job1.request(util.get("job.long.contact"));
GramJob job2 = new GramJob(util.get("job.long"));
job2.request(util.get("job.long.contact"));
assertEquals(2, Gram.getActiveJobs());
int i = 0;
while ( Gram.getActiveJobs() != 0 ) {
Thread.sleep(2000);
i++;
if (i == 40) {
fail("getActiveJob() did not reported 0 jobs");
}
}
}
示例2: testBadExecutable
import org.globus.gram.GramJob; //导入依赖的package包/类
public void testBadExecutable() throws Exception {
GramJob job = new GramJob("&(executable=/bin/thisexecdoesnotexist)");
FailedStatusListener listener = new FailedStatusListener();
job.addListener(listener);
try {
job.request(util.get("job.long.contact"));
} catch (GramException e) {
if (e.getErrorCode() != GramException.EXECUTABLE_NOT_FOUND) {
e.printStackTrace();
fail("Unexpected error returned: " + e.getMessage());
}
logger.debug("Error returned on request()");
return;
}
if (!listener.waitFor(TIMEOUT)) {
fail("Did not get FAILED notification");
}
if (job.getError() != GramException.EXECUTABLE_NOT_FOUND) {
fail("Unexpected error returned: " + job.getError());
}
}
示例3: testTwoPhaseExtend
import org.globus.gram.GramJob; //导入依赖的package包/类
public void testTwoPhaseExtend() throws Exception {
GramJob job = new GramJob(util.get("job.long") + "(twoPhase=yes)");
try {
job.request(util.get("job.long.contact"));
} catch(WaitingForCommitException e) {
logger.debug("Two phase commit: sending COMMIT_EXTEND signal");
job.signal(GramJob.SIGNAL_COMMIT_EXTEND, "30");
}
logger.debug("job submited: " + job.getIDAsString());
Thread.sleep(75000);
if (job.getStatus() == job.STATUS_FAILED) {
fail("Timeout expired!");
}
}
示例4: statusChanged
import org.globus.gram.GramJob; //导入依赖的package包/类
public void statusChanged(GramJob job) {
String status = job.getStatusAsString();
logger.info("status changed " + status);
try {
if (job.getStatus() == GRAMConstants.STATUS_ACTIVE) {
// notify waiting thread when job ready
m_jobOutput = "Job sent. url=" + job.getIDAsString();
logger.info(m_jobOutput);
// if notify enabled return URL as output
// synchronized (this) {
// notify();
// }
}
} catch (Exception ex) {
logger.error("statusChanged Error:" + ex.getMessage());
ex.printStackTrace();
}
}
示例5: cancel
import org.globus.gram.GramJob; //导入依赖的package包/类
public void cancel(String message) throws InvalidSecurityContextException,
TaskSubmissionException {
try {
if (getTask().getStatus().getStatusCode() == Status.UNSUBMITTED) {
getTask().setStatus(new StatusImpl(Status.CANCELED, message, null));
return;
}
String jobCount = (String) getTask().getAttribute("jobCount");
if (jobCount.equalsIgnoreCase("multiple")) {
Iterator iterator = this.jobList.iterator();
while (iterator.hasNext()) {
GramJob job = (GramJob) iterator.next();
job.cancel();
}
} else {
this.gramJob.cancel();
}
getTask().setStatus(new StatusImpl(Status.CANCELED, message, null));
} catch (GramException ge) {
cleanup();
throw new TaskSubmissionException("Cannot cancel job", ge);
} catch (GSSException gsse) {
cleanup();
throw new InvalidSecurityContextException("Invalid GSSCredentials",
gsse);
}
}
示例6: statusChanged
import org.globus.gram.GramJob; //导入依赖的package包/类
public void statusChanged(GramJob job) {
int status = job.getStatus();
switch (status) {
case 2:
getTask().setStatus(Status.ACTIVE);
break;
case 4:
int errorCode = job.getError();
Exception e = new Exception("Error code: " + errorCode);
failTask(null, e);
break;
case 8:
getTask().setStatus(Status.COMPLETED);
break;
case 16:
getTask().setStatus(Status.SUSPENDED);
break;
case 32:
getTask().setStatus(Status.UNSUBMITTED);
break;
default:
break;
}
if ((status == 4) || (status == 8)) {
cleanup();
}
}
示例7: statusChanged
import org.globus.gram.GramJob; //导入依赖的package包/类
public void statusChanged(GramJob job) {
if (job.getStatus() == GramJob.STATUS_DONE) {
done();
} else if (job.getStatus() == GramJob.STATUS_FAILED) {
this.failed = true;
Status status = new StatusImpl();
status.setPrevStatusCode(this.task.getStatus().getStatusCode());
status.setStatusCode(Status.FAILED);
status.setMessage("ErrorCode: " + job.getError());
this.task.setStatus(status);
} else if (job.getStatus() == GramJob.STATUS_ACTIVE && !this.failed) {
this.task.setStatus(Status.ACTIVE);
}
}
示例8: submitMultipleJobs
import org.globus.gram.GramJob; //导入依赖的package包/类
private void submitMultipleJobs(RslNode rslTree, JobSpecification spec)
throws IllegalSpecException, InvalidSecurityContextException,
InvalidServiceContactException, TaskSubmissionException {
MultiJobListener listener = new MultiJobListener(getTask());
this.jobList = new ArrayList<GramJob>();
Iterator<RslNode> iter = rslTree.getSpecifications().iterator();
RslNode node;
NameOpValue nv;
String rmc;
String rsl;
while (iter.hasNext()) {
node = iter.next();
rsl = node.toRSL(true);
nv = node.getParam("resourceManagerContact");
if (nv == null) {
throw new IllegalSpecException(
"Error: No resource manager contact for job.");
}
else {
Object obj = nv.getFirstValue();
if (obj instanceof Value) {
rmc = ((Value) obj).getValue();
multiRunSub(rsl, rmc, listener);
}
getTask().setStatus(Status.SUBMITTED);
}
}
}
示例9: multiRunSub
import org.globus.gram.GramJob; //导入依赖的package包/类
private void multiRunSub(String rsl, String rmc, MultiJobListener listener)
throws InvalidSecurityContextException, TaskSubmissionException {
GramJob job = new GramJob(rsl);
job.addListener(listener);
try {
job.setCredentials(this.credential);
}
catch (IllegalArgumentException iae) {
throw new InvalidSecurityContextException(
"Cannot set the SecurityContext twice", iae);
}
boolean limitedDeleg = isLimitedDelegation(this.securityContext);
try {
job.request(rmc, false, limitedDeleg);
if (logger.isDebugEnabled()) {
logger.debug("Submitted job with Globus ID: "
+ job.getIDAsString());
}
}
catch (GramException ge) {
listener.failed(true);
throw new TaskSubmissionException("Cannot submit job", ge);
}
catch (GSSException gsse) {
listener.failed(true);
throw new InvalidSecurityContextException("Invalid GSSCredentials",
gsse);
}
listener.runningJob();
}
示例10: cancel
import org.globus.gram.GramJob; //导入依赖的package包/类
public void cancel(String message) throws InvalidSecurityContextException,
TaskSubmissionException {
try {
if (getTask().getStatus().getStatusCode() == Status.UNSUBMITTED) {
getTask().setStatus(
new StatusImpl(Status.CANCELED, message, null));
return;
}
String jobCount = (String) getTask().getAttribute("jobCount");
if (jobCount.equalsIgnoreCase("multiple")) {
for (GramJob job : jobList) {
job.cancel();
}
}
else {
this.gramJob.cancel();
}
getTask().setStatus(new StatusImpl(Status.CANCELED, message, null));
}
catch (GramException ge) {
cleanup();
throw new TaskSubmissionException("Cannot cancel job", ge);
}
catch (GSSException gsse) {
cleanup();
throw new InvalidSecurityContextException("Invalid GSSCredentials",
gsse);
}
}
示例11: statusChanged
import org.globus.gram.GramJob; //导入依赖的package包/类
public void statusChanged(GramJob job) {
int status = job.getStatus();
switch (status) {
case GRAMConstants.STATUS_ACTIVE:
getTask().setStatus(Status.ACTIVE);
break;
case GRAMConstants.STATUS_FAILED:
int errorCode = job.getError();
Exception e = new GramException(errorCode);
failTask(null, e);
break;
case GRAMConstants.STATUS_DONE:
getTask().setStatus(Status.COMPLETED);
break;
case GRAMConstants.STATUS_SUSPENDED:
getTask().setStatus(Status.SUSPENDED);
break;
case GRAMConstants.STATUS_UNSUBMITTED:
getTask().setStatus(Status.UNSUBMITTED);
break;
default:
break;
}
if ((status == GRAMConstants.STATUS_FAILED)
|| (status == GRAMConstants.STATUS_DONE)) {
cleanup();
}
}
示例12: statusChanged
import org.globus.gram.GramJob; //导入依赖的package包/类
public synchronized void statusChanged(GramJob job) {
if (!called) {
called = true;
status = job.getStatus();
error = job.getError();
notify();
}
}
示例13: testBadParameter
import org.globus.gram.GramJob; //导入依赖的package包/类
public void testBadParameter() throws Exception {
GramJob job = new GramJob("&(argument=12)");
try {
job.request(util.get("job.long.contact"));
} catch (GramException e) {
if (e.getErrorCode() != GramException.PARAMETER_NOT_SUPPORTED) {
e.printStackTrace();
fail("Unexpected error returned: " + e.getMessage());
}
}
}
示例14: statusChanged
import org.globus.gram.GramJob; //导入依赖的package包/类
public synchronized void statusChanged(GramJob job) {
int st = job.getStatus();
logger.debug("Gass job status: " + st);
if (status == -1 && isStartState(st)) {
status = st;
error = job.getError();
notify();
}
}
示例15: submitSingleJob
import org.globus.gram.GramJob; //导入依赖的package包/类
private void submitSingleJob(RslNode rsl, JobSpecification spec,
String server) throws IllegalSpecException,
InvalidSecurityContextException, InvalidServiceContactException,
TaskSubmissionException {
this.gramJob = new GramJob(rsl.toString());
try {
this.gramJob.setCredentials(this.credential);
}
catch (IllegalArgumentException iae) {
throw new InvalidSecurityContextException(
"Cannot set the SecurityContext twice", iae);
}
if (!spec.isBatchJob()) {
CallbackHandlerManager.increaseUsageCount(this.credential);
this.gramJob.addListener(this);
}
if (logger.isDebugEnabled()) {
logger.debug("Execution server: " + server);
}
boolean limitedDeleg = isLimitedDelegation(this.securityContext);
if (spec.getDelegation() == Delegation.FULL_DELEGATION) {
limitedDeleg = false;
}
try {
// check if the task has not been canceled after it was
// submitted for execution
this.gramJob.request(server, spec.isBatchJob(), limitedDeleg);
if (logger.isDebugEnabled()) {
logger.debug("Submitted job with Globus ID: "
+ this.gramJob.getIDAsString());
}
getTask().setStatus(Status.SUBMITTED);
if (spec.isBatchJob()) {
getTask().setStatus(Status.COMPLETED);
}
}
catch (GramException ge) {
cleanup();
throw new TaskSubmissionException("Cannot submit job", ge);
}
catch (GSSException gsse) {
cleanup();
throw new InvalidSecurityContextException("Invalid GSSCredentials",
gsse);
}
}