Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.Condition


  void shutdown() {
    shutdown = true;
    entryLock.lock();
    try {
      while (!lockMap.isEmpty()) {
        Condition cond = lockMap.values().iterator().next();
        cond.awaitUninterruptibly();
      }
    } finally {
      entryLock.unlock();
    }
  }
View Full Code Here


        offsets.add(offset);
    }

    Map<Long, Condition> locked = new TreeMap<Long, Condition>();
    for (long offset : offsets) {
      Condition condition = lockManager.lockEntry(offset);
      if (condition == null)
        break;
      locked.put(offset, condition);
    }
View Full Code Here

            }
            oldMemtable.freeze();

            final CommitLogSegment.CommitLogContext ctx = writeCommitLog ? CommitLog.instance().getContext() : null;
            logger_.info(columnFamily_ + " has reached its threshold; switching in a fresh Memtable at " + ctx);
            final Condition condition = submitFlush(oldMemtable);
            memtable_ = new Memtable(this);
            // a second executor that makes sure the onMemtableFlushes get called in the right order,
            // while keeping the wait-for-flush (future.get) out of anything latency-sensitive.
            return commitLogUpdater_.submit(new WrappedRunnable()
            {
                public void runMayThrow() throws InterruptedException, IOException
                {
                    condition.await();
                    if (writeCommitLog)
                    {
                        // if we're not writing to the commit log, we are replaying the log, so marking
                        // the log header with "you can discard anything written before the context" is not valid
                        CommitLog.instance().discardCompletedSegments(table_, columnFamily_, ctx);
View Full Code Here

     * (since, by definition, it started last).
     */
    Condition submitFlush(IFlushable flushable)
    {
        logger_.info("Enqueuing flush of " + flushable);
        final Condition condition = new SimpleCondition();
        flushable.flushAndSignal(condition, flushSorter_, flushWriter_);
        return condition;
    }
View Full Code Here

            {
                return null;
            }
            logger_.info(columnFamily_ + " has reached its threshold; switching in a fresh Memtable");
            oldMemtable.freeze();
            final Condition condition = submitFlush(oldMemtable);
            memtable_ = new Memtable(table_, columnFamily_);
            // a second executor that makes sure the onMemtableFlushes get called in the right order,
            // while keeping the wait-for-flush (future.get) out of anything latency-sensitive.
            return commitLogUpdater_.submit(new Runnable()
            {
                public void run()
                {
                    try
                    {
                        condition.await();
                        if (writeCommitLog)
                        {
                            // if we're not writing to the commit log, we are replaying the log, so marking
                            // the log header with "you can discard anything written before the context" is not valid
                            onMemtableFlush(ctx);
View Full Code Here

            // since they're a little complicated.  (We dont' want to move the remove back to switchMemtable, which is
            // the other sane option, since that could mean keeping a flushed memtable in the Historical set unnecessarily
            // while earlier flushes finish.)
            getMemtablesPendingFlushNotNull(columnFamily_).add((Memtable) flushable); // it's ok for the MT to briefly be both active and pendingFlush
        }
        final Condition condition = new SimpleCondition();
        flushSorter_.submit(new Runnable()
        {
            public void run()
            {
                final List sortedKeys = flushable.getSortedKeys();
                flushWriter_.submit(new Runnable()
                {
                    public void run()
                    {
                        try
                        {
                            addSSTable(flushable.writeSortedContents(sortedKeys));
                        }
                        catch (IOException e)
                        {
                            throw new RuntimeException(e);
                        }
                        if (flushable instanceof Memtable)
                        {
                            getMemtablesPendingFlushNotNull(columnFamily_).remove(flushable);
                        }
                        condition.signalAll();
                    }
                });
            }
        });
        return condition;
View Full Code Here

        pkg.getJavaProject().getElementName(),
        unit.getTypes()[0].getFullyQualifiedName(), ILaunchManager.RUN_MODE);

    ILaunch launch = null;
    final Lock lock = new ReentrantLock();
    final Condition condition = lock.newCondition();
    lock.lock();
    try {
      // Wait for listener to be notified:
      while (listener.getLaunch(configName) == null) {
        condition.await(100, TimeUnit.MILLISECONDS);
      }
      launch = listener.getLaunch(configName);
      // Wait for launch to terminate:
      while (!launch.isTerminated()) {
        condition.await(100, TimeUnit.MILLISECONDS);
      }
      // Give the tracker a bit more time to finish:
      condition.await(100, TimeUnit.MILLISECONDS);
    } finally {
      lock.unlock();
    }
    tracker.setEnabled(false);
View Full Code Here

    ILaunchConfiguration config2 = launch(configName2,
        pkg.getJavaProject().getElementName(),
        unit2.getTypes()[0].getFullyQualifiedName(), ILaunchManager.RUN_MODE);

    final Lock lock = new ReentrantLock();
    final Condition condition = lock.newCondition();
    lock.lock();
    try {
      while (listener.getLaunch(configName1) == null
          || listener.getLaunch(configName2) == null) {
        condition.await(100, TimeUnit.MILLISECONDS);
      }
      while (!listener.getLaunch(configName1).isTerminated()
          || !listener.getLaunch(configName2).isTerminated()) {
        condition.await(100, TimeUnit.MILLISECONDS);
      }
      condition.await(100, TimeUnit.MILLISECONDS);
    } finally {
      lock.unlock();
    }
    tracker.setEnabled(false);
View Full Code Here

        pkg.getJavaProject().getElementName(),
        unit2.getType(className2).getFullyQualifiedName(),
        ILaunchManager.DEBUG_MODE);

    final Lock lock = new ReentrantLock();
    final Condition condition = lock.newCondition();
    lock.lock();
    try {
      // We had two breakpoints set, so we need to resume twice:
      while (suspendResume[0] == null) {
        condition.await(100, TimeUnit.MICROSECONDS);
      }
      suspendResume[0].resume();
      suspendResume[0] = null;
      condition.await(100, TimeUnit.MILLISECONDS);
      while (suspendResume[0] == null) {
        condition.await(100, TimeUnit.MILLISECONDS);
      }
      suspendResume[0].resume();
      condition.await(500, TimeUnit.MILLISECONDS);
    } finally {
      lock.unlock();
    }

    assertEquals(1, tracker.getData().size());
View Full Code Here

            }
            oldMemtable.freeze();

            final CommitLogSegment.CommitLogContext ctx = writeCommitLog ? CommitLog.instance().getContext() : null;
            logger_.info(columnFamily_ + " has reached its threshold; switching in a fresh Memtable at " + ctx);
            final Condition condition = submitFlush(oldMemtable);
            memtable_ = new Memtable(this);
            // a second executor that makes sure the onMemtableFlushes get called in the right order,
            // while keeping the wait-for-flush (future.get) out of anything latency-sensitive.
            return commitLogUpdater_.submit(new WrappedRunnable()
            {
                public void runMayThrow() throws InterruptedException, IOException
                {
                    condition.await();
                    if (writeCommitLog)
                    {
                        // if we're not writing to the commit log, we are replaying the log, so marking
                        // the log header with "you can discard anything written before the context" is not valid
                        CommitLog.instance().discardCompletedSegments(table_, columnFamily_, ctx);
View Full Code Here

TOP

Related Classes of java.util.concurrent.locks.Condition

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.