Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReadWriteLock.readLock()


    @Test
    public void testInitLock()
    {
        ReadWriteLock lock = EasyMock.createMock(ReadWriteLock.class);
        Lock readLock = EasyMock.createMock(Lock.class);
        EasyMock.expect(lock.readLock()).andReturn(readLock);
        readLock.lock();
        EasyMock.replay(lock, readLock);
        ReadWriteSynchronizer sync = new ReadWriteSynchronizer(lock);
        sync.beginRead();
        EasyMock.verify(lock, readLock);
View Full Code Here


    super(core);

    // Pass fairness=true so commit request is not starved
    // when add/updates are running hot (SOLR-2342):
    ReadWriteLock rwl = new ReentrantReadWriteLock(true);
    iwAccess = rwl.readLock();
    iwCommit = rwl.writeLock();

    tracker = new CommitTracker();
  }
View Full Code Here

  @Inject
  public HostImpl(@Assisted HostEntity hostEntity,
      @Assisted boolean persisted, Injector injector) {
    this.stateMachine = stateMachineFactory.make(this);
    ReadWriteLock rwLock = new ReentrantReadWriteLock();
    this.readLock = rwLock.readLock();
    this.writeLock = rwLock.writeLock();

    this.hostEntity = hostEntity;
    this.injector = injector;
    this.persisted = persisted;
View Full Code Here

    } else {
      this.stateMachine = daemonStateMachineFactory.make(this);
    }

    ReadWriteLock rwLock = new ReentrantReadWriteLock();
    this.readLock = rwLock.readLock();
    this.writeLock = rwLock.writeLock();
    this.serviceComponent = serviceComponent;

    stateEntity = new HostComponentStateEntity();
    stateEntity.setClusterId(serviceComponent.getClusterId());
View Full Code Here

                                  @Assisted HostComponentStateEntity stateEntity,
                                  @Assisted HostComponentDesiredStateEntity desiredStateEntity,
                                  Injector injector) {
    injector.injectMembers(this);
    ReadWriteLock rwLock = new ReentrantReadWriteLock();
    this.readLock = rwLock.readLock();
    this.writeLock = rwLock.writeLock();
    this.serviceComponent = serviceComponent;


    this.desiredStateEntity = desiredStateEntity;
View Full Code Here

            throw new NullPointerException();
        }
        this.lifecycleManagerRegistry = lifecycleManagerRegistry;
        this.cacheByClass = new HashMap<Class<?>, ResourceRecord>();
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
        readersLock = readWriteLock.readLock();
        writersLock = readWriteLock.writeLock();
    }

    /**
     * Gets a resource record from a cache of records for the specified resource
View Full Code Here

                            ApplicationValidator applicationValidator) {
        this.applicationValidator = applicationValidator;
        rootResources = new LinkedList<ResourceRecord>();
        resourceRecordsFactory = new ResourceRecordFactory(factoryRegistry);
        ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
        readersLock = readWriteLock.readLock();
        writersLock = readWriteLock.writeLock();
        uriToResourceCache.put(Boolean.TRUE,
                               new SoftConcurrentMap<String, ArrayList<ResourceRecord>>());
        uriToResourceCache.put(Boolean.FALSE,
                               new SoftConcurrentMap<String, ArrayList<ResourceRecord>>());
View Full Code Here

    data.write();
    data.read();
    QueueLock qlock = new MockQueueLock();
   
    final ReadWriteLock locker = new DistributedReadWriteLock(qlock, "locker1".getBytes());
    final Lock readLock = locker.readLock();
    final Lock writeLock = locker.writeLock();
    readLock.lock();
    readLock.unlock();
    writeLock.lock();
    writeLock.unlock();
View Full Code Here

              data.write();
            } finally {
              wl.unlock();
            }
          } else {
            final Lock rl = locker.readLock();
            rl.lock();
            data.read();
            try {
              data.read();
            } finally {
View Full Code Here

    // Initialize reportedStatus
    reportedStatus = new TaskAttemptStatus();
    initTaskAttemptStatus(reportedStatus);

    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    readLock = readWriteLock.readLock();
    writeLock = readWriteLock.writeLock();

    this.credentials = credentials;
    this.jobToken = jobToken;
    this.eventHandler = eventHandler;
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.