Search in sources :

Example 1 with ServerInfoBuilder

use of com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder in project databus by linkedin.

the class IntegratedDummyDatabusConsumer method initConn.

public void initConn(List<String> sources) throws IOException, InvalidConfigException, DatabusClientException, DatabusException {
    StringBuilder sourcesString = new StringBuilder();
    boolean firstSrc = true;
    for (String source : sources) {
        if (!firstSrc)
            sourcesString.append(",");
        firstSrc = false;
        sourcesString.append(source);
    }
    _fileBasedCallback.init();
    ArrayList<DatabusBootstrapConsumer> bootstrapCallbacks = new ArrayList<DatabusBootstrapConsumer>();
    bootstrapCallbacks.add(this);
    ArrayList<DatabusStreamConsumer> streamCallbacks = new ArrayList<DatabusStreamConsumer>();
    streamCallbacks.add(this);
    DatabusHttpClientImpl.Config clientConfigBuilder = new DatabusHttpClientImpl.Config();
    clientConfigBuilder.getContainer().getJmx().setJmxServicePort(5555);
    clientConfigBuilder.getContainer().setId(545454);
    clientConfigBuilder.getContainer().setHttpPort(8082);
    clientConfigBuilder.getCheckpointPersistence().setType(ProviderType.FILE_SYSTEM.toString());
    clientConfigBuilder.getCheckpointPersistence().getFileSystem().setRootDirectory("./integratedconsumer-checkpoints");
    clientConfigBuilder.getCheckpointPersistence().setClearBeforeUse(true);
    clientConfigBuilder.getRuntime().getBootstrap().setEnabled(true);
    DatabusSourcesConnection.Config srcDefaultConfig = new DatabusSourcesConnection.Config();
    srcDefaultConfig.setFreeBufferThreshold((int) (_maxEventBufferSize * 0.05));
    srcDefaultConfig.setCheckpointThresholdPct(80);
    // 60 sec before retries (unless disabled)
    srcDefaultConfig.setConsumerTimeBudgetMs(_useConsumerTimeout ? 60000 : 0);
    // max of 3 retries
    srcDefaultConfig.getDispatcherRetries().setMaxRetryNum(3);
    clientConfigBuilder.setConnectionDefaults(srcDefaultConfig);
    DbusEventBuffer.Config eventBufferConfig = clientConfigBuilder.getConnectionDefaults().getEventBuffer();
    eventBufferConfig.setMaxSize(_maxEventBufferSize);
    eventBufferConfig.setAverageEventSize(_maxReadBufferSize);
    // TODO: the following shall be used once we can set eventbuffer for bootstrap through the config builder (DDSDBUS-82)
    // For now, bootstrap buffer will use the same config as relay buffer.
    // clientConfigBuilder.getConnectionDefaults().
    DatabusHttpClientImpl.StaticConfig clientConfig = clientConfigBuilder.build();
    ServerInfoBuilder relayBuilder = clientConfig.getRuntime().getRelay("1");
    relayBuilder.setName("DefaultRelay");
    relayBuilder.setHost("localhost");
    relayBuilder.setPort(9000);
    relayBuilder.setSources(sourcesString.toString());
    ServerInfoBuilder bootstrapBuilder = clientConfig.getRuntime().getBootstrap().getService("2");
    bootstrapBuilder.setName("DefaultBootstrapServices");
    bootstrapBuilder.setHost("localhost");
    bootstrapBuilder.setPort(6060);
    bootstrapBuilder.setSources(sourcesString.toString());
    _dbusClient = new DatabusHttpClientImpl(clientConfig);
    _dbusClient.registerDatabusStreamListener(this, sources, null);
    _dbusClient.registerDatabusBootstrapListener(this, sources, null);
    // add pause processor
    try {
        _dbusClient.getProcessorRegistry().register(ConsumerPauseRequestProcessor.COMMAND_NAME, new ConsumerPauseRequestProcessor(null, this));
    } catch (ProcessorRegistrationConflictException e) {
        LOG.error("Failed to register " + ConsumerPauseRequestProcessor.COMMAND_NAME);
    }
}
Also used : DatabusStreamConsumer(com.linkedin.databus.client.pub.DatabusStreamConsumer) ConsumerPauseRequestProcessor(com.linkedin.databus.client.generic.ConsumerPauseRequestProcessor) ArrayList(java.util.ArrayList) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) DatabusBootstrapConsumer(com.linkedin.databus.client.pub.DatabusBootstrapConsumer) DatabusSourcesConnection(com.linkedin.databus.client.DatabusSourcesConnection) DbusEventBuffer(com.linkedin.databus.core.DbusEventBuffer) ServerInfoBuilder(com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder) ProcessorRegistrationConflictException(com.linkedin.databus2.core.container.request.ProcessorRegistrationConflictException)

Example 2 with ServerInfoBuilder

use of com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder in project databus by linkedin.

the class TestDatabusV2ClusterRegistrationImpl method registerRelay.

private ServerInfo registerRelay(int id, String name, InetSocketAddress addr, String sources, DatabusHttpClientImpl client) throws InvalidConfigException {
    RuntimeConfigBuilder rtConfigBuilder = (RuntimeConfigBuilder) client.getClientConfigManager().getConfigBuilder();
    ServerInfoBuilder relayConfigBuilder = rtConfigBuilder.getRelay(Integer.toString(id));
    relayConfigBuilder.setName(name);
    relayConfigBuilder.setHost(addr.getHostName());
    relayConfigBuilder.setPort(addr.getPort());
    relayConfigBuilder.setSources(sources);
    ServerInfo si = relayConfigBuilder.build();
    client.getClientConfigManager().setNewConfig(rtConfigBuilder.build());
    return si;
}
Also used : ServerInfo(com.linkedin.databus.client.pub.ServerInfo) RuntimeConfigBuilder(com.linkedin.databus.client.DatabusHttpClientImpl.RuntimeConfigBuilder) ServerInfoBuilder(com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder)

Example 3 with ServerInfoBuilder

use of com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder in project databus by linkedin.

the class TestDatabusV2RegistrationImpl method registerRelay.

private ServerInfo registerRelay(int id, String name, InetSocketAddress addr, String sources, DatabusHttpClientImpl client) throws InvalidConfigException {
    RuntimeConfigBuilder rtConfigBuilder = (RuntimeConfigBuilder) client.getClientConfigManager().getConfigBuilder();
    ServerInfoBuilder relayConfigBuilder = rtConfigBuilder.getRelay(Integer.toString(id));
    relayConfigBuilder.setName(name);
    relayConfigBuilder.setHost(addr.getHostName());
    relayConfigBuilder.setPort(addr.getPort());
    relayConfigBuilder.setSources(sources);
    ServerInfo si = relayConfigBuilder.build();
    client.getClientConfigManager().setNewConfig(rtConfigBuilder.build());
    return si;
}
Also used : ServerInfo(com.linkedin.databus.client.pub.ServerInfo) RuntimeConfigBuilder(com.linkedin.databus.client.DatabusHttpClientImpl.RuntimeConfigBuilder) ServerInfoBuilder(com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder)

Example 4 with ServerInfoBuilder

use of com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder in project databus by linkedin.

the class DummySuccessfulErrorCountingConsumer method registerRelay.

private ServerInfo registerRelay(int id, String name, InetSocketAddress addr, String sources, DatabusHttpClientImpl client) throws InvalidConfigException {
    RuntimeConfigBuilder rtConfigBuilder = (RuntimeConfigBuilder) client.getClientConfigManager().getConfigBuilder();
    ServerInfoBuilder relayConfigBuilder = rtConfigBuilder.getRelay(Integer.toString(id));
    relayConfigBuilder.setName(name);
    relayConfigBuilder.setHost(addr.getHostName());
    relayConfigBuilder.setPort(addr.getPort());
    relayConfigBuilder.setSources(sources);
    ServerInfo si = relayConfigBuilder.build();
    client.getClientConfigManager().setNewConfig(rtConfigBuilder.build());
    return si;
}
Also used : ServerInfo(com.linkedin.databus.client.pub.ServerInfo) RuntimeConfigBuilder(com.linkedin.databus.client.DatabusHttpClientImpl.RuntimeConfigBuilder) ServerInfoBuilder(com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder)

Example 5 with ServerInfoBuilder

use of com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder in project databus by linkedin.

the class TestServerInfo method testBuilderSetAddressWithName.

@Test
public void testBuilderSetAddressWithName() throws Exception {
    ServerInfoBuilder builder = new ServerInfoBuilder();
    String address = ServerInfoBuilder.generateAddress("SeRvEr", "localhost", 99, "com.linkedin.events.source1", "com.linkedin.events.source3");
    builder.setAddress(address);
    ServerInfo si = builder.build();
    assertEquals("SeRvEr", si.getName());
    assertEquals(99, si.getAddress().getPort());
    assertEquals(2, si.getSources().size());
    assertEquals("com.linkedin.events.source1", si.getSources().get(0));
    assertEquals("com.linkedin.events.source3", si.getSources().get(1));
}
Also used : ServerInfoBuilder(com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder) Test(org.testng.annotations.Test)

Aggregations

ServerInfoBuilder (com.linkedin.databus.client.pub.ServerInfo.ServerInfoBuilder)11 ServerInfo (com.linkedin.databus.client.pub.ServerInfo)5 DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)3 RuntimeConfigBuilder (com.linkedin.databus.client.DatabusHttpClientImpl.RuntimeConfigBuilder)3 ProcessorRegistrationConflictException (com.linkedin.databus2.core.container.request.ProcessorRegistrationConflictException)3 ArrayList (java.util.ArrayList)3 Test (org.testng.annotations.Test)3 DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)2 ConfigLoader (com.linkedin.databus.core.util.ConfigLoader)2 ContainerOperationProcessor (com.linkedin.databus2.core.container.request.ContainerOperationProcessor)2 Properties (java.util.Properties)2 DatabusSourcesConnection (com.linkedin.databus.client.DatabusSourcesConnection)1 ConsumerPauseRequestProcessor (com.linkedin.databus.client.generic.ConsumerPauseRequestProcessor)1 DatabusBootstrapConsumer (com.linkedin.databus.client.pub.DatabusBootstrapConsumer)1 DatabusStreamConsumer (com.linkedin.databus.client.pub.DatabusStreamConsumer)1 ServerInfoSetBuilder (com.linkedin.databus.client.pub.ServerInfo.ServerInfoSetBuilder)1 DatabusV2RegistrationImpl (com.linkedin.databus.client.registration.DatabusV2RegistrationImpl)1 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)1 DbusKeyCompositeFilterConfig (com.linkedin.databus2.core.filter.DbusKeyCompositeFilterConfig)1 HashMap (java.util.HashMap)1