Examples of tryAcquire()


Examples of java.util.concurrent.Semaphore.tryAcquire()

         // Reacquire the semaphore tickets; when we have them all
         // we know the threads are done
         for (int i = 0; i < count; i++)
         {
            boolean acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
            if (!acquired) fail("failed to acquire semaphore " + i);
         }

         // allow any async calls to clear
         if (!sync)

Examples of java.util.concurrent.Semaphore.tryAcquire()

         // Reacquire the semaphore tickets; when we have them all
         // we know the threads are done
         for (int i = 0; i < count; i++)
         {
            boolean acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
            if (!acquired)
            {
               fail("failed to acquire semaphore " + i);
            }
         }

Examples of java.util.concurrent.Semaphore.tryAcquire()

               System.out.println("Activating /" + stressor.getName() + " on A");
               cacheA.getRegion(Fqn.fromString("/" + stressor.getName()), true).activate();
               stressor.stopPuts();
               System.out.println("Run " + x + "-- /" + stressor.getName() + " activated on A");
               // Reacquire one semaphore ticket
               boolean acquired = semaphore.tryAcquire(60, TimeUnit.SECONDS);
               if (!acquired)
               {
                  fail("failed to acquire semaphore " + stressor.getName());
               }

Examples of java.util.concurrent.Semaphore.tryAcquire()

        ConnectFuture connectFuture = vmPipeConnector.connect(vmPipeAddress);
        connectFuture.awaitUninterruptibly();
        connectFuture.getSession().write(IoBuffer.wrap(new byte[1]));
        connectFuture.getSession().close(false).awaitUninterruptibly();

        semaphore.tryAcquire(1, TimeUnit.SECONDS);
        vmPipeAcceptor.unbind(vmPipeAddress);
        Assert.assertEquals(1, connectFuture.getSession().getWrittenBytes());
        Assert.assertEquals("ABCD", stringBuffer.toString());
    }
}

Examples of java.util.concurrent.Semaphore.tryAcquire()

      }
    };
   
    bqp.quiesce(qc, Arrays.asList(testBundle));
   
    assertTrue(result.tryAcquire(2, TimeUnit.SECONDS));
  }
}

Examples of java.util.concurrent.Semaphore.tryAcquire()

            server.stop();

            // test foreground retry
            client.checkExists().forPath("/hey");
            Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS));

            semaphore.drainPermits();
            retries.set(0);

            server.stop();

Examples of java.util.concurrent.Semaphore.tryAcquire()

            server.stop();

            // test background retry
            client.checkExists().inBackground().forPath("/hey");
            Assert.assertTrue(semaphore.tryAcquire(MAX_RETRIES, timing.forWaiting().seconds(), TimeUnit.SECONDS));
        }
        catch ( Throwable e )
        {
            Assert.fail("Error", e);
        }

Examples of java.util.concurrent.Semaphore.tryAcquire()

            return true;
        } else {
            for(int i = 0; i < numNodes; i++) {
                try {
                    long timeoutMs = timeoutConfig.getOperationTimeout(VoldemortOpCode.DELETE_OP_CODE);
                    boolean acquired = semaphore.tryAcquire(timeoutMs, TimeUnit.MILLISECONDS);
                    if(!acquired)
                        logger.warn("Delete operation timed out waiting for operation " + i
                                    + " to complete after waiting " + timeoutMs + " ms.");
                    // okay, at least the required number of operations have
                    // completed, were they successful?

Examples of java.util.concurrent.Semaphore.tryAcquire()

                creationSemaphore = new Semaphore(1, true);
                socketCreationMap.put(key, creationSemaphore);
            }
        }
        try {
            boolean retval = creationSemaphore.tryAcquire(10, TimeUnit.SECONDS);
            if (!retval) {
                throw new IOException("Could not acquire IO Semaphore'" + key
                        + "' after 10 seconds -- giving up ");
            }
        } catch (InterruptedException e) {

Examples of java.util.concurrent.Semaphore.tryAcquire()

                                stackLogger.logDebug("trying to acquiring semaphore for message " + message);
                            }
                            // we try to acquire here so that if the result if false because it is already acquired
                            // we acquire it in the thread to avoid blocking other messages with a different call id
                            // that could be processed in parallel
                            final boolean acquired = callIdSemaphore.tryAcquire(0, TimeUnit.SECONDS);                                                      
                           
                            Thread messageDispatchTask = new Thread() {
                                @Override
                                public void run() {
                                    // if it was not acquired above
TOP
Copyright © 2018 www.massapi.com. 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.