}
@Test public void testScanUncommitted() throws Exception {
try{
TransactionManager tm = new TransactionManager(conf);
TransactionalTable table = new TransactionalTable(conf, TEST_TABLE);
TransactionState t=tm.beginTransaction();
int[] lIntsA=new int[]{100,243,2342,22,1,5,43,56};
for (int i=0;i<lIntsA.length;i++) {
byte[]data=Bytes.toBytes(lIntsA[i]);
Put put=new Put(data);
put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
table.put(t,put);
}
tm.tryCommit(t);
TransactionState tu=tm.beginTransaction();
int[] lIntsB=new int[]{105,24,4342,32,7,3,30,40};
for (int i=0;i<lIntsB.length;i++) {
byte[]data=Bytes.toBytes(lIntsB[i]);
Put put=new Put(data);
put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
table.put(tu,put);
}
t=tm.beginTransaction();
int[] lIntsC=new int[]{109,224,242,2,16,59,23,26};
for (int i=0;i<lIntsC.length;i++) {
byte[]data=Bytes.toBytes(lIntsC[i]);
Put put=new Put(data);
put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes(TEST_COL), data);
table.put(t,put);
}
tm.tryCommit(t);
t=tm.beginTransaction();
Scan s=new Scan();
ResultScanner res=table.getScanner(t,s);
Result rr;
int count = 0;
while ((rr=res.next())!=null) {
int iTmp=Bytes.toInt(rr.getValue(Bytes.toBytes(TEST_FAMILY),
Bytes.toBytes(TEST_COL)));
LOG.info("Result: "+iTmp);
count++;
}
assertTrue("Count should be " + (lIntsA.length*lIntsC.length) + " but is " + count,
count == lIntsA.length + lIntsC.length);
LOG.info("Rows found " + count);
tm.tryCommit(t);
table.close();
} catch (Exception e) {
LOG.error("Exception in test", e);
}
}