Package com.yahoo.omid.client

Examples of com.yahoo.omid.client.TransactionState


   @Test public void testScanUncommitted() throws Exception {
      try{
         TransactionManager tm = new TransactionManager(hbaseConf);
         TransactionalTable table = new TransactionalTable(hbaseConf, 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);
View Full Code Here


   @Test public void testSingleColumnFamily() throws Exception {
      TransactionManager tm = new TransactionManager(hbaseConf);
      TransactionalTable table1 = new TransactionalTable(hbaseConf, TEST_TABLE);
      int num=10;
      TransactionState t=tm.beginTransaction();
      for(int j=0;j<num;j++) {
         byte[]data=Bytes.toBytes(j);
         Put put=new Put(data);
         put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("value1"), data);
         put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("value2"), data);
View Full Code Here

         byte[] family = Bytes.toBytes(TEST_FAMILY);
         byte[] col1 = Bytes.toBytes("value1");
         byte[] col2 = Bytes.toBytes("value2");
         TransactionManager tm = new TransactionManager(hbaseConf);
         TransactionalTable table1 = new TransactionalTable(hbaseConf, TEST_TABLE);
         TransactionState t=tm.beginTransaction();
         int val=1000;
         byte[]data=Bytes.toBytes(val);
         Put put1=new Put(data);
         put1.add(family, col1, data);
         table1.put(t,put1);
View Full Code Here

         byte[] family = Bytes.toBytes(TEST_FAMILY);
         byte[] col = Bytes.toBytes("value");

         TransactionManager tm = new TransactionManager(hbaseConf);
         TransactionalTable table1 = new TransactionalTable(hbaseConf, TEST_TABLE);
         TransactionState t=tm.beginTransaction();
         int num=50;
         for(int j=0;j<=num;j++) {
            byte[]data=Bytes.toBytes(j);
            Put put=new Put(data);
            put.add(family, col, data);
View Full Code Here

        TransactionManager tm = new TransactionManager(conf);
        TransactionalTable tt = new TransactionalTable(conf, TEST_TABLE);

        TransactionalTable tt2 = new TransactionalTable(conf, TEST_TABLE2);

        TransactionState t1 = tm.beginTransaction();

        Put put = new Put(Bytes.toBytes("2002"));
        put.add(Bytes.toBytes(TEST_FAMILY), Bytes.toBytes("c"), Bytes.toBytes("2002"));
        tt.put(t1, put);
View Full Code Here

   @Test
   public void runTestWriteWriteConflict() throws Exception {
      TransactionManager tm = new TransactionManager(hbaseConf);
      TransactionalTable tt = new TransactionalTable(hbaseConf, TEST_TABLE);

      TransactionState t1 = tm.beginTransaction();
      LOG.info("Transaction created " + t1);

      TransactionState t2 = tm.beginTransaction();
      LOG.info("Transaction created" + t2);

      byte[] row = Bytes.toBytes("test-simple");
      byte[] fam = Bytes.toBytes(TEST_FAMILY);
      byte[] col = Bytes.toBytes("testdata");
View Full Code Here

         admin.enableTable(table2);
      }

      TransactionalTable tt2 = new TransactionalTable(hbaseConf, table2);

      TransactionState t1 = tm.beginTransaction();
      LOG.info("Transaction created " + t1);

      TransactionState t2 = tm.beginTransaction();
      LOG.info("Transaction created" + t2);

      byte[] row = Bytes.toBytes("test-simple");
      byte[] row2 = Bytes.toBytes("test-simple2");
      byte[] fam = Bytes.toBytes(TEST_FAMILY);
View Full Code Here

   @Test
   public void runTestCleanupAfterConflict() throws Exception {
      TransactionManager tm = new TransactionManager(hbaseConf);
      TransactionalTable tt = new TransactionalTable(hbaseConf, TEST_TABLE);

      TransactionState t1 = tm.beginTransaction();
      LOG.info("Transaction created " + t1);

      TransactionState t2 = tm.beginTransaction();
      LOG.info("Transaction created" + t2);

      byte[] row = Bytes.toBytes("test-simple");
      byte[] fam = Bytes.toBytes(TEST_FAMILY);
      byte[] col = Bytes.toBytes("testdata");
View Full Code Here

   public void testCleanupWithDeleteRow() throws Exception {
      try {
         TransactionManager tm = new TransactionManager(hbaseConf);
         TransactionalTable tt = new TransactionalTable(hbaseConf, TEST_TABLE);

         TransactionState t1 = tm.beginTransaction();
         LOG.info("Transaction created " + t1);

         int rowcount = 10;
         int count = 0;

         byte[] fam = Bytes.toBytes(TEST_FAMILY);
         byte[] col = Bytes.toBytes("testdata");
         byte[] data1 = Bytes.toBytes("testWrite-1");
         byte[] data2 = Bytes.toBytes("testWrite-2");

         byte[] modrow = Bytes.toBytes("test-del" + 3);
         for (int i = 0; i < rowcount; i++) {
            byte[] row = Bytes.toBytes("test-del" + i);

            Put p = new Put(row);
            p.add(fam, col, data1);
            tt.put(t1, p);
         }
         tm.tryCommit(t1);

         TransactionState t2 = tm.beginTransaction();
         LOG.info("Transaction created " + t2);
         Delete d = new Delete(modrow);
         tt.delete(t2, d);

         ResultScanner rs = tt.getScanner(t2, new Scan());
         Result r = rs.next();
         count = 0;
         while (r != null) {
            count++;
            LOG.trace("row: " + Bytes.toString(r.getRow()) + " count: " + count);
            r = rs.next();
         }
         assertEquals("Wrong count", rowcount - 1, count);

         TransactionState t3 = tm.beginTransaction();
         LOG.info("Transaction created " + t3);
         Put p = new Put(modrow);
         p.add(fam, col, data2);
         tt.put(t3, p);

         tm.tryCommit(t3);

         boolean aborted = false;
         try {
            tm.tryCommit(t2);
            assertTrue("Didn't abort", false);
         } catch (CommitUnsuccessfulException e) {
            aborted = true;
         }
         assertTrue("Didn't raise exception", aborted);

         TransactionState tscan = tm.beginTransaction();
         rs = tt.getScanner(tscan, new Scan());
         r = rs.next();
         count = 0;
         while (r != null) {
            count++;
View Full Code Here

   @Test public void runTestInterleaveScan() throws Exception {
      try {
         TransactionManager tm = new TransactionManager(hbaseConf);
         TransactionalTable tt = new TransactionalTable(hbaseConf, TEST_TABLE);
        
         TransactionState t1 = tm.beginTransaction();
         LOG.info("Transaction created " + t1);
        
         byte[] fam = Bytes.toBytes(TEST_FAMILY);
         byte[] col = Bytes.toBytes("testdata");
         byte[] data1 = Bytes.toBytes("testWrite-1");
         byte[] data2 = Bytes.toBytes("testWrite-2");
        
         byte[] startrow = Bytes.toBytes("test-scan" + 0);
         byte[] stoprow = Bytes.toBytes("test-scan" + 9);
         byte[] modrow = Bytes.toBytes("test-scan" + 3);
         for (int i = 0; i < 10; i++) {
            byte[] row = Bytes.toBytes("test-scan" + i);
           
            Put p = new Put(row);
            p.add(fam, col, data1);
            tt.put(t1, p);
         }
         tm.tryCommit(t1);

         TransactionState t2 = tm.beginTransaction();
         Put p = new Put(modrow);
         p.add(fam, col, data2);
         tt.put(t2, p);        
        
         int modifiedrows = 0;
         ResultScanner rs = tt.getScanner(t2, new Scan().setStartRow(startrow).setStopRow(stoprow).addColumn(fam, col));
         Result r = rs.next();
         while (r != null) {
            if (Bytes.equals(data2, r.getValue(fam, col))) {
               if (LOG.isTraceEnabled()) {
                  LOG.trace("Modified :" + Bytes.toString(r.getRow()));
               }
               modifiedrows++;
            }
           
            r = rs.next();
         }
        
         assertTrue("Expected 1 row modified, but " + modifiedrows + " are.",
                    modifiedrows == 1);
         tm.abort(t2);
        
         TransactionState tscan = tm.beginTransaction();
         rs = tt.getScanner(tscan, new Scan().setStartRow(startrow).setStopRow(stoprow).addColumn(fam, col));
         r = rs.next();
         while (r != null) {
            if (LOG.isTraceEnabled()) {
               LOG.trace("Scan1 :" + Bytes.toString(r.getRow()) + " => " + Bytes.toString(r.getValue(fam, col)));
View Full Code Here

TOP

Related Classes of com.yahoo.omid.client.TransactionState

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.