Package com.yahoo.omid.client

Examples of com.yahoo.omid.client.TransactionState


   @Test public void runTestSimple() throws Exception {
      try {
         TransactionManager tm = new TransactionManager(conf);
         TransactionalTable tt = new TransactionalTable(conf, TEST_TABLE);
        
         TransactionState t1 = tm.beginTransaction();
         LOG.info("Transaction created " + t1);
        
         byte[] row = Bytes.toBytes("test-simple");
         byte[] fam = Bytes.toBytes(TEST_FAMILY);
         byte[] col = Bytes.toBytes("testdata");
         byte[] data1 = Bytes.toBytes("testWrite-1");
         byte[] data2 = Bytes.toBytes("testWrite-2");

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

         TransactionState tread = tm.beginTransaction();
         TransactionState t2 = tm.beginTransaction();
         p = new Put(row);
         p.add(fam, col, data2);
         tt.put(t2, p);
         tm.tryCommit(t2);
View Full Code Here


   @Test public void runTestManyVersions() throws Exception {
      try {
         TransactionManager tm = new TransactionManager(conf);
         TransactionalTable tt = new TransactionalTable(conf, TEST_TABLE);

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

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

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

         for (int i = 0; i < 5; ++i) {
            TransactionState t2 = tm.beginTransaction();
            p = new Put(row);
            p.add(fam, col, data2);
            tt.put(t2, p);
         }
         TransactionState tread = tm.beginTransaction();

         Get g = new Get(row).setMaxVersions(1);
         Result r = tt.get(g);
         assertTrue("Unexpected value for read: " + Bytes.toString(r.getValue(fam, col)),
               Bytes.equals(data2, r.getValue(fam, col)));
View Full Code Here

   @Test public void runTestInterleave() throws Exception {
      try {
         TransactionManager tm = new TransactionManager(conf);
         TransactionalTable tt = new TransactionalTable(conf, TEST_TABLE);
       
         TransactionState t1 = tm.beginTransaction();
         LOG.info("Transaction created " + t1);
        
         byte[] row = Bytes.toBytes("test-interleave");
         byte[] fam = Bytes.toBytes(TEST_FAMILY);
         byte[] col = Bytes.toBytes("testdata");
         byte[] data1 = Bytes.toBytes("testWrite-1");
         byte[] data2 = Bytes.toBytes("testWrite-2");

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

         TransactionState t2 = tm.beginTransaction();
         p = new Put(row);
         p.add(fam, col, data2);
         tt.put(t2, p);

         TransactionState tread = tm.beginTransaction();
         Get g = new Get(row).setMaxVersions(1);
         Result r = tt.get(tread, g);
         assertTrue("Unexpected value for SI read " + tread + ": " + Bytes.toString(r.getValue(fam, col)),
                    Bytes.equals(data1, r.getValue(fam, col)));
         tm.tryCommit(t2);
View Full Code Here

   @Test public void runTestInterleaveScan() throws Exception {
      try {
         TransactionManager tm = new TransactionManager(conf);
         TransactionalTable tt = new TransactionalTable(conf, 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);
        
         TransactionState tscan = tm.beginTransaction();
         ResultScanner rs = tt.getScanner(tscan, new Scan().setStartRow(startrow).setStopRow(stoprow));
         Result r = rs.next();
         int i = 0;
         while (r != null) {
            if (LOG.isTraceEnabled()) {
View Full Code Here

   @Test public void runTestDeleteCol() throws Exception {
      try {
         TransactionManager tm = new TransactionManager(conf);
         TransactionalTable tt = new TransactionalTable(conf, TEST_TABLE);
        
         TransactionState t1 = tm.beginTransaction();
         LOG.info("Transaction created " + t1);
        
         int rowcount = 10;
         int colAcount = 0;
         int colBcount = 0;

         byte[] fam = Bytes.toBytes(TEST_FAMILY);
         byte[] colA = Bytes.toBytes("testdataA");
         byte[] colB = Bytes.toBytes("testdataB");
         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, colA, data1);
            p.add(fam, colB, data2);
            tt.put(t1, p);
         }
         tm.tryCommit(t1);

         TransactionState t2 = tm.beginTransaction();
         Delete d = new Delete(modrow);
         d.deleteColumn(fam, colA);
         tt.delete(t2, d);
        
         TransactionState tscan = tm.beginTransaction();
         ResultScanner rs = tt.getScanner(tscan, new Scan());
         Result r = rs.next();
         colAcount = 0;
         colBcount = 0;
         while (r != null) {
View Full Code Here

   @Test public void runTestDeleteRow() throws Exception {
      try {
         TransactionManager tm = new TransactionManager(conf);
         TransactionalTable tt = new TransactionalTable(conf, 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[] 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();
         Delete d = new Delete(modrow);
         tt.delete(t2, d);
        
         TransactionState tscan = tm.beginTransaction();
         ResultScanner rs = tt.getScanner(tscan, new Scan());
         Result r = rs.next();
         count = 0;
         while (r != null) {
            count++;
View Full Code Here

   @Test public void testSingleColumnFamily() throws Exception {
      TransactionManager tm = new TransactionManager(conf);
      TransactionalTable table1 = new TransactionalTable(conf, 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(conf);
         TransactionalTable table1 = new TransactionalTable(conf, 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(conf);
         TransactionalTable table1 = new TransactionalTable(conf, 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

   @Test
   public void runTestWriteWriteConflict() throws Exception {
      TransactionManager tm = new TransactionManager(conf);
      TransactionalTable tt = new TransactionalTable(conf, 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

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.