Package com.linkedin.databus.client.pub

Examples of com.linkedin.databus.client.pub.DatabusRegistration


      registerRelay(2, "relay2", new InetSocketAddress("localhost", 7777), "S1,S3", client);
      registerRelay(3, "relay1.1", new InetSocketAddress("localhost", 8887), "S1,S2", client);
      registerRelay(4, "relay3", new InetSocketAddress("localhost", 6666), "S3,S4,S5", client);

      TestConsumer listener1 = new TestConsumer();
      DatabusRegistration reg = client.register(listener1, "S1", "S3");

      assertEquals("Registered State", RegistrationState.REGISTERED,
          reg.getState());

      assertEquals("Component Name" , "Status_TestConsumer_a62d57a7", reg.getStatus().getComponentName());
      assertEquals("Component Status", Status.INITIALIZING, reg.getStatus().getStatus());


      // Start
      boolean started = reg.start();
      assertEquals("Started", true, started);
      assertEquals("Registered State", RegistrationState.STARTED, reg.getState());
      assertEquals("Component Status", Status.RUNNING, reg.getStatus().getStatus());
     
     
      //Start again
      started = reg.start();
      assertEquals("Started", false, started);
      assertEquals("Registered State", RegistrationState.STARTED, reg.getState());

      // Pause
      reg.pause();
      assertEquals("Registered State", RegistrationState.PAUSED, reg.getState());
      assertEquals("Component Status", Status.PAUSED, reg.getStatus().getStatus());

      // resume
      reg.resume();
      assertEquals("Registered State", RegistrationState.RESUMED, reg.getState());
      assertEquals("Component Status", Status.RUNNING, reg.getStatus().getStatus());

      // suspend due to error
      reg.suspendOnError(new Exception("dummy"));
      assertEquals("Registered State", RegistrationState.SUSPENDED_ON_ERROR, reg.getState());
      assertEquals("Component Status", Status.SUSPENDED_ON_ERROR, reg.getStatus().getStatus());

      // SHutdown
      reg.shutdown();
      assertEquals("Registered State", RegistrationState.SHUTDOWN, reg.getState());
      assertEquals("Component Status", Status.SHUTDOWN, reg.getStatus().getStatus());  
     
      // Duplicate regId
      DatabusRegistration reg2 = client.register(listener1, "S1", "S3");
      boolean isException = false;
      try
      {
        reg2.withRegId(reg.getRegistrationId());
      } catch (DatabusClientException ex) {
        isException = true;
      }

      assertEquals("Exception expected", true, isException);

      reg2.deregister();
      reg.deregister();
     
    } finally {
      if ( null != client)
        client.shutdown();
View Full Code Here


      registerRelay(2, "relay2", new InetSocketAddress("localhost", 7777), "S1,S3", client);
      registerRelay(3, "relay1.1", new InetSocketAddress("localhost", 8887), "S1,S2", client);
      registerRelay(4, "relay3", new InetSocketAddress("localhost", 6666), "S3,S4,S5", client);

      TestConsumer listener1 = new TestConsumer();
      DatabusRegistration reg = client.register(listener1, "S6", "S2");

      assertEquals("Registered State", RegistrationState.REGISTERED,
          reg.getState());

      assertEquals("Component Name" , "Status_TestConsumer_6fdc9d8d", reg.getStatus().getComponentName());
      assertEquals("Component Status", Status.INITIALIZING, reg.getStatus().getStatus());


      // Start
      boolean started = false;
      boolean gotException = false;
      try
      {
        started = reg.start();
      } catch (DatabusClientException ex) {
        gotException = true;
      }
     
      assertEquals("gotException", true, gotException);
      assertEquals("Registered State", RegistrationState.REGISTERED, reg.getState());
      assertEquals("Component Status", Status.INITIALIZING, reg.getStatus().getStatus());
     
      gotException = false;
      try
      {
        reg = client.register((AbstractDatabusCombinedConsumer)null, "S6", "S2");
      } catch (DatabusClientException ex) {
        gotException = true;
      }
      assertEquals("gotException", true, gotException);

      gotException = false;
      try
      {
        reg = client.register(listener1, null);
      } catch (DatabusClientException ex) {
        gotException = true;
      }
      assertEquals("gotException", true, gotException);
     
      if ( reg != null)
        reg.deregister();
     
    } finally {
      if ( null != client)
        client.shutdown();
    }
View Full Code Here

      List<DatabusCombinedConsumer> listeners = new ArrayList<DatabusCombinedConsumer>();
      listeners.add(listener1);
      listeners.add(listener2);

      DatabusRegistration reg = client.register(listeners, "S1", "S2");

      assertEquals("Registered State", RegistrationState.REGISTERED,
          reg.getState());

      assertEquals("Component Name" , "Status_TestConsumer_922c5e28", reg.getStatus().getComponentName());
      assertEquals("Component Status", Status.INITIALIZING, reg.getStatus().getStatus());


      // Start
      boolean started = reg.start();
      assertEquals("Started", true, started);
      assertEquals("Registered State", RegistrationState.STARTED, reg.getState());
      assertEquals("Component Status", Status.RUNNING, reg.getStatus().getStatus());

      //Start again
      started = reg.start();
      assertEquals("Started", false, started);
      assertEquals("Registered State", RegistrationState.STARTED, reg.getState());

      // Pause
      reg.pause();
      assertEquals("Registered State", RegistrationState.PAUSED, reg.getState());
      assertEquals("Component Status", Status.PAUSED, reg.getStatus().getStatus());

      // resume
      reg.resume();
      assertEquals("Registered State", RegistrationState.RESUMED, reg.getState());
      assertEquals("Component Status", Status.RUNNING, reg.getStatus().getStatus());

      // suspend due to error
      reg.suspendOnError(new Exception("dummy"));
      assertEquals("Registered State", RegistrationState.SUSPENDED_ON_ERROR, reg.getState());
      assertEquals("Component Status", Status.SUSPENDED_ON_ERROR, reg.getStatus().getStatus());

      // SHutdown
      reg.shutdown();
      assertEquals("Registered State", RegistrationState.SHUTDOWN, reg.getState());
      assertEquals("Component Status", Status.SHUTDOWN, reg.getStatus().getStatus());  
     
     
      reg.deregister();
    } finally {
      if ( null != client )
        client.shutdown();
    }
  }
View Full Code Here

   */
  private RegInfo getV2PartitionRegistration(String cluster, long partition) throws RequestProcessingException
  {
    DatabusV2ClusterRegistrationImpl reg = getV2ClusterRegistration(cluster);
    DbusPartitionInfo p = new DbusPartitionInfoImpl(partition);
    DatabusRegistration r = reg.getPartitionRegs().get(p);

    if (null == r)
      throw new RequestProcessingException("Partition(" + partition + ") for cluster ("
          + cluster + ") not found !!");

    return new RegInfo(r.getState().name(),
                       r.getRegistrationId(),
                       r.getStatus(),
                       r.getFilterConfig(),
                       r.getSubscriptions());
  }
View Full Code Here

    if (_eventPattern != null)
    {
      consumer.setEventPattern(_eventPattern);
    }
    DatabusRegistration reg = client.register(consumer, sources);

    if (!(reg instanceof DatabusV2RegistrationImpl))
    {
      throw new RuntimeException("Unexpected type for registration Object !!");
    }

    if (null != filterConfig)
      reg.withServerSideFilter(filterConfig);

    // add pause processor
    try
    {
      client.getProcessorRegistry().register(ConsumerPauseRequestProcessor.COMMAND_NAME,
View Full Code Here

  }

  private void processInboundEventsRegistration(DatabusRequest request)
      throws IOException, RequestProcessingException
  {
    DatabusRegistration reg = findRegistration(request, INBOUND_EVENTS_REG_KEY_PREFIX);
    writeJsonObjectToResponse(reg.getRelayEventStats().getTotalStats(), request);
  }
View Full Code Here

  }

  private void processBootstrapEventsRegistration(DatabusRequest request)
      throws IOException, RequestProcessingException
  {
    DatabusRegistration reg = findRegistration(request, BOOTSTRAP_EVENTS_REG_KEY_PREFIX);
    writeJsonObjectToResponse(reg.getBootstrapEventStats().getTotalStats(), request);
  }
View Full Code Here

  }

  private void processInboundCallbacksRegistration(DatabusRequest request)
      throws IOException, RequestProcessingException
  {
    DatabusRegistration reg = findRegistration(request, INBOUND_CALLBACKS_REG_KEY_PREFIX);
    writeJsonObjectToResponse(reg.getRelayCallbackStats(), request);
  }
View Full Code Here

  }

  private void processBootstrapCallbacksRegistration(DatabusRequest request)
      throws IOException, RequestProcessingException
  {
    DatabusRegistration reg = findRegistration(request, BOOTSTRAP_CALLBACKS_REG_KEY_PREFIX);
    writeJsonObjectToResponse(reg.getBootstrapCallbackStats(), request);
  }
View Full Code Here

  }

  private void processUnifiedRegistration(DatabusRequest request)
      throws IOException, RequestProcessingException
  {
    DatabusRegistration reg = findRegistration(request, UNIFIED_REG_KEY_PREFIX);
    writeJsonObjectToResponse(reg.getUnifiedClientStats(), request);
  }
View Full Code Here

TOP

Related Classes of com.linkedin.databus.client.pub.DatabusRegistration

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.