Package java.util.concurrent.locks

Examples of java.util.concurrent.locks.ReadWriteLock


    this.oldJobId = TypeConverter.fromYarn(jobId);
    this.newApiCommitter = newApiCommitter;

    this.taskAttemptListener = taskAttemptListener;
    this.eventHandler = eventHandler;
    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    this.readLock = readWriteLock.readLock();
    this.writeLock = readWriteLock.writeLock();

    this.fsTokens = fsTokenCredentials;
    this.jobTokenSecretManager = jobTokenSecretManager;
    this.committer = committer;
View Full Code Here


      Map<TaskId, TaskInfo> completedTasksFromPreviousRun, int startCount,
      MRAppMetrics metrics) {
    this.conf = conf;
    this.clock = clock;
    this.jobFile = remoteJobConfFile;
    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    readLock = readWriteLock.readLock();
    writeLock = readWriteLock.writeLock();
    this.attempts = Collections.emptyMap();
    // This overridable method call is okay in a constructor because we
    //  have a convention that none of the overrides depends on any
    //  fields that need initialization.
    maxAttempts = getMaxAttempts();
View Full Code Here

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

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

    this.fsTokens = fsTokens;
    this.jobToken = jobToken;
    this.eventHandler = eventHandler;
    this.committer = committer;
View Full Code Here

  protected SolrIndexSearcher searcher;

  public DirectUpdateHandler2(SolrCore core) throws IOException {
    super(core);

    ReadWriteLock rwl = new ReentrantReadWriteLock();
    iwAccess = rwl.readLock();
    iwCommit = rwl.writeLock();

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

    public void testLoadInOnly() throws Exception {
        createRoute(Transacted.Jms, true, false, true);

        final int nbThreads = 10;
        final int nbExchanges = 10;
        final ReadWriteLock lock = new ReentrantReadWriteLock();
        final CountDownLatch latch = new CountDownLatch(nbThreads);
        final AtomicInteger id = new AtomicInteger();
        lock.writeLock().lock();
        for (int i = 0; i < nbThreads; i++) {
            new Thread() {
                public void run() {
                    Channel client = null;
                    try {
                        client = nmr1.createChannel();
                        lock.readLock().lock();
                        for (int i = 0; i < nbExchanges; i++) {
                            Exchange exchange = client.createExchange(Pattern.InOnly);
                            exchange.getIn().setBody(new StringSource("<hello id='" + id.getAndIncrement() + "'/>"));
                            exchange.setTarget(nmr1.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, PROXY_ENDPOINT_NAME)));
                            client.sendSync(exchange);
                            assertEquals(Status.Done, exchange.getStatus());
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        lock.readLock().unlock();
                        latch.countDown();
                        if (client != null) {
                            client.close();
                        }
                    }
                }
            }.start();
        }

        long t0, t1;

        t0 = System.currentTimeMillis();
        lock.writeLock().unlock();
      
        latch.await();

        receiver.assertExchangesReceived(nbThreads * nbExchanges, TIMEOUT);

View Full Code Here

    public void testLoadInOut() throws Exception {
        createRoute(Transacted.Jms, true, false, false);

        final int nbThreads = 10;
        final int nbExchanges = 10;
        final ReadWriteLock lock = new ReentrantReadWriteLock();
        final CountDownLatch latch = new CountDownLatch(nbThreads);
        lock.writeLock().lock();
        for (int i = 0; i < nbThreads; i++) {
            new Thread() {
                public void run() {
                    Channel client = null;
                    try {
                        client = nmr1.createChannel();
                        lock.readLock().lock();
                        for (int i = 0; i < nbExchanges; i++) {
                            Exchange exchange = client.createExchange(Pattern.InOut);
                            exchange.getIn().setBody(new StringSource("<hello/>"));
                            exchange.setTarget(nmr1.getEndpointRegistry().lookup(ServiceHelper.createMap(Endpoint.NAME, PROXY_ENDPOINT_NAME)));
                            client.sendSync(exchange);
                            assertEquals(Status.Active, exchange.getStatus());
                            exchange.setStatus(Status.Done);
                            client.send(exchange);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        lock.readLock().unlock();
                        latch.countDown();
                        if (client != null) {
                            client.close();
                        }
                    }
                }
            }.start();
        }

        cluster2.pause();
        lock.writeLock().unlock();
        Thread.sleep(0000);
        cluster2.resume();

        latch.await();
View Full Code Here

    this.oldJobId = TypeConverter.fromYarn(jobId);
    this.newApiCommitter = newApiCommitter;

    this.taskAttemptListener = taskAttemptListener;
    this.eventHandler = eventHandler;
    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    this.readLock = readWriteLock.readLock();
    this.writeLock = readWriteLock.writeLock();

    this.fsTokens = fsTokenCredentials;
    this.jobTokenSecretManager = jobTokenSecretManager;

    this.aclsManager = new JobACLsManager(conf);
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;
    this.jobFile = jobFile;
View Full Code Here

      Map<TaskId, TaskInfo> completedTasksFromPreviousRun, int startCount,
      MRAppMetrics metrics, AppContext appContext) {
    this.conf = conf;
    this.clock = clock;
    this.jobFile = remoteJobConfFile;
    ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
    readLock = readWriteLock.readLock();
    writeLock = readWriteLock.writeLock();
    this.attempts = Collections.emptyMap();
    this.finishedAttempts = new HashSet<TaskAttemptId>(2);
    this.failedAttempts = new HashSet<TaskAttemptId>(2);
    this.inProgressAttempts = new HashSet<TaskAttemptId>(2);
    // This overridable method call is okay in a constructor because we
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;
    this.hostDAO = injector.getInstance(HostDAO.class);
View Full Code Here

TOP

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

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.