Search in sources :

Example 1 with TimeoutAccounter

use of org.objectweb.proactive.utils.TimeoutAccounter in project scheduling by ow2-proactive.

the class TestSmartProxy method waitWithMonitor.

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");
}
Also used : ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) TimeoutAccounter(org.objectweb.proactive.utils.TimeoutAccounter)

Example 2 with TimeoutAccounter

use of org.objectweb.proactive.utils.TimeoutAccounter in project scheduling by ow2-proactive.

the class RMMonitorsHandler method waitWithMonitor.

// ---------------------------------------------------------------//
// private methods
// these method MUST NOT be called from a synchronized(this) block
// ---------------------------------------------------------------//
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");
}
Also used : ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) TimeoutAccounter(org.objectweb.proactive.utils.TimeoutAccounter)

Example 3 with TimeoutAccounter

use of org.objectweb.proactive.utils.TimeoutAccounter in project scheduling by ow2-proactive.

the class SchedulerMonitorsHandler method waitWithMonitor.

// ---------------------------------------------------------------//
// private methods
// these methods MUST NOT be called from a synchronized(this) block
// ---------------------------------------------------------------//
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");
}
Also used : ProActiveTimeoutException(org.objectweb.proactive.core.ProActiveTimeoutException) TimeoutAccounter(org.objectweb.proactive.utils.TimeoutAccounter)

Aggregations

ProActiveTimeoutException (org.objectweb.proactive.core.ProActiveTimeoutException)3 TimeoutAccounter (org.objectweb.proactive.utils.TimeoutAccounter)3