Java 类org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext 实例源码

项目:ditb    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:ditb    文件:TestAcidGuarantees.java   
public AtomicGetReader(TestContext ctx, byte targetRow[],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:ditb    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(TableName TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = new HTable(conf, TABLE_NAME);
}
项目:ditb    文件:TestAtomicOperation.java   
/**
 * Test written as a verifier for HBASE-7051, CheckAndPut should properly read
 * MVCC.
 *
 * Moved into TestAtomicOperation from its original location, TestHBase7051
 */
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {

  final String tableName = "testPutAndCheckAndPut";
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  final MockHRegion region = (MockHRegion) TEST_UTIL.createLocalHRegion(Bytes.toBytes(tableName),
      null, null, tableName, conf, false, Durability.SYNC_WAL, null, Bytes.toBytes(family));

  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;

  region.batchMutate(puts, HConstants.NO_NONCE, HConstants.NO_NONCE);
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<Cell> results = new ArrayList<Cell>();
  ScannerContext scannerContext = ScannerContext.newBuilder().setBatchLimit(2).build();
  scanner.next(results, scannerContext);
  for (Cell keyValue : results) {
    assertEquals("50",Bytes.toString(CellUtil.cloneValue(keyValue)));
  }
}
项目:LCIndex-HBase-0.94.16    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:LCIndex-HBase-0.94.16    文件:TestAcidGuarantees.java   
public AtomicGetReader(TestContext ctx, byte targetRow[],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:LCIndex-HBase-0.94.16    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(String TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = new HTable(conf, TABLE_NAME);
}
项目:LCIndex-HBase-0.94.16    文件:TestHBase7051.java   
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {

  final String tableName = "testPutAndCheckAndPut";
  Configuration conf = HBaseConfiguration.create();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  final MockHRegion region = (MockHRegion) TestHRegion.initHRegion(Bytes.toBytes(tableName),
      tableName, conf, Bytes.toBytes(family));

  List<Pair<Mutation, Integer>> putsAndLocks = Lists.newArrayList();
  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;
  Pair<Mutation, Integer> pair = new Pair<Mutation, Integer>(puts[0], null);

  putsAndLocks.add(pair);

  region.batchMutate(putsAndLocks.toArray(new Pair[0]));
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<KeyValue> results = new ArrayList<KeyValue>();
  scanner.next(results, 2);
  for (KeyValue keyValue : results) {
    assertEquals("50",Bytes.toString(keyValue.getValue()));
  }

}
项目:pbase    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:pbase    文件:TestAcidGuarantees.java   
public AtomicGetReader(TestContext ctx, byte targetRow[],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:pbase    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(TableName TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = new HTable(conf, TABLE_NAME);
}
项目:pbase    文件:TestAtomicOperation.java   
/**
 * Test written as a verifier for HBASE-7051, CheckAndPut should properly read
 * MVCC. 
 * 
 * Moved into TestAtomicOperation from its original location, TestHBase7051
 */
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {

  final String tableName = "testPutAndCheckAndPut";
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  final MockHRegion region = (MockHRegion) TEST_UTIL.createLocalHRegion(Bytes.toBytes(tableName),
      null, null, tableName, conf, false, Durability.SYNC_WAL, null, Bytes.toBytes(family));

  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;

  region.batchMutate(puts);
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<Cell> results = new ArrayList<Cell>();
  scanner.next(results, 2);
  for (Cell keyValue : results) {
    assertEquals("50",Bytes.toString(CellUtil.cloneValue(keyValue)));
  }

}
项目:HIndex    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:HIndex    文件:TestAcidGuarantees.java   
public AtomicGetReader(TestContext ctx, byte targetRow[],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:HIndex    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(String TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = new HTable(conf, TABLE_NAME);
}
项目:HIndex    文件:TestAtomicOperation.java   
/**
 * Test written as a verifier for HBASE-7051, CheckAndPut should properly read
 * MVCC. 
 * 
 * Moved into TestAtomicOperation from its original location, TestHBase7051
 */
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {

  final String tableName = "testPutAndCheckAndPut";
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  final MockHRegion region = (MockHRegion) TEST_UTIL.createLocalHRegion(Bytes.toBytes(tableName),
      null, null, tableName, conf, false, Durability.SYNC_WAL, null, Bytes.toBytes(family));

  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;

  region.batchMutate(puts);
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<Cell> results = new ArrayList<Cell>();
  scanner.next(results, 2);
  for (Cell keyValue : results) {
    assertEquals("50",Bytes.toString(CellUtil.cloneValue(keyValue)));
  }

}
项目:HIndex    文件:TestAcidGuaranteesForIndex.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][], byte targetFamilies[][])
    throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:HIndex    文件:TestAcidGuaranteesForIndex.java   
public AtomicGetReader(TestContext ctx, byte targetRow[], byte targetFamilies[][])
    throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:IRIndex    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:IRIndex    文件:TestAcidGuarantees.java   
public AtomicGetReader(TestContext ctx, byte targetRow[],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:IRIndex    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(String TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = new HTable(conf, TABLE_NAME);
}
项目:IRIndex    文件:TestHBase7051.java   
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {

  final String tableName = "testPutAndCheckAndPut";
  Configuration conf = HBaseConfiguration.create();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  final MockHRegion region = (MockHRegion) TestHRegion.initHRegion(Bytes.toBytes(tableName),
      tableName, conf, Bytes.toBytes(family));

  List<Pair<Mutation, Integer>> putsAndLocks = Lists.newArrayList();
  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;
  Pair<Mutation, Integer> pair = new Pair<Mutation, Integer>(puts[0], null);

  putsAndLocks.add(pair);

  region.batchMutate(putsAndLocks.toArray(new Pair[0]));
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<KeyValue> results = new ArrayList<KeyValue>();
  scanner.next(results, 2);
  for (KeyValue keyValue : results) {
    assertEquals("50",Bytes.toString(keyValue.getValue()));
  }

}
项目:hbase    文件:AcidGuaranteesTestTool.java   
public AtomicityWriter(TestContext ctx, byte[][] targetRows, byte[][] targetFamilies,
    ExecutorService pool) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  connection = ConnectionFactory.createConnection(ctx.getConf(), pool);
  table = connection.getTable(TABLE_NAME);
}
项目:hbase    文件:AcidGuaranteesTestTool.java   
public AtomicGetReader(TestContext ctx, byte[] targetRow, byte[][] targetFamilies,
    ExecutorService pool) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  connection = ConnectionFactory.createConnection(ctx.getConf(), pool);
  table = connection.getTable(TABLE_NAME);
}
项目:hbase    文件:AcidGuaranteesTestTool.java   
public AtomicScanReader(TestContext ctx, byte[][] targetFamilies, ExecutorService pool)
    throws IOException {
  super(ctx);
  this.targetFamilies = targetFamilies;
  connection = ConnectionFactory.createConnection(ctx.getConf(), pool);
  table = connection.getTable(TABLE_NAME);
}
项目:hbase    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(TableName TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = UTIL.getConnection().getTable(TABLE_NAME);
}
项目:hbase    文件:TestAtomicOperation.java   
/**
 * Test written as a verifier for HBASE-7051, CheckAndPut should properly read
 * MVCC.
 *
 * Moved into TestAtomicOperation from its original location, TestHBase7051
 */
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  HTableDescriptor htd = new HTableDescriptor(TableName.valueOf(name.getMethodName()))
      .addFamily(new HColumnDescriptor(family));
  this.region = TEST_UTIL.createLocalHRegion(htd, null, null);
  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.addColumn(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;

  region.batchMutate(puts, HConstants.NO_NONCE, HConstants.NO_NONCE);
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<Cell> results = new ArrayList<>();
  ScannerContext scannerContext = ScannerContext.newBuilder().setBatchLimit(2).build();
  scanner.next(results, scannerContext);
  for (Cell keyValue : results) {
    assertEquals("50",Bytes.toString(CellUtil.cloneValue(keyValue)));
  }
}
项目:PyroDB    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:PyroDB    文件:TestAcidGuarantees.java   
public AtomicGetReader(TestContext ctx, byte targetRow[],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:PyroDB    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(String TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = new HTable(conf, TABLE_NAME);
}
项目:PyroDB    文件:TestAtomicOperation.java   
/**
 * Test written as a verifier for HBASE-7051, CheckAndPut should properly read
 * MVCC. 
 * 
 * Moved into TestAtomicOperation from its original location, TestHBase7051
 */
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {

  final String tableName = "testPutAndCheckAndPut";
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  final MockHRegion region = (MockHRegion) TEST_UTIL.createLocalHRegion(Bytes.toBytes(tableName),
      null, null, tableName, conf, false, Durability.SYNC_WAL, null, Bytes.toBytes(family));

  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;

  region.batchMutate(puts);
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<Cell> results = new ArrayList<Cell>();
  scanner.next(results, 2);
  for (Cell keyValue : results) {
    assertEquals("50",Bytes.toString(CellUtil.cloneValue(keyValue)));
  }

}
项目:c5    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:c5    文件:TestAcidGuarantees.java   
public AtomicGetReader(TestContext ctx, byte targetRow[],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:c5    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(String TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = new HTable(conf, TABLE_NAME);
}
项目:c5    文件:TestAtomicOperation.java   
/**
 * Test written as a verifier for HBASE-7051, CheckAndPut should properly read
 * MVCC. 
 * 
 * Moved into TestAtomicOperation from its original location, TestHBase7051
 */
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {

  final String tableName = "testPutAndCheckAndPut";
  Configuration conf = TEST_UTIL.getConfiguration();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  final MockHRegion region = (MockHRegion) TEST_UTIL.createLocalHRegion(Bytes.toBytes(tableName),
      null, null, tableName, conf, false, Durability.SYNC_WAL, null, Bytes.toBytes(family));

  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;

  region.batchMutate(puts);
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<Cell> results = new ArrayList<Cell>();
  scanner.next(results, 2);
  for (Cell keyValue : results) {
    assertEquals("50",Bytes.toString(CellUtil.cloneValue(keyValue)));
  }

}
项目:HBase-Research    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:HBase-Research    文件:TestAcidGuarantees.java   
public AtomicGetReader(TestContext ctx, byte targetRow[],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRow = targetRow;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}
项目:HBase-Research    文件:TestHRegionServerBulkLoad.java   
public AtomicScanReader(String TABLE_NAME, TestContext ctx,
    byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.TABLE_NAME = TABLE_NAME;
  this.targetFamilies = targetFamilies;
  table = new HTable(conf, TABLE_NAME);
}
项目:HBase-Research    文件:TestHBase7051.java   
@Test
public void testPutAndCheckAndPutInParallel() throws Exception {

  final String tableName = "testPutAndCheckAndPut";
  Configuration conf = HBaseConfiguration.create();
  conf.setClass(HConstants.REGION_IMPL, MockHRegion.class, HeapSize.class);
  final MockHRegion region = (MockHRegion) TestHRegion.initHRegion(Bytes.toBytes(tableName),
      tableName, conf, Bytes.toBytes(family));

  List<Pair<Mutation, Integer>> putsAndLocks = Lists.newArrayList();
  Put[] puts = new Put[1];
  Put put = new Put(Bytes.toBytes("r1"));
  put.add(Bytes.toBytes(family), Bytes.toBytes("q1"), Bytes.toBytes("10"));
  puts[0] = put;
  Pair<Mutation, Integer> pair = new Pair<Mutation, Integer>(puts[0], null);

  putsAndLocks.add(pair);

  region.batchMutate(putsAndLocks.toArray(new Pair[0]));
  MultithreadedTestUtil.TestContext ctx =
    new MultithreadedTestUtil.TestContext(conf);
  ctx.addThread(new PutThread(ctx, region));
  ctx.addThread(new CheckAndPutThread(ctx, region));
  ctx.startThreads();
  while (testStep != TestStep.CHECKANDPUT_COMPLETED) {
    Thread.sleep(100);
  }
  ctx.stop();
  Scan s = new Scan();
  RegionScanner scanner = region.getScanner(s);
  List<KeyValue> results = new ArrayList<KeyValue>();
  scanner.next(results, 2);
  for (KeyValue keyValue : results) {
    assertEquals("50",Bytes.toString(keyValue.getValue()));
  }

}
项目:hbase-0.94.8-qod    文件:TestAcidGuarantees.java   
public AtomicityWriter(TestContext ctx, byte targetRows[][],
                       byte targetFamilies[][]) throws IOException {
  super(ctx);
  this.targetRows = targetRows;
  this.targetFamilies = targetFamilies;
  table = new HTable(ctx.getConf(), TABLE_NAME);
}