Examples of Lock


Examples of java.util.concurrent.locks.Lock

        long mills1 = System.currentTimeMillis();
        long ops = 0L;
        long miss = 0L;
        int iocontention = 0;

        final Lock readLock = rwlock.readLock();
        final Lock writeLock = rwlock.writeLock();

        final int start = thrdnum * round;
        final int limit = start + round - 1;
        for(int nth = start, i = 0; !_stop; nth = (nth < limit) ? nth + 1 : start, i++) {
            final long key;
View Full Code Here

Examples of java.util.concurrent.locks.Lock

        long mills1 = System.currentTimeMillis();
        long ops = 0L;
        long miss = 0L;
        int iocontention = 0;

        final Lock readLock = rwlock.readLock();
        final Lock writeLock = rwlock.writeLock();

        final int start = thrdnum * round;
        final int limit = start + round - 1;
        for(int nth = start, i = 0; !_stop; nth = (nth < limit) ? nth + 1 : start, i++) {
            final long key;
View Full Code Here

Examples of java.util.concurrent.locks.Lock

    public void run()
    {
       try
       {
          Lock rlock = lock_.readLock();
          Lock wlock;
          if (!rlock.tryLock(0, TimeUnit.MILLISECONDS))
          {
             String str = caseNum + "-" + name + "-RL-0";
             postLockingResult(str);
             notifyBeforeFinish.countDown();
            if (beforeUpgrateWait != null) beforeUpgrateWait.await(10, TimeUnit.SECONDS);
            return;
          }
          // OK, read lock obtained, sleep and upgrade it later.
          notifyBeforeSecondOp.countDown();
          if (beforeUpgrateWait != null) beforeUpgrateWait.await(10, TimeUnit.SECONDS);
          String str = caseNum + "-" + name + "-UL-";
          if ((wlock = lock_.upgradeLockAttempt(0)) == null)
          {
             str += "0";
          }
          else
          {
             str += "1";
          }
          postLockingResult(str);
          // Sleep again and then release the lock.
          TestingUtil.sleepThread(SLEEP_MSECS);
          if (wlock != null)
          {
             wlock.unlock();
          }
          rlock.unlock();
          notifyBeforeFinish.countDown();
          if (beforeFinishWait != null) beforeFinishWait.await(10, TimeUnit.SECONDS);
       }
View Full Code Here

Examples of java.util.concurrent.locks.Lock

    if ( trace ) log.trace( "Opening IndexReader for directoryProviders: " + length );

    for (int index = 0; index < length; index++) {
      DirectoryProvider directoryProvider = directoryProviders[index];
      IndexReader reader;
      Lock directoryProviderLock = perDirectoryProviderManipulationLocks.get( directoryProvider );
      if ( trace ) log.trace( "Opening IndexReader from " + directoryProvider.getDirectory().toString() );
      directoryProviderLock.lock(); //needed for same problem as the double-checked locking
      try {
        reader = activeSearchIndexReaders.get( directoryProvider );
      }
      finally {
        directoryProviderLock.unlock();
      }
      if ( reader == null ) {
        if ( trace )
          log.trace( "No shared IndexReader, opening a new one: " + directoryProvider.getDirectory().toString() );
        reader = replaceActiveReader( null, directoryProviderLock, directoryProvider, readers );
      }
      else {
        boolean isCurrent;
        try {
          isCurrent = reader.isCurrent();
        }
        catch (IOException e) {
          throw new SearchException( "Unable to read current status of Lucene IndexReader", e );
        }
        if ( !isCurrent ) {
          if ( trace )
            log.trace( "Out of date shared IndexReader found, opening a new one: " + directoryProvider.getDirectory().toString() );
          IndexReader outOfDateReader = reader;
          reader = replaceActiveReader( outOfDateReader, directoryProviderLock, directoryProvider, readers );
        }
        else {
          if ( trace )
            log.trace( "Valid shared IndexReader: " + directoryProvider.getDirectory().toString() );
          directoryProviderLock.lock();
          try {
            //read the latest active one, the current one could be out of date and closed already
            //the latest active is guaranteed to be active because it's protected by the dp lock
            reader = activeSearchIndexReaders.get( directoryProvider );
            semaphoreIndexReaderLock.lock();
            try {
              SharedReaderProvider.ReaderData readerData = searchIndexReaderSemaphores.get( reader );
              //TODO if readerData is null????
              readerData.semaphore++;
              searchIndexReaderSemaphores.put( reader, readerData ); //not necessary
              if ( trace ) log.trace( "Semaphore increased: " + readerData.semaphore + " for " + reader );
            }
            finally {
              semaphoreIndexReaderLock.unlock();
            }
          }
          finally {
            directoryProviderLock.unlock();
          }
        }
      }
      readers[index] = reader;
    }
View Full Code Here

Examples of java.util.concurrent.locks.Lock

        //TODO should we try to close?
        continue;
      }

      //acquire the locks in the same order as everywhere else
      Lock directoryProviderLock = perDirectoryProviderManipulationLocks.get( readerData.provider );
      boolean closeReader = false;
      directoryProviderLock.lock();
      try {
        boolean isActive;
        isActive = activeSearchIndexReaders.get( readerData.provider ) == subReader;
        if ( trace ) log.trace( "Indexreader not active: " + subReader );
        semaphoreIndexReaderLock.lock();
        try {
          readerData = searchIndexReaderSemaphores.get( subReader );
          if ( readerData == null ) {
            log.error( "Trying to close a Lucene IndexReader not present: " + subReader.directory().toString() );
            //TODO should we try to close?
            continue;
          }
          readerData.semaphore--;
          if ( trace ) log.trace( "Semaphore decreased to: " + readerData.semaphore + " for " + subReader );
          if ( readerData.semaphore < 0 )
            log.error( "Semaphore negative: " + subReader.directory().toString() );
          if ( ( !isActive ) && readerData.semaphore == 0 ) {
            searchIndexReaderSemaphores.remove( subReader );
            closeReader = true;
          }
          else {
            closeReader = false;
          }
        }
        finally {
          semaphoreIndexReaderLock.unlock();
        }
      }
      finally {
        directoryProviderLock.unlock();
      }

      if ( closeReader ) {
        if ( trace ) log.trace( "Closing IndexReader: " + subReader );
        try {
View Full Code Here

Examples of java.util.concurrent.locks.Lock

        }
    }

    public static class NoCleanUpRemoteProcess implements Action<WorkerProcessContext>, Serializable {
        public void execute(WorkerProcessContext workerProcessContext) {
            final Lock lock = new ReentrantLock();
            lock.lock();
            new Thread(new Runnable() {
                public void run() {
                    lock.lock();
                }
            }).start();

            TestListenerInterface sender = workerProcessContext.getServerConnection().addOutgoing(
                    TestListenerInterface.class);
View Full Code Here

Examples of javax.ejb.Lock

      // if no bean level lock type specified, then just return null
      if (lockType == null)
      {
         return null;
      }
      Lock lock = new LockImpl(lockType);
      return annotationClass.cast(lock);

   }
View Full Code Here

Examples of javax.jcr.lock.Lock

        if (Type.WRITE.equals(type)) {
            try {
                if (!exists()) {
                    log.warn("Unable to retrieve lock: no item found at '" + getResourcePath() + "'");
                } else if (((Node) item).isLocked()) {
                    Lock jcrLock = ((Node) item).getLock();
                    lock = new JcrActiveLock(jcrLock);
                }
            } catch (AccessDeniedException e) {
                log.error("Error while accessing resource lock: "+e.getMessage());
            } catch (UnsupportedRepositoryOperationException e) {
View Full Code Here

Examples of nexj.core.runtime.InstanceRef.Lock

      {
         InstanceRef ref = m_context.findInstanceRef(instance.getLazyMetaclass(), instance.getOID());

         if (ref != null)
         {
            Lock lock = ref.unlink(this);

            if (lock != null)
            {
               removeLock(lock);
            }
View Full Code Here

Examples of nexj.core.util.lock.Lock

   /**
    * @see nexj.core.rpc.http.WebServer#getSessionLock()
    */
   public Lock getSessionLock() throws TimeoutException
   {
      Lock lock = s_lockMap.get(m_request.getSession(), m_lLockTimeout);

      lock.lock();

      return lock;
   }
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.