Package org.apache.hadoop.hbase.regionserver.HRegion

Examples of org.apache.hadoop.hbase.regionserver.HRegion.RowLock


      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs + 2) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here


      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs + 2) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here

      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs + 2) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here

      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(CONF);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs + 2) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here

      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx =
        new MultithreadedTestUtil.TestContext(conf);
      final AtomicReference<OperationStatus[]> retFromThread =
        new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs +2 ) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here

      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(CONF);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs + 2) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here

      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(CONF);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs + 2) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here

      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(CONF);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs + 2) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here

      }

      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 2, source);

      LOG.info("Next a batch put that has to break into two batches to avoid a lock");
      RowLock rowLock = region.getRowLock(Bytes.toBytes("row_2"));

      MultithreadedTestUtil.TestContext ctx = new MultithreadedTestUtil.TestContext(CONF);
      final AtomicReference<OperationStatus[]> retFromThread = new AtomicReference<OperationStatus[]>();
      TestThread putter = new TestThread(ctx) {
        @Override
        public void doWork() throws IOException {
          retFromThread.set(region.batchMutate(puts));
        }
      };
      LOG.info("...starting put thread while holding lock");
      ctx.addThread(putter);
      ctx.startThreads();

      LOG.info("...waiting for put thread to sync first time");
      long startWait = System.currentTimeMillis();
      while (metricsAssertHelper.getCounter("syncTimeNumOps", source) == syncs + 2) {
        Thread.sleep(100);
        if (System.currentTimeMillis() - startWait > 10000) {
          fail("Timed out waiting for thread to sync first minibatch");
        }
      }
      LOG.info("...releasing row lock, which should let put thread continue");
      rowLock.release();
      LOG.info("...joining on thread");
      ctx.stop();
      LOG.info("...checking that next batch was synced");
      metricsAssertHelper.assertCounter("syncTimeNumOps", syncs + 4, source);
      codes = retFromThread.get();
View Full Code Here

        HRegion region = env.getRegion();
        /*
         * Lock directly on key, though it may be an index table. This will just prevent a table
         * from getting rebuilt too often.
         */
        RowLock rowLock = region.getRowLock(key);
        if (rowLock == null) {
            throw new IOException("Failed to acquire lock on " + Bytes.toStringBinary(key));
        }
        try {
            // Try cache again in case we were waiting on a lock
            table = metaDataCache.getIfPresent(cacheKey);
            // We only cache the latest, so we'll end up building the table with every call if the
            // client connection has specified an SCN.
            // TODO: If we indicate to the client that we're returning an older version, but there's
            // a newer version available, the client
            // can safely not call this, since we only allow modifications to the latest.
            if (table != null && table.getTimeStamp() < clientTimeStamp) {
                // Table on client is up-to-date with table on server, so just return
                if (isTableDeleted(table)) {
                    return null;
                }
                return table;
            }
            // Query for the latest table first, since it's not cached
            table = buildTable(key, cacheKey, region, HConstants.LATEST_TIMESTAMP);
            if (table != null && table.getTimeStamp() < clientTimeStamp) {
                return table;
            }
            // Otherwise, query for an older version of the table - it won't be cached
            return buildTable(key, cacheKey, region, clientTimeStamp);
        } finally {
            rowLock.release();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.regionserver.HRegion.RowLock

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.