Package java.util.concurrent

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


            tracker.open();

            try {
                configs[0].delete();

                if (!sem.tryAcquire(1, TimeUnit.SECONDS)) {
                    throw new IOException("Instance did not get removed in time.");
                }
            }
            finally {
                tracker.close();
View Full Code Here


            for (int i = 0; i < configs.length; i++) {
                configs[i].delete();
            }

            if (!sem.tryAcquire(1, TimeUnit.SECONDS)) {
                throw new IOException("Not all instances were removed in time.");
            }
            tracker.close();
        }
    }
View Full Code Here

                     }

                     message.getBodyBuffer().writeBytes(new byte[50]);

                     producer.send(message);
                     assertTrue(semop.tryAcquire(1, 10, TimeUnit.SECONDS));
                  }
               }
               catch (Throwable e)
               {
                  e.printStackTrace(System.out);
View Full Code Here

                        throw (Error) t;
                    }
                }
        }}, taskOwner);

        assertTrue(doneFlag.tryAcquire(2, 1, TimeUnit.SECONDS));
        Throwable throwable = error.get();
        if (throwable != null) {
            throw new AssertionError(throwable);
        }
    }
View Full Code Here

                }
                Transaction txn = txnProxy.getCurrentTransaction();
                txn.abort(new TestAbortedTransactionException("abort"));
        }}, taskOwner);

        assertTrue(doneFlag.tryAcquire(2, 1, TimeUnit.SECONDS));
        Throwable throwable = error.get();
        if (throwable != null) {
            throw new AssertionError(throwable);
        }
    }
View Full Code Here

            }
        }
        ShutdownTask task = new ShutdownTask();
        try {
            txnScheduler.runTask(task, taskOwner);
            assertTrue(doneFlag.tryAcquire(200, TimeUnit.MILLISECONDS));
            Throwable throwable = error.get();
            if (throwable != null) {
                throw new AssertionError(throwable);
            }
        } finally {
View Full Code Here

      UsePrepareAndCommit.ARBITRARY, 20000);
        /* Get write lock on name-299 and notify txn */
        store.setBinding(txn2, "name-299", id2);
        flag.release();
        /* Wait for txn, then commit */
        flag2.tryAcquire(10000, TimeUnit.MILLISECONDS);
        txn2.commit();
    } catch (TransactionAbortedException e) {
        System.err.println("txn2: " + e);
        exception2 = e;
    } catch (Exception e) {
View Full Code Here

    public void run() {
                }
            }, taskOwner);
           
        // Calling reports is asynchronous
        flag.tryAcquire(100, TimeUnit.MILLISECONDS);
        assertTrue(test.reportCalls > 0);
    }
   
    @Test
    public void testAddListenerTwice() throws Exception {
View Full Code Here

                public void run() {
                    AppContext.getDataManager().
                        createReference(new DummyObject());
                }
            }, serverNode.getProxy().getCurrentOwner());
        if (! sem.tryAcquire(500, TimeUnit.MILLISECONDS)) {
            throw new RuntimeException("Listener never reported");
        }
        if (throwableRef.get() != null) {
            throw new RuntimeException("listener failed", throwableRef.get());
        }
View Full Code Here

                            createReference(new DummyObject());
                        throw new ExpectedException();
                    }
                }, serverNode.getProxy().getCurrentOwner());
        } catch (ExpectedException ee) {}
        if (! sem.tryAcquire(500, TimeUnit.MILLISECONDS)) {
            throw new RuntimeException("Listener never reported");
        }
        if (throwableRef.get() != null) {
            throw new RuntimeException("listener failed", throwableRef.get());
        }
View Full Code Here

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.