Example usage for java.util.concurrent TimeoutException TimeoutException

List of usage examples for java.util.concurrent TimeoutException TimeoutException

Introduction

In this page you can find the example usage for java.util.concurrent TimeoutException TimeoutException.

Prototype

public TimeoutException() 

Source Link

Document

Constructs a TimeoutException with no specified detail message.

Usage

From source file:org.apache.zookeeper.server.quorum.QuorumPeerMainTest.java

private QuorumPeer waitForQuorumPeer(MainThread mainThread, int timeout) throws TimeoutException {
    long start = Time.currentElapsedTime();
    while (true) {
        QuorumPeer quorumPeer = mainThread.isAlive() ? mainThread.getQuorumPeer() : null;
        if (quorumPeer != null) {
            return quorumPeer;
        }/*from  ww w  . j  av  a  2 s .  c  o  m*/

        if (Time.currentElapsedTime() > start + timeout) {
            LOG.error("Timed out while waiting for QuorumPeer");
            throw new TimeoutException();
        }

        try {
            Thread.sleep(250);
        } catch (InterruptedException e) {
            // ignore
        }
    }
}