Search in sources :

Example 6 with DatabusRegistration

use of com.linkedin.databus.client.pub.DatabusRegistration in project databus by linkedin.

the class ClientStatsRequestProcessor method processUnifiedRegistration.

private void processUnifiedRegistration(DatabusRequest request) throws IOException, RequestProcessingException {
    DatabusRegistration reg = findRegistration(request, UNIFIED_REG_KEY_PREFIX);
    writeJsonObjectToResponse(reg.getUnifiedClientStats(), request);
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration)

Example 7 with DatabusRegistration

use of com.linkedin.databus.client.pub.DatabusRegistration in project databus by linkedin.

the class ClientStatsRequestProcessor method processInboundCallbacksRegistration.

private void processInboundCallbacksRegistration(DatabusRequest request) throws IOException, RequestProcessingException {
    DatabusRegistration reg = findRegistration(request, INBOUND_CALLBACKS_REG_KEY_PREFIX);
    writeJsonObjectToResponse(reg.getRelayCallbackStats(), request);
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration)

Example 8 with DatabusRegistration

use of com.linkedin.databus.client.pub.DatabusRegistration in project databus by linkedin.

the class ClientStatsRequestProcessor method processBootstrapCallbacksRegistration.

private void processBootstrapCallbacksRegistration(DatabusRequest request) throws IOException, RequestProcessingException {
    DatabusRegistration reg = findRegistration(request, BOOTSTRAP_CALLBACKS_REG_KEY_PREFIX);
    writeJsonObjectToResponse(reg.getBootstrapCallbackStats(), request);
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration)

Example 9 with DatabusRegistration

use of com.linkedin.databus.client.pub.DatabusRegistration in project databus by linkedin.

the class TestDatabusV2RegistrationImpl method testMultiConsumerRegistrationOps.

@Test
public void testMultiConsumerRegistrationOps() throws Exception {
    DatabusHttpClientImpl client = null;
    try {
        DatabusHttpClientImpl.Config clientConfig = new DatabusHttpClientImpl.Config();
        clientConfig.getContainer().getJmx().setRmiEnabled(false);
        clientConfig.getContainer().setHttpPort(12003);
        client = new DatabusHttpClientImpl(clientConfig);
        registerRelay(1, "relay1", new InetSocketAddress("localhost", 8888), "S1,S2", client);
        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();
        TestConsumer listener2 = new TestConsumer();
        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();
    }
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration) InetSocketAddress(java.net.InetSocketAddress) ArrayList(java.util.ArrayList) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) DatabusCombinedConsumer(com.linkedin.databus.client.pub.DatabusCombinedConsumer) AbstractDatabusCombinedConsumer(com.linkedin.databus.client.consumer.AbstractDatabusCombinedConsumer) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException) Test(org.testng.annotations.Test)

Example 10 with DatabusRegistration

use of com.linkedin.databus.client.pub.DatabusRegistration in project databus by linkedin.

the class TestDatabusV2RegistrationImpl method testOneConsumerRegistrationOps.

@Test
public void testOneConsumerRegistrationOps() throws Exception {
    DatabusHttpClientImpl client = null;
    try {
        DatabusHttpClientImpl.Config clientConfig = new DatabusHttpClientImpl.Config();
        clientConfig.getContainer().getJmx().setRmiEnabled(false);
        clientConfig.getContainer().setHttpPort(12003);
        client = new DatabusHttpClientImpl(clientConfig);
        registerRelay(1, "relay1", new InetSocketAddress("localhost", 8888), "S1,S2", client);
        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();
    }
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration) InetSocketAddress(java.net.InetSocketAddress) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException) Test(org.testng.annotations.Test)

Aggregations

DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)21 DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)5 DatabusClientException (com.linkedin.databus.client.pub.DatabusClientException)5 DbusPartitionInfo (com.linkedin.databus.client.pub.DbusPartitionInfo)5 RegistrationId (com.linkedin.databus.client.pub.RegistrationId)5 RequestProcessingException (com.linkedin.databus2.core.container.request.RequestProcessingException)5 DatabusV3Registration (com.linkedin.databus.client.pub.DatabusV3Registration)4 ArrayList (java.util.ArrayList)4 DatabusMultiPartitionRegistration (com.linkedin.databus.client.registration.DatabusMultiPartitionRegistration)3 InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)3 InetSocketAddress (java.net.InetSocketAddress)3 Test (org.testng.annotations.Test)3 AbstractDatabusCombinedConsumer (com.linkedin.databus.client.consumer.AbstractDatabusCombinedConsumer)2 ServerInfoBuilder (com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder)2 DatabusV2ClusterRegistrationImpl (com.linkedin.databus.client.registration.DatabusV2ClusterRegistrationImpl)2 ConfigLoader (com.linkedin.databus.core.util.ConfigLoader)2 ContainerOperationProcessor (com.linkedin.databus2.core.container.request.ContainerOperationProcessor)2 ProcessorRegistrationConflictException (com.linkedin.databus2.core.container.request.ProcessorRegistrationConflictException)2 Properties (java.util.Properties)2 DatabusSourcesConnection (com.linkedin.databus.client.DatabusSourcesConnection)1