Search in sources :

Example 21 with DatabusRegistration

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

the class TestDatabusV2RegistrationImpl method testErrorRegistration.

@Test
public void testErrorRegistration() 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, "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();
    }
}
Also used : DatabusRegistration(com.linkedin.databus.client.pub.DatabusRegistration) InetSocketAddress(java.net.InetSocketAddress) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) AbstractDatabusCombinedConsumer(com.linkedin.databus.client.consumer.AbstractDatabusCombinedConsumer) 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