本文整理汇总了Java中org.objectweb.proactive.core.ProActiveTimeoutException类的典型用法代码示例。如果您正苦于以下问题:Java ProActiveTimeoutException类的具体用法?Java ProActiveTimeoutException怎么用?Java ProActiveTimeoutException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProActiveTimeoutException类属于org.objectweb.proactive.core包,在下文中一共展示了ProActiveTimeoutException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitWithMonitor
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
private void waitWithMonitor(EventMonitor monitor, long timeout) throws ProActiveTimeoutException {
TimeoutAccounter counter = TimeoutAccounter.getAccounter(timeout);
synchronized (monitor) {
monitor.setTimeouted(false);
while (!counter.isTimeoutElapsed()) {
if (monitor.eventOccured())
return;
try {
//System.out.println("I AM WAITING FOR EVENT : " + monitor.getWaitedEvent() + " during " +
// counter.getRemainingTimeout());
monitor.wait(counter.getRemainingTimeout());
} catch (InterruptedException e) {
//spurious wake-up, nothing to do
e.printStackTrace();
}
}
monitor.setTimeouted(true);
}
throw new ProActiveTimeoutException("timeout elapsed");
}
示例2: waitWithMonitor
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
protected void waitWithMonitor(EventMonitor monitor, long timeout) throws ProActiveTimeoutException {
TimeoutAccounter counter = TimeoutAccounter.getAccounter(timeout);
synchronized (monitor) {
monitor.setTimeouted(false);
while (!counter.isTimeoutElapsed()) {
if (monitor.eventOccured())
return;
try {
functionaltests.utils.SchedulerTHelper.log("waiting for event monitor " + monitor);
monitor.wait(counter.getRemainingTimeout());
} catch (InterruptedException e) {
// spurious wake-up, nothing to do
e.printStackTrace();
}
}
if (monitor.eventOccured())
return;
monitor.setTimeouted(true);
}
throw new ProActiveTimeoutException("timeout elapsed");
}
示例3: waitWithMonitor
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
private void waitWithMonitor(RMEventMonitor monitor, long timeout) throws ProActiveTimeoutException {
TimeoutAccounter counter = TimeoutAccounter.getAccounter(timeout);
synchronized (monitor) {
monitor.setTimeouted(false);
while (!counter.isTimeoutElapsed()) {
if (monitor.eventOccured())
return;
try {
monitor.wait(counter.getRemainingTimeout());
} catch (InterruptedException e) {
//spurious wake-up, nothing to do
e.printStackTrace();
}
}
monitor.setTimeouted(true);
}
throw new ProActiveTimeoutException("timeout elapsed");
}
示例4: getFutureValue
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
/**
* Return the object contains by the future (ie its target). If parameter is not a future, it is
* returned. A wait-by-necessity occurs if future is not available. This method is recursive,
* i.e. if result of future is a future too, <CODE>getFutureValue</CODE> is called again on
* this result, and so on.
* @param timeout to wait in ms
* @throws ProActiveException if the timeout expire
*/
public static <T> T getFutureValue(T future, long timeout) throws ProActiveTimeoutException {
TimeoutAccounter ta = TimeoutAccounter.getAccounter(timeout);
while (true) {
// If the object is not reified, it cannot be a future
if ((MOP.isReifiedObject(future)) == false) {
return future;
} else {
org.objectweb.proactive.core.mop.Proxy theProxy = ((StubObject) future).getProxy();
// If it is reified but its proxy is not of type future, we cannot wait
if (!(theProxy instanceof Future)) {
return future;
} else {
future = (T) ((Future) theProxy).getResult(ta.getRemainingTimeout());
}
}
}
}
示例5: waitFor
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
/**
* Blocks the calling thread until the object <code>future</code> is available or until the
* timeout expires. <code>future</code> must be the result object of an asynchronous call.
* Usually the the wait by necessity model take care of blocking the caller thread asking for a
* result not yet available. This method allows to block before the result is first used.
*
* @param future
* object to wait for
* @param timeout
* to wait in ms
* @throws ProActiveException
* if the timeout expire
*/
public static void waitFor(Object future, long timeout) throws ProActiveTimeoutException {
// If the object is not reified, it cannot be a future
if ((MOP.isReifiedObject(future)) == false) {
return;
} else {
org.objectweb.proactive.core.mop.Proxy theProxy = ((StubObject) future).getProxy();
// If it is reified but its proxy is not of type future, we cannot wait
if (!(theProxy instanceof Future)) {
return;
} else {
((Future) theProxy).waitFor(timeout);
}
}
}
示例6: waitReady
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
public static void waitReady(GCMVirtualNode gcmVn) throws Exception {
boolean waiting = true;
while (waiting) {
try {
gcmVn.waitReady(TIMEOUT);
waiting = false;
} catch (ProActiveTimeoutException pate) {
logger.warn("The virtual node: " + gcmVn.getName() +
" is still not ready after having waited " + (TIMEOUT / 1000) +
" seconds. Awaiting further " + (TIMEOUT / 1000) + " seconds.");
}
}
if (gcmVn.getNbCurrentNodes() == 0) {
throw new InstantiationException("Cannot create component on virtual node " + gcmVn.getName() +
" as no node is associated with this virtual node");
}
}
示例7: action
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
@Before
public void action() throws Exception {
try {
CentralPAPropertyRepository.PA_FUTURE_SYNCHREQUEST_TIMEOUT.setValue(2);
activeA = PAActiveObject.newActive(SynchrounousMethodCallWithTimeout.class, new Object[0]);
System.out
.println("calling a synchronous method that waits for 10 sec while timeout is set to 2 sec");
activeA.sleepFor10Sec();
} catch (ProActiveTimeoutException e) {
System.out.println("got the exception " + e.getMessage() + ", this is good");
exceptionCaught = true;
return;
}
System.out.println("missed the exception, this is *no* good");
}
示例8: waitReady
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
public void waitReady(long timeout) throws ProActiveTimeoutException {
TimeoutAccounter time = TimeoutAccounter.getAccounter(timeout);
for (GCMVirtualNode vn : virtualNodes.values()) {
try {
vn.waitReady(time.getRemainingTimeout());
} catch (ProActiveTimeoutException e) {
if (time.isTimeoutElapsed()) { // should always be true
StringBuilder sb = new StringBuilder();
sb.append("Timeout reached while waiting for all virtual nodes to be ready.");
for (GCMVirtualNode v : virtualNodes.values()) {
sb.append(" ");
sb.append(v.getName());
sb.append(": ");
sb.append(v.isReady());
throw new ProActiveTimeoutException(sb.toString());
}
}
}
}
}
示例9: waitForEventJobSubmitted
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
/**
* Wait for a job submission event for a specific job id.
* If event has been already thrown by scheduler, returns immediately
* with job object associated to event, otherwise wait for event reception.
*
* @param id job identifier, for which submission event is waited for.
* @return JobState object corresponding to job submitted event.
*/
public JobState waitForEventJobSubmitted(JobId id) {
try {
return waitForEventJobSubmitted(id, 0);
} catch (ProActiveTimeoutException e) {
//unreachable block, 0 means infinite, no timeout, no timeoutExcpetion
//log sthing ?
return null;
}
}
示例10: waitForEventJobRunning
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
/**
* Wait for a specific job passing from pending state to running state.
* If corresponding event has been already thrown by scheduler, returns immediately
* with jobInfo object associated to event, otherwise wait for reception
* of the corresponding event.
*
* @param id job identifier, for which event is waited for.
* @return JobInfo event's associated object.
*/
public JobInfo waitForEventJobRunning(JobId id) {
try {
return waitForEventJobRunning(id, 0);
} catch (ProActiveTimeoutException e) {
//unreachable block, 0 means infinite, no timeout
//log sthing ?
return null;
}
}
示例11: waitForEventJobFinished
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
public JobInfo waitForEventJobFinished(Scheduler userInterface, JobId id) throws Exception {
try {
return waitForJobEvent(userInterface, id, 0, JobStatus.FINISHED, SchedulerEvent.JOB_RUNNING_TO_FINISHED);
} catch (ProActiveTimeoutException e) {
//unreachable block, 0 means infinite, no timeout
//log sthing ?
return null;
}
}
示例12: waitForEventJobRemoved
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
/**
* Wait for a job removed from Scheduler's database.
* If corresponding event has been already thrown by scheduler, returns immediately
* with JobInfo object associated to event, otherwise wait for event reception.
*
* @param id job identifier, for which event is waited for.
* @return JobInfo event's associated object.
*/
public JobInfo waitForEventJobRemoved(JobId id) {
try {
return waitForEventJobRemoved(id, 0);
} catch (ProActiveTimeoutException e) {
//unreachable block, 0 means infinite, no timeout
//log sthing ?
return null;
}
}
示例13: waitForEventSchedulerState
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
/**
* Wait for an event regarding Scheduler state : started, resumed, stopped...
* If a corresponding event has been already thrown by scheduler, returns immediately,
* otherwise wait for reception of the corresponding event.
* @param event awaited event.
*/
public void waitForEventSchedulerState(SchedulerEvent event) {
try {
waitForEventSchedulerState(event, 0);
} catch (ProActiveTimeoutException e) {
//unreachable block, 0 means infinite, no timeout
//log sthing ?
}
}
示例14: waitForFinishedJob
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
/**
* Wait for a finished job. If Job is already finished, methods return.
* This method doesn't wait strictly 'job finished event', it looks
* first if the job is already finished, if yes, returns immediately.
* Otherwise method performs a wait for job finished event.
*
* @param id JobId representing the job awaited to be finished.
*/
public void waitForFinishedJob(JobId id) {
try {
waitForFinishedJob(id, 0);
} catch (ProActiveTimeoutException e) {
//unreachable block, 0 means infinite, no timeout
//log sthing ?
}
}
示例15: waitForEventJobSubmitted
import org.objectweb.proactive.core.ProActiveTimeoutException; //导入依赖的package包/类
/**
* Wait for event : submission of Job to Scheduler.
* @param id JobId to wait for submission
* @param timeout max waiting time in milliseconds.
* @return A Job representing submitted job
* @throws ProActiveTimeoutException if timeout has expired
*/
public JobState waitForEventJobSubmitted(JobId id, long timeout) throws ProActiveTimeoutException {
JobEventMonitor monitor = null;
synchronized (this) {
monitor = removeJobEvent(id, SchedulerEvent.JOB_SUBMITTED);
if (monitor != null) {
//event occurred, remove it and return associated Job object
return monitor.getJobState();
}
monitor = (JobEventMonitor) getMonitor(new JobEventMonitor(SchedulerEvent.JOB_SUBMITTED, id));
}
waitWithMonitor(monitor, timeout);
return monitor.getJobState();
}