use of org.apache.hadoop.hbase.util.IncrementingEnvironmentEdge in project hbase by apache.
the class TestRegionObserverBypass method testMulti.
/**
* Test various multiput operations.
* @throws Exception
*/
@Test
public void testMulti() throws Exception {
//ensure that server time increments every time we do an operation, otherwise
//previous deletes will eclipse successive puts having the same timestamp
EnvironmentEdgeManagerTestHelper.injectEdge(new IncrementingEnvironmentEdge());
Table t = util.getConnection().getTable(tableName);
List<Put> puts = new ArrayList<>();
Put p = new Put(row1);
p.addColumn(dummy, dummy, dummy);
puts.add(p);
p = new Put(row2);
p.addColumn(test, dummy, dummy);
puts.add(p);
p = new Put(row3);
p.addColumn(test, dummy, dummy);
puts.add(p);
// before HBASE-4331, this would throw an exception
t.put(puts);
checkRowAndDelete(t, row1, 1);
checkRowAndDelete(t, row2, 0);
checkRowAndDelete(t, row3, 0);
puts.clear();
p = new Put(row1);
p.addColumn(test, dummy, dummy);
puts.add(p);
p = new Put(row2);
p.addColumn(test, dummy, dummy);
puts.add(p);
p = new Put(row3);
p.addColumn(test, dummy, dummy);
puts.add(p);
// before HBASE-4331, this would throw an exception
t.put(puts);
checkRowAndDelete(t, row1, 0);
checkRowAndDelete(t, row2, 0);
checkRowAndDelete(t, row3, 0);
puts.clear();
p = new Put(row1);
p.addColumn(test, dummy, dummy);
puts.add(p);
p = new Put(row2);
p.addColumn(test, dummy, dummy);
puts.add(p);
p = new Put(row3);
p.addColumn(dummy, dummy, dummy);
puts.add(p);
// this worked fine even before HBASE-4331
t.put(puts);
checkRowAndDelete(t, row1, 0);
checkRowAndDelete(t, row2, 0);
checkRowAndDelete(t, row3, 1);
puts.clear();
p = new Put(row1);
p.addColumn(dummy, dummy, dummy);
puts.add(p);
p = new Put(row2);
p.addColumn(test, dummy, dummy);
puts.add(p);
p = new Put(row3);
p.addColumn(dummy, dummy, dummy);
puts.add(p);
// this worked fine even before HBASE-4331
t.put(puts);
checkRowAndDelete(t, row1, 1);
checkRowAndDelete(t, row2, 0);
checkRowAndDelete(t, row3, 1);
puts.clear();
p = new Put(row1);
p.addColumn(test, dummy, dummy);
puts.add(p);
p = new Put(row2);
p.addColumn(dummy, dummy, dummy);
puts.add(p);
p = new Put(row3);
p.addColumn(test, dummy, dummy);
puts.add(p);
// before HBASE-4331, this would throw an exception
t.put(puts);
checkRowAndDelete(t, row1, 0);
checkRowAndDelete(t, row2, 1);
checkRowAndDelete(t, row3, 0);
t.close();
EnvironmentEdgeManager.reset();
}
use of org.apache.hadoop.hbase.util.IncrementingEnvironmentEdge in project hbase by apache.
the class TestHRegion method doTestDelete_AndPostInsert.
public void doTestDelete_AndPostInsert(Delete delete) throws IOException, InterruptedException {
this.region = initHRegion(tableName, method, CONF, fam1);
try {
EnvironmentEdgeManagerTestHelper.injectEdge(new IncrementingEnvironmentEdge());
Put put = new Put(row);
put.addColumn(fam1, qual1, value1);
region.put(put);
// now delete the value:
region.delete(delete);
// ok put data:
put = new Put(row);
put.addColumn(fam1, qual1, value2);
region.put(put);
// ok get:
Get get = new Get(row);
get.addColumn(fam1, qual1);
Result r = region.get(get);
assertEquals(1, r.size());
assertArrayEquals(value2, r.getValue(fam1, qual1));
// next:
Scan scan = new Scan(row);
scan.addColumn(fam1, qual1);
InternalScanner s = region.getScanner(scan);
List<Cell> results = new ArrayList<>();
assertEquals(false, s.next(results));
assertEquals(1, results.size());
Cell kv = results.get(0);
assertArrayEquals(value2, CellUtil.cloneValue(kv));
assertArrayEquals(fam1, CellUtil.cloneFamily(kv));
assertArrayEquals(qual1, CellUtil.cloneQualifier(kv));
assertArrayEquals(row, CellUtil.cloneRow(kv));
} finally {
HBaseTestingUtility.closeRegionAndWAL(this.region);
this.region = null;
}
}
Aggregations