Package java.util.concurrent

Examples of java.util.concurrent.TimeoutException


                    String errorMessage = String.format("Timeout while checking out resource (%s). Configured time (%d) ns NonBlocking time (%d) ns Blocking time (%d) ns ",
                                                        key,
                                                        resourcePoolConfig.getTimeout(TimeUnit.NANOSECONDS),
                                                        nonBlockingElapsedNs,
                                                        blockingElapsedNs);
                    throw new TimeoutException(errorMessage);
                }
            }

            if(!objectFactory.validate(key, resource))
                throw new ExcessiveInvalidResourcesException(1);
View Full Code Here


            }

            for (long i = 0; i < Long.MAX_VALUE; i++) {
                // First check for timeout
                if (hasTimedOut.get()) {
                    throw new TimeoutException(
                                               String.format("Could not find order and matching for key set in alloted time with specified parameters (m=%d;k=%d;q=%d)",
                                                             m, k, q));
                }

                hasher = new BloomierHasher<K>(hashSeed, m, k, q);
View Full Code Here

          return null;
        } else {
          throw new ExecutionException(exception);
        }
      } else {
        throw new TimeoutException();
      }
    }
  }
View Full Code Here

   public SyncResponse blockUntilAcquired(long timeout, TimeUnit timeUnit) throws TimeoutException {
      int initState = flushWaitGateCount.get();
      while (true) {
         try {
            if (!flushWaitGate.await(timeout, timeUnit))
               throw new TimeoutException("Timed out waiting for a cluster-wide sync to be acquired. (timeout = " + Util.prettyPrintTime(timeout) + ")");

            return initState == flushWaitGateCount.get() ? SyncResponse.STATE_PREEXISTED : SyncResponse.STATE_ACHIEVED;
         } catch (InterruptedException ie) {
            Thread.currentThread().interrupt();
         }
View Full Code Here

   public SyncResponse blockUntilReleased(long timeout, TimeUnit timeUnit) throws TimeoutException {
      int initState = flushBlockGateCount.get();
      while (true) {
         try {
            if (!flushBlockGate.await(timeout, timeUnit))
               throw new TimeoutException("Timed out waiting for a cluster-wide sync to be released. (timeout = " + Util.prettyPrintTime(timeout) + ")");

            return initState == flushWaitGateCount.get() ? SyncResponse.STATE_PREEXISTED : SyncResponse.STATE_ACHIEVED;
         } catch (InterruptedException ie) {
            Thread.currentThread().interrupt();
         }
View Full Code Here

   public void acquireProcessingLock(boolean exclusive, long timeout, TimeUnit timeUnit) throws TimeoutException {
      while (true) {
         try {
            Lock lock = exclusive ? processingLock.writeLock() : processingLock.readLock();
            if (!lock.tryLock(timeout, timeUnit))
               throw new TimeoutException("Could not obtain " + (exclusive ? "exclusive" : "shared") + " processing lock");
            break;
         } catch (InterruptedException ie) {
            Thread.currentThread().interrupt();
         }
      }
View Full Code Here

      if (value != null) {
        return value;
      }

      if (!pollInterval.doSafeSleep()) {
        throw new TimeoutException("Interrupted during sleep");
      }
    } while (!timeout.hasTimedOut(start));

    throw new TimeoutException();
  }
View Full Code Here

     */
    public V retrieve(long timeout, TimeUnit unit)
            throws T {
        final V value = tryRetrieve(timeout, unit);
        if (value == null)
            throw chainer.chain(new TimeoutException("Timeout expired"));
        else
            return value;
    }
View Full Code Here

    long timeoutAt = System.currentTimeMillis() + unit.toMillis(duration);

    // TODO: Timeout?
    while (operation.getStatus().equals("RUNNING")) {
      if (timeoutAt < System.currentTimeMillis()) {
        throw new TimeoutException("Timeout while waiting for operation to complete");
      }
      log.debug("Polling for operation completion: " + operation);
      try {
        operation = compute.operations().get(projectId, operation.getName()).execute();
      } catch (IOException e) {
View Full Code Here

        }
    }

    private PooledConnection waitForConnection(long timeout, TimeUnit unit) throws ConnectionException, TimeoutException {
        if (timeout == 0)
            throw new TimeoutException();

        long start = System.nanoTime();
        long remaining = timeout;
        do {
            try {
                awaitAvailableConnection(remaining, unit);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                // If we're interrupted fine, check if there is a connection available but stop waiting otherwise
                timeout = 0; // this will make us stop the loop if we don't get a connection right away
            }

            if (isClosed())
                throw new ConnectionException(host.getSocketAddress(), "Pool is shutdown");

            PooledConnection connection = connectionRef.get();
            // If we race with shutdown, connection could be null. In that case we just loop and we'll throw on the next
            // iteration anyway
            if (connection != null) {
                while (true) {
                    int inFlight = connection.inFlight.get();

                    if (inFlight >= Math.min(connection.maxAvailableStreams(),
                                             options().getMaxSimultaneousRequestsPerHostThreshold(hostDistance)))
                        break;

                    if (connection.inFlight.compareAndSet(inFlight, inFlight + 1))
                        return connection;
                }
            }

            remaining = timeout - Cluster.timeSince(start, unit);
        } while (remaining > 0);

        throw new TimeoutException();
    }
View Full Code Here

TOP

Related Classes of java.util.concurrent.TimeoutException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.