Package com.yahoo.omid.tso.messages

Examples of com.yahoo.omid.tso.messages.TimestampResponse


            switch (type) {
            case TSOMessage.TimestampRequest:
                msg = new TimestampRequest();
                break;
            case TSOMessage.TimestampResponse:
                msg = new TimestampResponse();
                break;
            case TSOMessage.CommitRequest:
                msg = new CommitRequest();
                break;
            case TSOMessage.CommitResponse:
View Full Code Here


        ChannelFuture future = Channels.future(channel);
        synchronized (sharedMsgBufLock) {
            cb = buffer.flush(future);
        }
        Channels.write(ctx, future, cb);
        Channels.write(channel, new TimestampResponse(timestamp));
   }
View Full Code Here

   @Test
   public void testCommit() throws Exception {
       
       clientHandler.sendMessage(new TimestampRequest());
       clientHandler.receiveBootstrap();
       TimestampResponse tr1 = clientHandler.receiveMessage(TimestampResponse.class);

       clientHandler.sendMessage(new CommitRequest(tr1.timestamp, new RowKey[] { r1 }));
       CommitResponse cr1 = clientHandler.receiveMessage(CommitResponse.class);
      
       clientHandler.sendMessage(new TimestampRequest());
       // Pending commit report
       CommittedTransactionReport ctr1 = clientHandler.receiveMessage(CommittedTransactionReport.class);
       assertEquals(cr1.startTimestamp, ctr1.startTimestamp);
       assertEquals(cr1.commitTimestamp, ctr1.commitTimestamp);
      
       tr1 = clientHandler.receiveMessage(TimestampResponse.class);

       clientHandler.sendMessage(new CommitRequest(tr1.timestamp, new RowKey[] { r1, r2 }));
       cr1 = clientHandler.receiveMessage(CommitResponse.class);
            
       LOG.info("Going to shut down TSO");
       teardownTSO();
     
       LOG.info("Going to restart TSO");
       setupTSO();
     
       LOG.info("TSO started, going to process transactions");
       clientHandler.sendMessage(new TimestampRequest());
       clientHandler.receiveBootstrap();
       TimestampResponse tr2 = clientHandler.receiveMessage(TimestampResponse.class);

       clientHandler.sendMessage(new CommitRequest(tr2.timestamp, new RowKey[] { r1 }))
       CommitResponse cr2 = clientHandler.receiveMessage(CommitResponse.class);
       LOG.info("Timestamps: start " + tr2.timestamp + ", commit" + cr2.startTimestamp);
       assertTrue(cr2.committed);
View Full Code Here

         Object msg;
         while (!((msg = clientHandler.receiveMessage()) instanceof TimestampResponse))
            // iterate until we get a TimestampResponse
            ;

         TimestampResponse tr1 = (TimestampResponse) msg;

         clientHandler.sendMessage(new CommitRequest(tr1.timestamp, new RowKey[] { r1, r2 }));
         clientHandler.receiveMessage(CommitResponse.class);
         clientHandler.sendMessage(new TimestampRequest());
      }
View Full Code Here

   public void testCommitAbortedReport() throws Exception {
      secondClientHandler.setAutoFullAbort(false);
     
      clientHandler.sendMessage(new TimestampRequest());
      clientHandler.receiveBootstrap();
      TimestampResponse tr1 = clientHandler.receiveMessage(TimestampResponse.class);

      secondClientHandler.sendMessage(new TimestampRequest());
      secondClientHandler.receiveBootstrap();
      TimestampResponse tr2 = secondClientHandler.receiveMessage(TimestampResponse.class);
     
      clientHandler.sendMessage(new CommitRequest(tr1.timestamp, new RowKey[] { r1 }));
      CommitResponse cr1 = clientHandler.receiveMessage(CommitResponse.class);
      assertTrue(cr1.committed);
      assertTrue(cr1.commitTimestamp > tr1.timestamp);
View Full Code Here

  
   @Test
   public void testReadAlgorithm() throws Exception {     
      secondClientHandler.sendMessage(new TimestampRequest());
      secondClientHandler.receiveBootstrap();
      TimestampResponse tr1 = secondClientHandler.receiveMessage(TimestampResponse.class);

      clientHandler.sendMessage(new TimestampRequest());
      clientHandler.sendMessage(new TimestampRequest());
      clientHandler.receiveBootstrap();
      TimestampResponse tr2 = clientHandler.receiveMessage(TimestampResponse.class);
      TimestampResponse tr3 = clientHandler.receiveMessage(TimestampResponse.class);
     
      clientHandler.setAutoFullAbort(false);
      clientHandler.sendMessage(new CommitRequest(tr2.timestamp, new RowKey[] { r1 }));
      CommitResponse cr1 = clientHandler.receiveMessage(CommitResponse.class);
      assertTrue(cr1.committed);
      clientHandler.sendMessage(new CommitRequest(tr3.timestamp, new RowKey[] { r1, r2 }));
      CommitResponse cr2 = clientHandler.receiveMessage(CommitResponse.class);
      assertFalse(cr2.committed);

      secondClientHandler.sendMessage(new TimestampRequest());
      secondClientHandler.receiveMessage(CommittedTransactionReport.class);
      secondClientHandler.receiveMessage(AbortedTransactionReport.class);
      TimestampResponse tr4 = secondClientHandler.receiveMessage(TimestampResponse.class);
     
      // Transaction half aborted
      assertFalse(secondClientHandler.validRead(tr3.timestamp, tr4.timestamp));
     
      // Transaction committed after start timestamp
View Full Code Here

   public void testTimestampsOrdering() throws Exception {
      long timestamp;

      clientHandler.sendMessage(new TimestampRequest());
      clientHandler.receiveBootstrap();
      TimestampResponse tr1 = clientHandler.receiveMessage(TimestampResponse.class);
      timestamp = tr1.timestamp;

      clientHandler.sendMessage(new TimestampRequest());
      TimestampResponse tr2 = clientHandler.receiveMessage(TimestampResponse.class);
      assertEquals(++timestamp, tr2.timestamp);

      clientHandler.sendMessage(new CommitRequest(tr2.timestamp, new RowKey[] { r1 }));
      CommitResponse cr1 = clientHandler.receiveMessage(CommitResponse.class);
      assertTrue(cr1.committed);
      assertEquals(tr2.timestamp, cr1.startTimestamp);
      assertEquals(++timestamp, cr1.commitTimestamp);

      clientHandler.sendMessage(new CommitRequest(tr1.timestamp, new RowKey[] { r2 }));
      CommitResponse cr2 = clientHandler.receiveMessage(CommitResponse.class);
      assertTrue(cr2.committed);
      assertEquals(tr1.timestamp, cr2.startTimestamp);
      assertEquals(++timestamp, cr2.commitTimestamp);

      {
         clientHandler.sendMessage(new TimestampRequest());
         CommittedTransactionReport ctr1 = clientHandler.receiveMessage(CommittedTransactionReport.class);
         assertEquals(cr1.startTimestamp, ctr1.startTimestamp);
         assertEquals(cr1.commitTimestamp, ctr1.commitTimestamp);

         CommittedTransactionReport ctr2 = clientHandler.receiveMessage(CommittedTransactionReport.class);
         assertEquals(cr2.startTimestamp, ctr2.startTimestamp);
         assertEquals(cr2.commitTimestamp, ctr2.commitTimestamp);

         TimestampResponse tr3 = clientHandler.receiveMessage(TimestampResponse.class);
         assertEquals(++timestamp, tr3.timestamp);
      }
   }
View Full Code Here

   @Test
   public void testGetTimestamp() throws Exception {
      clientHandler.sendMessage(new TimestampRequest());
      clientHandler.receiveBootstrap();
      TimestampResponse tr1 = clientHandler.receiveMessage(TimestampResponse.class);

      clientHandler.sendMessage(new TimestampRequest());
      TimestampResponse tr2 = clientHandler.receiveMessage(TimestampResponse.class);
      assertTrue(tr2.timestamp > tr1.timestamp);
   }
View Full Code Here

  
   @Test
   public void testCommitReport() throws Exception {     
      clientHandler.sendMessage(new TimestampRequest());
      clientHandler.receiveBootstrap();
      TimestampResponse tr1 = clientHandler.receiveMessage(TimestampResponse.class);

      clientHandler.sendMessage(new CommitRequest(tr1.timestamp));
      CommitResponse cr1 = clientHandler.receiveMessage(CommitResponse.class);
      assertTrue(cr1.committed);
      assertTrue(cr1.commitTimestamp > tr1.timestamp);
      assertEquals(tr1.timestamp, cr1.startTimestamp);
     
      secondClientHandler.sendMessage(new TimestampRequest());
      secondClientHandler.receiveBootstrap();
      TimestampResponse tr2 = secondClientHandler.receiveMessage(TimestampResponse.class);
     
      secondClientHandler.sendMessage(new CommitRequest(tr2.timestamp));
      CommitResponse cr2 = secondClientHandler.receiveMessage(CommitResponse.class);
      assertTrue(cr2.committed);
      assertTrue(cr2.commitTimestamp > tr2.timestamp);
      assertEquals(tr2.timestamp, cr2.startTimestamp);
     
      clientHandler.sendMessage(new TimestampRequest());
      // Txn 2 was a readonly transaction, so no committed info received
      clientHandler.receiveMessage(TimestampResponse.class);
     
      secondClientHandler.sendMessage(new TimestampRequest());
      TimestampResponse tr3 = secondClientHandler.receiveMessage(TimestampResponse.class);
     
      secondClientHandler.sendMessage(new CommitRequest(tr3.timestamp, new RowKey[] { r1 }));
      CommitResponse cr3 = secondClientHandler.receiveMessage(CommitResponse.class);
      assertTrue(cr3.committed);
      assertTrue(cr3.commitTimestamp > tr3.timestamp);
View Full Code Here

      // Disable auto full abort for testing every commit query request case
      clientHandler.setAutoFullAbort(false);

      clientHandler.sendMessage(new TimestampRequest());
      clientHandler.receiveBootstrap();
      TimestampResponse tr1 = clientHandler.receiveMessage(TimestampResponse.class);

      clientHandler.sendMessage(new TimestampRequest());
      TimestampResponse tr2 = clientHandler.receiveMessage(TimestampResponse.class);
      assertTrue(tr2.timestamp > tr1.timestamp);

      //
      // Test Commit query of uncommitted transaction
      //
      clientHandler.sendMessage(new CommitQueryRequest(tr2.timestamp, tr1.timestamp));
      CommitQueryResponse cqr1 = clientHandler.receiveMessage(CommitQueryResponse.class);
      assertFalse(cqr1.committed);
      assertFalse(cqr1.retry);

      clientHandler.sendMessage(new CommitRequest(tr1.timestamp, new RowKey[] { r1 }));
      CommitResponse cr1 = clientHandler.receiveMessage(CommitResponse.class);
      assertTrue(cr1.committed);
      assertTrue(cr1.commitTimestamp > tr1.timestamp);
      assertEquals(tr1.timestamp, cr1.startTimestamp);

      //
      // Test Commit query of concurrent committed transaction
      //
      clientHandler.sendMessage(new CommitQueryRequest(tr2.timestamp, tr1.timestamp));
      CommitQueryResponse cqr2 = clientHandler.receiveMessage(CommitQueryResponse.class);
      assertFalse(cqr2.committed);
      assertFalse(cqr2.retry);

      clientHandler.sendMessage(new CommitRequest(tr2.timestamp, new RowKey[] { r1, r2 }));
      CommitResponse cr2 = clientHandler.receiveMessage(CommitResponse.class);
      assertFalse(cr2.committed);

      // Queued reports
      clientHandler.sendMessage(new TimestampRequest());
      clientHandler.receiveMessage(CommittedTransactionReport.class);
      clientHandler.receiveMessage(AbortedTransactionReport.class);

      TimestampResponse tr3 = clientHandler.receiveMessage(TimestampResponse.class);
      assertTrue(tr3.timestamp > tr2.timestamp);

      state.largestDeletedTimestamp = 1000000;

      //
View Full Code Here

TOP

Related Classes of com.yahoo.omid.tso.messages.TimestampResponse

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.