Package com.linkedin.databus.core

Examples of com.linkedin.databus.core.Checkpoint


        dispatcher.setSchemaIdCheck(false);

        BootstrapCheckpointHandler cptHandler = new BootstrapCheckpointHandler("source1");
        long sinceScn=15000L;
        long startTsNsecs = System.nanoTime();
        final Checkpoint initCheckpoint = cptHandler.createInitialBootstrapCheckpoint(null, sinceScn);
        initCheckpoint.setBootstrapStartNsecs(startTsNsecs);
        initCheckpoint.setBootstrapStartScn(0L);

        /* Launch writer */
        //numBootstrapCheckpoint - number of checkpoints before writing end of period
        int numBootstrapCheckpoint=4;
        DbusEventAppender eventProducer = new DbusEventAppender(srcTestEvents, dataEventsBuffer,numBootstrapCheckpoint,null) ;
        //simulate bootstrap server; use this checkpoint as init checkpoint
        eventProducer.setBootstrapCheckpoint(initCheckpoint);
        Thread tEmitter = new Thread(eventProducer);
      //be generous ; use worst case for num control events
        long waitTimeMs  = (numEvents*timeTakenForDataEventInMs + numEvents*timeTakenForControlEventInMs) * 4;

        tEmitter.start();
        tEmitter.join(waitTimeMs);


        /* Launch dispatcher */
        Thread tDispatcher = new Thread(dispatcher);
        tDispatcher.start();

        /* Now initialize this  state machine */
        dispatcher.enqueueMessage(SourcesMessage.createSetSourcesIdsMessage(sourcesMap.values()));
        dispatcher.enqueueMessage(SourcesMessage.createSetSourcesSchemasMessage(schemaMap));

        //expect dispatcher to fail - at end of window
        tDispatcher.join(waitTimeMs);

        Assert.assertFalse(tEmitter.isAlive());
        Assert.assertFalse(tDispatcher.isAlive());

        LOG.info("tConsumer: " + tConsumer);
        HashMap<List<String>,Checkpoint> cps = cpPersister.getCheckpoints();
        Assert.assertTrue(cps.size() > 0);
        for (Map.Entry<List<String>,Checkpoint> i : cps.entrySet())
        {
            Checkpoint cp = i.getValue();
            LOG.info("checkpoint="+ cp);
            Assert.assertEquals(cp.getConsumptionMode(), DbusClientMode.BOOTSTRAP_SNAPSHOT);
            //check if progress has been made during bootstrap
            Assert.assertTrue(cp.getSnapshotOffset() > 0);
            //these two values should be unchanged during the course of bootstrap
            Assert.assertEquals(sinceScn,cp.getBootstrapSinceScn().longValue());
            Assert.assertEquals(startTsNsecs,cp.getBootstrapStartNsecs());
            //the tsNsec normally udpdated by client at end of window should be a no-op during bootstrap
            Assert.assertEquals(Checkpoint.UNSET_TS_NSECS,cp.getTsNsecs());
            //the scn passed to consumers during onCheckpoint should be the sinceSCN and not any other interim value
            Assert.assertEquals(cp.getBootstrapSinceScn().longValue(),tConsumer.getLastSeenCheckpointScn());
        }
        log.info("end\n");
    }
View Full Code Here


       *  reader side to achieve the behavior that ChunkedBodyReadableByte channel provides.
       */
      readerStream.configureBlocking(false);

      //Event writer - Relay in the real world
      Checkpoint cp = Checkpoint.createFlexibleCheckpoint();

      //Event readers - Clients in the real world
      //Checkpoint pullerCheckpoint = Checkpoint.createFlexibleCheckpoint();
      DbusEventsStatisticsCollector clientStats = new DbusEventsStatisticsCollector(0, "client", true, false, null);
      DbusEventBufferReader reader = new DbusEventBufferReader(destEventsBuf, readerStream, null, clientStats);
View Full Code Here

      Pipe.SourceChannel readerStream = pipe.source();
      writerStream.configureBlocking(true);
      readerStream.configureBlocking(false);

      //Event writer - Relay in the real world
      Checkpoint cp = Checkpoint.createFlexibleCheckpoint();

      //Event readers - Clients in the real world
      //Checkpoint pullerCheckpoint = Checkpoint.createFlexibleCheckpoint();
      DbusEventsStatisticsCollector clientStats = new DbusEventsStatisticsCollector(0, "client", true, false, null);
      DbusEventBufferReader reader = new DbusEventBufferReader(destEventsBuf, readerStream, null, clientStats);
View Full Code Here

      // Register_Response_Success to Request Stream, when partially consumed window
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        RelayPullThread relayPuller = bldr.createRelayPullThread();

        Checkpoint cp = new Checkpoint();
        cp.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
        cp.setWindowScn(100L);
        cp.setWindowOffset(20);
        cp.setPrevScn(80L);
        relayPuller.getConnectionState().setCheckpoint(cp);
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        Assert.assertEquals(relayPuller.getConnectionState().getCheckpoint().getWindowScn(), 80L, "WindowSCN check");
        Assert.assertEquals(relayPuller.getConnectionState().getCheckpoint().getWindowOffset(), new Long(-1), "WindowOffset check");
        Assert.assertEquals(relayPuller.getConnectionState().isSCNRegress(), true, "SCN Regress check");
      }

      // Register_Response_Success, No PrevSCN for partially consumed window
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        RelayPullThread relayPuller = bldr.createRelayPullThread();

        Checkpoint cp = new Checkpoint();
        cp.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
        cp.setWindowScn(100L);
        cp.setWindowOffset(20);
        relayPuller.getConnectionState().setCheckpoint(cp);
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS,StateId.REGISTER_RESPONSE_SUCCESS, "SUSPEND_ON_ERROR");
      }

      // Register_Response_Success to Bootstrap ( when checkpoint is Bootstrap_SnapShot
      {
        //RelayPullThread relayPuller = createRelayPullThread(false, false, true);
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true);
        RelayPullThread relayPuller = bldr.createRelayPullThread();

        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");

        Checkpoint cp = new Checkpoint();
        cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
        connState.setCheckpoint(cp);
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.BOOTSTRAP);
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        Assert.assertEquals(relayPuller.getConnectionState().isSCNRegress(), false, "SCN Regress check");
      }

      // Register_Response_Success to Bootstrap ( when checkpoint is Bootstrap_Catchup
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true);
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");

        Checkpoint cp = new Checkpoint();
        cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_CATCHUP);
        connState.setCheckpoint(cp);
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.BOOTSTRAP);
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        Assert.assertEquals(relayPuller.getConnectionState().isSCNRegress(), false, "SCN Regress check");
      }


      // Request_Stream to Request_Stream_Sent
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
        List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
        sourcesResponse.add(new IdNamePair(1L, "source1"));
        connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        String subsListString = "[{\"physicalSource\":{\"uri\":\"databus:physical-source:ANY\",\"role\":\"MASTER\"},\"physicalPartition\":{\"id\":-1,\"name\":\"*\"},\"logicalPartition\":{\"source\":{\"id\":0,\"name\":\"source1\"},\"id\":-1}}]";
        String sourcesIdListString = "1";
        connState.switchToRequestSourcesSchemas(sourcesIdListString, subsListString);
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_REQUEST_SENT,"");
        relayPuller.getMessageQueue().clear();
        MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
        connState.switchToRegisterSuccess(conn.getRegisterResponse(), conn.getRegisterResponse(), conn.getRegisterMetadataResponse());
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SENT, "");
              validateConnState(connState);
      }

      // Request_Stream to Stream_Response_Success
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
      }


      //Stream_Request_Success to Stream_Request_Done
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_DONE);
      }


      //Stream_Request_Success : ScnNotFoundException but retries set to 5 and  bootstrap enabled
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName()).setNumRetriesOnFellOff(5);
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();

        for ( int i = 1; i <= 6 ; i++)
        {
          System.out.println("Iteration :" + i);
          testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
          relayPuller.getMessageQueue().clear();
          if ( i < 6 )
          {
            testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.PICK_SERVER);
            Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 6-i ,"Retry State");
          } else {
            testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
            Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 5 ,"Retry State"); //reset
          }
          relayPuller.getMessageQueue().clear();
        }
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "RelayFellOff State");
      }

      //Stream_Request_Success : ScnNotFoundException and  bootstrap enabled
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
        RelayPullThread relayPuller = bldr.createRelayPullThread();

        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
      }

      //Stream_Request_Success : ScnNotFoundException but retries set to 5, bootstrap disabled and readLatestScnOnFallOff enabled.
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(false).setReadLatestScnEnabled(true).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName()).setNumRetriesOnFellOff(5);
        RelayPullThread relayPuller = bldr.createRelayPullThread();

        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        for (int i=1; i<=6;i++)
        {
          testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
          relayPuller.getMessageQueue().clear();
          if ( i < 6 )
          {
            testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.PICK_SERVER);
            Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 6-i ,"Retry State");
          } else {
            testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_DONE);
            Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 5 ,"Retry State"); //reset
          }
          relayPuller.getMessageQueue().clear();
        }
        MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
        Assert.assertEquals(conn.isReadFromLatestScn(),true, "ReadFromLatestScn set");
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "RelayFellOff State");

      }

      //Stream_Request_Success : ScnNotFoundException, bootstrap disabled and readLatestScnOnFallOff enabled.
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(false).setReadLatestScnEnabled(true).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_DONE);
        MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
        Assert.assertEquals(conn.isReadFromLatestScn(),true, "ReadFromLatestScn set");
      }

      //Stream_Request_Success : ScnNotFoundException but retries set to 5, bootstrap disabled and readLatestScnOnFallOff disabled.
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(false).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName()).setNumRetriesOnFellOff(5);
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        for (int i = 1; i <= 6; i++)
        {
          testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
          relayPuller.getMessageQueue().clear();
          testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
          relayPuller.getMessageQueue().clear();
          if ( i < 6 )
          {
            testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.PICK_SERVER);
            Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 6-i ,"Retry State");
          } else {
            testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_REQUEST_SUCCESS, "SUSPEND_ON_ERROR");
            Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 5 ,"Retry State"); //reset
          }
          relayPuller.getMessageQueue().clear();
        }
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "RelayFellOff State");

      }


      //Stream_Request_Success : ScnNotFoundException, bootstrap disabled and readLatestScnOnFallOff disabled.
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(false).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_REQUEST_SUCCESS, "SUSPEND_ON_ERROR");
      }

      //Stream_Request_Success : Non-ScnNotFoundException
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName("DummyError");
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_ERROR);
      }

      //Stream_Request_Done to Request_Stream
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_DONE);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_RESPONSE_DONE,StateId.REQUEST_STREAM);
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");
      }

      // Bootstrap to Bootstrap_Requested
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
        relayPuller.getMessageQueue().clear();
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP_REQUESTED,"");
      }

      //Exception while doBootstrap()
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(true)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
        relayPuller.getMessageQueue().clear();
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP, "SUSPEND_ON_ERROR");
      }

      // Bootstrap Failed : Case 1
      {
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
        relayPuller.getMessageQueue().clear();
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP_REQUESTED,"");
        BootstrapResultMessage msg = BootstrapResultMessage.createBootstrapFailedMessage(new Exception("Dummy"));
        doExecuteAndChangeState(relayPuller,msg);
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        Assert.assertEquals(connState.getStateId(),StateId.BOOTSTRAP, "BOOTSTRAP_REQUESTED to BOOTSTRAP");
        Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [BOOTSTRAP]", "Queue :BOOTSTRAP_REQUESTED to BOOTSTRAP");
      }

      // Bootstrap Failed : Case 2
      {
        //RelayPullThread relayPuller = createRelayPullThread(false, false, true, false, false, true, ScnNotFoundException.class.getName());
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
        relayPuller.getMessageQueue().clear();
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP_REQUESTED,"");
        BootstrapResultMessage msg = BootstrapResultMessage.createBootstrapCompleteMessage(null);
        doExecuteAndChangeState(relayPuller,msg);
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        Assert.assertEquals(connState.getStateId(),StateId.BOOTSTRAP, "BOOTSTRAP_REQUESTED to BOOTSTRAP");
        Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [BOOTSTRAP]", "Queue :BOOTSTRAP_REQUESTED to BOOTSTRAP");
      }

      // Bootstrap Success
      {
        //RelayPullThread relayPuller = createRelayPullThread(false, false, true, false, false, true, ScnNotFoundException.class.getName());
        RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
        bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
        .setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
        RelayPullThread relayPuller = bldr.createRelayPullThread();
        relayPuller.getComponentStatus().start();
        ConnectionState connState = relayPuller.getConnectionState();
        connState.switchToPickServer();
        testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
        relayPuller.getMessageQueue().clear();
        testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
        relayPuller.getMessageQueue().clear();
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
        testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP_REQUESTED,"");
        BootstrapResultMessage msg = BootstrapResultMessage.createBootstrapCompleteMessage(new Checkpoint());
        doExecuteAndChangeState(relayPuller,msg);
        Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");
        Assert.assertEquals(connState.getStateId(),StateId.REQUEST_STREAM, "BOOTSTRAP_REQUESTED to REQUEST_STREAM");
        Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [REQUEST_STREAM]", "Queue :BOOTSTRAP_REQUESTED to REQUEST_STREAM");
      }
View Full Code Here

          Assert.assertEquals(connState.getStateId(),StateId.BOOTSTRAP_REQUESTED, "ServerSetChange while BOOTSTRAP");
          Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: []", "Queue :ServerSetChange while BOOTSTRAP");
          Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Relay FellOff CHeck");

          // Now Response arrives
          BootstrapResultMessage msg = BootstrapResultMessage.createBootstrapCompleteMessage(new Checkpoint());
          doExecuteAndChangeState(relayPuller,msg);
          Assert.assertEquals(connState.getStateId(),StateId.PICK_SERVER, "BOOTSTRAP_REQUESTED to PICK_SERVER");
          Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [PICK_SERVER]", "Queue :BOOTSTRAP_REQUESTED to REQUEST_STREAM");
          Assert.assertEquals(relayPuller.toTearConnAfterHandlingResponse(), false, "Tear Conn After Handling Response");
          Assert.assertEquals(relayPuller.getCurrentServerIdx() == -1, true, "Current Server Index undefined");
View Full Code Here

  {
    TestAbstractQueue queue = new TestAbstractQueue();
    TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
    DefaultHttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
    Checkpoint cp = new Checkpoint();
    cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
    BootstrapStartScnHttpResponseProcessor  processor =
        new BootstrapStartScnHttpResponseProcessor(null, queue, stateMsg, cp, remoteExHandler,
                                                   null);
    ChannelBuffer buf = getScnResponse();
    HttpChunk httpChunk = new DefaultHttpChunk(buf);
    HttpChunkTrailer httpChunkTrailer = new DefaultHttpChunkTrailer();

    processor.startResponse(httpResponse);
    processor.addChunk(httpChunk);
    processor.addTrailer(httpChunkTrailer);
    processor.finishResponse();

    Assert.assertEquals("Error Handled", false, processor._errorHandled);
    Assert.assertEquals("Processor Response State", AbstractHttpResponseProcessorDecorator.ResponseStatus.CHUNKS_FINISHED,processor._responseStatus);
    Assert.assertEquals("Actor Queue Size", 1, queue.getMessages().size());
    Assert.assertEquals("Expected ConnectionStateMessage","TestConnectionStateMessage", queue.getMessages().get(0).getClass().getSimpleName());
    TestConnectionStateMessage gotMsg = (TestConnectionStateMessage)(queue.getMessages().get(0));
    Assert.assertEquals("Expected ConnectionStateMessage State", TestConnectionStateMessage.State.STARTSCN_RESPONSE_SUCCESS, gotMsg._state);
    Assert.assertEquals("StartSCN Response Id Check",new Long(5678912),cp.getBootstrapStartScn());
  }
View Full Code Here

  {
    TestAbstractQueue queue = new TestAbstractQueue();
    TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
    DefaultHttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
    Checkpoint cp = new Checkpoint();
    cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
    BootstrapStartScnHttpResponseProcessor  processor =
        new BootstrapStartScnHttpResponseProcessor(null, queue, stateMsg, cp, remoteExHandler,
                                                   null);
    ChannelBuffer buf = getScnResponse();
    httpResponse.setContent(buf);
    httpResponse.setHeader(HttpHeaders.Names.CONTENT_LENGTH,"1000");
    processor.startResponse(httpResponse);
    processor.finishResponse();


    Assert.assertEquals("Error Handled", false, processor._errorHandled);
    Assert.assertEquals("Processor Response State", AbstractHttpResponseProcessorDecorator.ResponseStatus.CHUNKS_FINISHED,processor._responseStatus);
    Assert.assertEquals("Actor Queue Size", 1, queue.getMessages().size());
    Assert.assertEquals("Expected ConnectionStateMessage","TestConnectionStateMessage", queue.getMessages().get(0).getClass().getSimpleName());
    TestConnectionStateMessage gotMsg = (TestConnectionStateMessage)(queue.getMessages().get(0));
    System.out.println("Long Max is :" + Long.MAX_VALUE);
    Assert.assertEquals("Expected ConnectionStateMessage State", TestConnectionStateMessage.State.STARTSCN_RESPONSE_SUCCESS, gotMsg._state);
    Assert.assertEquals("StartSCN Response Id Check",new Long(5678912),cp.getBootstrapStartScn());
  }
View Full Code Here

    TestAbstractQueue queue = new TestAbstractQueue();
    TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
    DefaultHttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
    remoteExHandler._exType= ExceptionType.BOOTSTRAP_TOO_OLD_EXCEPTION;
    Checkpoint cp = new Checkpoint();
    cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
    BootstrapStartScnHttpResponseProcessor  processor =
        new BootstrapStartScnHttpResponseProcessor(null, queue, stateMsg, cp, remoteExHandler,
                                                   null);
    ChannelBuffer buf = getScnResponse();
    HttpChunk httpChunk = new DefaultHttpChunk(buf);
View Full Code Here

    TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
    DefaultHttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    httpResponse.setHeader(DatabusHttpHeaders.DATABUS_ERROR_CAUSE_CLASS_HEADER, "Other Dummy Error");
    TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
    remoteExHandler._exType= ExceptionType.OTHER_EXCEPTION;
    Checkpoint cp = new Checkpoint();
    cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
    BootstrapStartScnHttpResponseProcessor  processor =
        new BootstrapStartScnHttpResponseProcessor(null, queue, stateMsg, cp, remoteExHandler,
                                                   null);
    ChannelBuffer buf = getScnResponse();
    HttpChunk httpChunk = new DefaultHttpChunk(buf);
View Full Code Here

  {
    TestAbstractQueue queue = new TestAbstractQueue();
    TestConnectionStateMessage stateMsg = new TestConnectionStateMessage();
    HttpResponse httpResponse = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK);
    TestRemoteExceptionHandler remoteExHandler = new TestRemoteExceptionHandler();
    Checkpoint cp = new Checkpoint();
    cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
    BootstrapStartScnHttpResponseProcessor  processor =
        new BootstrapStartScnHttpResponseProcessor(null, queue, stateMsg, cp, remoteExHandler,
                                                   null);
    ChannelBuffer buf = getScnResponse();
    HttpChunk httpChunk = new DefaultHttpChunk(buf);
View Full Code Here

TOP

Related Classes of com.linkedin.databus.core.Checkpoint

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.