Search in sources :

Example 6 with DbusEventV2Factory

use of com.linkedin.databus.core.DbusEventV2Factory in project databus by linkedin.

the class TestNettyHttpDatabusBootstrapConnection method setUpClass.

@BeforeClass
public void setUpClass() throws InvalidConfigException {
    TestUtil.setupLoggingWithTimestampedFile(true, "/tmp/TestNettyHttpDatabusBootstrapConnection_", ".log", Level.INFO);
    InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
    _dummyServer = new SimpleTestServerConnection(new DbusEventV2Factory().getByteOrder(), SimpleTestServerConnection.ServerType.NIO);
    _dummyServer.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG), new HttpServerCodec(), new LoggingHandler(InternalLogLevel.DEBUG), new SimpleObjectCaptureHandler());
        }
    });
    _dummyServer.start(SERVER_ADDRESS_ID);
    DatabusHttpClientImpl.Config clientCfgBuilder = new DatabusHttpClientImpl.Config();
    clientCfgBuilder.getContainer().setReadTimeoutMs(DEFAULT_READ_TIMEOUT_MS);
    clientCfgBuilder.getContainer().setWriteTimeoutMs(DEFAULT_WRITE_TIMEOUT_MS);
    CONN_FACTORY = new NettyHttpConnectionFactory(BOSS_POOL, IO_POOL, null, NETWORK_TIMER, clientCfgBuilder.getContainer().getWriteTimeoutMs(), clientCfgBuilder.getContainer().getReadTimeoutMs(), clientCfgBuilder.getContainer().getBstReadTimeoutMs(), // protocolVersion
    4, MAX_EVENT_VERSION, TEST_CHANNELS_GROUP);
}
Also used : LoggingHandler(org.jboss.netty.handler.logging.LoggingHandler) SimpleTestServerConnection(com.linkedin.databus2.test.container.SimpleTestServerConnection) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) SimpleObjectCaptureHandler(com.linkedin.databus2.test.container.SimpleObjectCaptureHandler) HttpServerCodec(org.jboss.netty.handler.codec.http.HttpServerCodec) Log4JLoggerFactory(org.jboss.netty.logging.Log4JLoggerFactory) DbusEventV2Factory(com.linkedin.databus.core.DbusEventV2Factory) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) BeforeClass(org.testng.annotations.BeforeClass)

Example 7 with DbusEventV2Factory

use of com.linkedin.databus.core.DbusEventV2Factory in project databus by linkedin.

the class TestDatabusV2ClusterRegistrationImpl method setUpClass.

@BeforeClass
public void setUpClass() throws InvalidConfigException {
    //setup logging
    TestUtil.setupLogging(true, null, Level.INFO);
    InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
    //initialize relays
    for (int relayN = 0; relayN < RELAY_PORT.length; ++relayN) {
        _dummyServer[relayN] = new SimpleTestServerConnection(new DbusEventV2Factory().getByteOrder(), SimpleTestServerConnection.ServerType.NIO);
        _dummyServer[relayN].setPipelineFactory(new ChannelPipelineFactory() {

            @Override
            public ChannelPipeline getPipeline() throws Exception {
                return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG), new HttpServerCodec(), new LoggingHandler(InternalLogLevel.DEBUG), new SimpleObjectCaptureHandler());
            }
        });
        _dummyServer[relayN].start(RELAY_PORT[relayN]);
    }
    //create standard client config
    DatabusHttpClientImpl.Config clientCfgBuilder = new DatabusHttpClientImpl.Config();
    clientCfgBuilder.getContainer().setHttpPort(CLIENT_PORT);
    clientCfgBuilder.getContainer().getJmx().setRmiEnabled(false);
    clientCfgBuilder.getContainer().setReadTimeoutMs(10000000);
    clientCfgBuilder.getConnectionDefaults().getPullerRetries().setInitSleep(10);
    clientCfgBuilder.getRuntime().getBootstrap().setEnabled(false);
    clientCfgBuilder.getCheckpointPersistence().setClearBeforeUse(true);
    for (int i = 0; i < RELAY_PORT.length; ++i) {
        clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setHost("localhost");
        clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setPort(RELAY_PORT[i]);
        clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setSources(SOURCE1_NAME);
    }
    _stdClientCfgBuilder = clientCfgBuilder;
    _stdClientCfg = clientCfgBuilder.build();
    //create standard relay buffer config
    DbusEventBuffer.Config bufCfgBuilder = new DbusEventBuffer.Config();
    bufCfgBuilder.setAllocationPolicy(AllocationPolicy.HEAP_MEMORY.toString());
    bufCfgBuilder.setMaxSize(100000);
    bufCfgBuilder.setScnIndexSize(128);
    bufCfgBuilder.setAverageEventSize(1);
    _bufCfg = bufCfgBuilder.build();
}
Also used : LoggingHandler(org.jboss.netty.handler.logging.LoggingHandler) DbusKeyCompositeFilterConfig(com.linkedin.databus2.core.filter.DbusKeyCompositeFilterConfig) StaticConfig(com.linkedin.databus.client.pub.ClusterCheckpointPersistenceProvider.StaticConfig) SimpleTestServerConnection(com.linkedin.databus2.test.container.SimpleTestServerConnection) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) DbusEventBuffer(com.linkedin.databus.core.DbusEventBuffer) SimpleObjectCaptureHandler(com.linkedin.databus2.test.container.SimpleObjectCaptureHandler) HttpServerCodec(org.jboss.netty.handler.codec.http.HttpServerCodec) Log4JLoggerFactory(org.jboss.netty.logging.Log4JLoggerFactory) DbusEventV2Factory(com.linkedin.databus.core.DbusEventV2Factory) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) BeforeClass(org.testng.annotations.BeforeClass)

Example 8 with DbusEventV2Factory

use of com.linkedin.databus.core.DbusEventV2Factory in project databus by linkedin.

the class TestDatabusV2RegistrationImpl method setUpClass.

@BeforeClass
public void setUpClass() throws InvalidConfigException {
    //setup logging
    TestUtil.setupLogging(true, null, Level.INFO);
    InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
    //initialize relays
    for (int relayN = 0; relayN < RELAY_PORT.length; ++relayN) {
        _dummyServer[relayN] = new SimpleTestServerConnection(new DbusEventV2Factory().getByteOrder(), SimpleTestServerConnection.ServerType.NIO);
        _dummyServer[relayN].setPipelineFactory(new ChannelPipelineFactory() {

            @Override
            public ChannelPipeline getPipeline() throws Exception {
                return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG), new HttpServerCodec(), new LoggingHandler(InternalLogLevel.DEBUG), new SimpleObjectCaptureHandler());
            }
        });
        _dummyServer[relayN].start(RELAY_PORT[relayN]);
    }
    //create standard client config
    DatabusHttpClientImpl.Config clientCfgBuilder = new DatabusHttpClientImpl.Config();
    clientCfgBuilder.getContainer().setHttpPort(CLIENT_PORT);
    clientCfgBuilder.getContainer().getJmx().setRmiEnabled(false);
    clientCfgBuilder.getContainer().setReadTimeoutMs(10000000);
    clientCfgBuilder.getConnectionDefaults().getPullerRetries().setInitSleep(10);
    clientCfgBuilder.getRuntime().getBootstrap().setEnabled(false);
    clientCfgBuilder.getCheckpointPersistence().setClearBeforeUse(true);
    for (int i = 0; i < RELAY_PORT.length; ++i) {
        clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setHost("localhost");
        clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setPort(RELAY_PORT[i]);
        clientCfgBuilder.getRuntime().getRelay(Integer.toString(i)).setSources(SOURCE1_NAME);
    }
    _stdClientCfgBuilder = clientCfgBuilder;
    _stdClientCfg = clientCfgBuilder.build();
    //create standard relay buffer config
    DbusEventBuffer.Config bufCfgBuilder = new DbusEventBuffer.Config();
    bufCfgBuilder.setAllocationPolicy(AllocationPolicy.HEAP_MEMORY.toString());
    bufCfgBuilder.setMaxSize(100000);
    bufCfgBuilder.setScnIndexSize(128);
    bufCfgBuilder.setAverageEventSize(1);
    _bufCfg = bufCfgBuilder.build();
}
Also used : LoggingHandler(org.jboss.netty.handler.logging.LoggingHandler) SimpleTestServerConnection(com.linkedin.databus2.test.container.SimpleTestServerConnection) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) DatabusClientException(com.linkedin.databus.client.pub.DatabusClientException) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) DbusEventBuffer(com.linkedin.databus.core.DbusEventBuffer) SimpleObjectCaptureHandler(com.linkedin.databus2.test.container.SimpleObjectCaptureHandler) HttpServerCodec(org.jboss.netty.handler.codec.http.HttpServerCodec) Log4JLoggerFactory(org.jboss.netty.logging.Log4JLoggerFactory) DbusEventV2Factory(com.linkedin.databus.core.DbusEventV2Factory) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) BeforeClass(org.testng.annotations.BeforeClass)

Example 9 with DbusEventV2Factory

use of com.linkedin.databus.core.DbusEventV2Factory in project databus by linkedin.

the class DummyRemoteExceptionHandler method setUpClass.

@BeforeClass
public void setUpClass() throws InvalidConfigException {
    TestUtil.setupLoggingWithTimestampedFile(true, "/tmp/TestNettyHttpDatabusRelayConnection_", ".log", Level.INFO);
    InternalLoggerFactory.setDefaultFactory(new Log4JLoggerFactory());
    _dummyServer = new SimpleTestServerConnection(new DbusEventV2Factory().getByteOrder(), SimpleTestServerConnection.ServerType.NIO);
    _dummyServer.setPipelineFactory(new ChannelPipelineFactory() {

        @Override
        public ChannelPipeline getPipeline() throws Exception {
            return Channels.pipeline(new LoggingHandler(InternalLogLevel.DEBUG), new HttpServerCodec(), new LoggingHandler(InternalLogLevel.DEBUG), new SimpleObjectCaptureHandler());
        }
    });
    _dummyServer.start(SERVER_ADDRESS_ID);
    DatabusHttpClientImpl.Config clientCfgBuilder = new DatabusHttpClientImpl.Config();
    clientCfgBuilder.getContainer().setReadTimeoutMs(DEFAULT_READ_TIMEOUT_MS);
    clientCfgBuilder.getContainer().setWriteTimeoutMs(DEFAULT_WRITE_TIMEOUT_MS);
    CONN_FACTORY = new NettyHttpConnectionFactory(BOSS_POOL, IO_POOL, null, NETWORK_TIMER, clientCfgBuilder.getContainer().getWriteTimeoutMs(), clientCfgBuilder.getContainer().getReadTimeoutMs(), clientCfgBuilder.getContainer().getBstReadTimeoutMs(), // protocolVersion
    4, MAX_EVENT_VERSION, TEST_CHANNELS_GROUP);
    DbusEventBuffer.Config bufCfgBuilder = new DbusEventBuffer.Config();
    bufCfgBuilder.setAllocationPolicy(AllocationPolicy.HEAP_MEMORY.toString());
    bufCfgBuilder.setMaxSize(100000);
    bufCfgBuilder.setScnIndexSize(128);
    bufCfgBuilder.setAverageEventSize(1);
    _bufCfg = bufCfgBuilder.build();
    initSchemaObjectsLists();
    _fullV4ResponseMap = new HashMap<String, List<Object>>();
    _fullV4ResponseMap.put(RegisterResponseEntry.SOURCE_SCHEMAS_KEY, _sourceObjectsList);
    _fullV4ResponseMap.put(RegisterResponseEntry.KEY_SCHEMAS_KEY, _keyObjectsList);
    _fullV4ResponseMap.put(RegisterResponseMetadataEntry.METADATA_SCHEMAS_KEY, _metadataObjectsList);
}
Also used : LoggingHandler(org.jboss.netty.handler.logging.LoggingHandler) SimpleTestServerConnection(com.linkedin.databus2.test.container.SimpleTestServerConnection) DatabusHttpClientImpl(com.linkedin.databus.client.DatabusHttpClientImpl) InvalidEventException(com.linkedin.databus.core.InvalidEventException) ScnNotFoundException(com.linkedin.databus.core.ScnNotFoundException) OffsetNotFoundException(com.linkedin.databus.core.OffsetNotFoundException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) JsonGenerationException(org.codehaus.jackson.JsonGenerationException) JsonMappingException(org.codehaus.jackson.map.JsonMappingException) IOException(java.io.IOException) ChannelPipeline(org.jboss.netty.channel.ChannelPipeline) DbusEventBuffer(com.linkedin.databus.core.DbusEventBuffer) SimpleObjectCaptureHandler(com.linkedin.databus2.test.container.SimpleObjectCaptureHandler) HttpServerCodec(org.jboss.netty.handler.codec.http.HttpServerCodec) List(java.util.List) ArrayList(java.util.ArrayList) Log4JLoggerFactory(org.jboss.netty.logging.Log4JLoggerFactory) DbusEventV2Factory(com.linkedin.databus.core.DbusEventV2Factory) ChannelPipelineFactory(org.jboss.netty.channel.ChannelPipelineFactory) BeforeClass(org.testng.annotations.BeforeClass)

Example 10 with DbusEventV2Factory

use of com.linkedin.databus.core.DbusEventV2Factory in project databus by linkedin.

the class DbusEventAppender method addBootstrapCheckpointEventToBuffer.

public void addBootstrapCheckpointEventToBuffer(long lastScn, long dataEventCount, int numCheckpoints) {
    Checkpoint cp = (_bootstrapCheckpoint == null) ? _bstCheckpointHandler.createInitialBootstrapCheckpoint(null, 0L) : _bootstrapCheckpoint;
    if (cp.getBootstrapStartScn() == Checkpoint.UNSET_BOOTSTRAP_START_SCN) {
        cp.setBootstrapStartScn(0L);
    }
    cp.setWindowScn(lastScn);
    cp.setSnapshotOffset(dataEventCount);
    DbusEventInternalReadable ev = new DbusEventV2Factory().createCheckpointEvent(cp);
    ByteBuffer b = ev.value();
    byte[] bytes = new byte[b.remaining()];
    b.get(bytes);
    for (int i = 0; i < numCheckpoints; ++i) {
        _buffer.appendEvent(new DbusEventKey(ev.key()), ev.physicalPartitionId(), ev.logicalPartitionId(), ev.timestampInNanos(), ev.srcId(), ev.schemaId(), bytes, false, _stats);
    }
}
Also used : Checkpoint(com.linkedin.databus.core.Checkpoint) DbusEventInternalReadable(com.linkedin.databus.core.DbusEventInternalReadable) DbusEventKey(com.linkedin.databus.core.DbusEventKey) DbusEventV2Factory(com.linkedin.databus.core.DbusEventV2Factory) ByteBuffer(java.nio.ByteBuffer) Checkpoint(com.linkedin.databus.core.Checkpoint)

Aggregations

DbusEventV2Factory (com.linkedin.databus.core.DbusEventV2Factory)12 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)7 InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)5 DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)4 SimpleObjectCaptureHandler (com.linkedin.databus2.test.container.SimpleObjectCaptureHandler)4 SimpleTestServerConnection (com.linkedin.databus2.test.container.SimpleTestServerConnection)4 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)4 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)4 HttpServerCodec (org.jboss.netty.handler.codec.http.HttpServerCodec)4 LoggingHandler (org.jboss.netty.handler.logging.LoggingHandler)4 Log4JLoggerFactory (org.jboss.netty.logging.Log4JLoggerFactory)4 BeforeClass (org.testng.annotations.BeforeClass)4 ServerInfo (com.linkedin.databus.client.pub.ServerInfo)3 Checkpoint (com.linkedin.databus.core.Checkpoint)3 DbusEventFactory (com.linkedin.databus.core.DbusEventFactory)3 DbusEventInternalReadable (com.linkedin.databus.core.DbusEventInternalReadable)3 DatabusSubscription (com.linkedin.databus.core.data_model.DatabusSubscription)3 DbusKeyCompositeFilterConfig (com.linkedin.databus2.core.filter.DbusKeyCompositeFilterConfig)3 LoggingConsumer (com.linkedin.databus.client.consumer.LoggingConsumer)2 RemoteExceptionHandler (com.linkedin.databus.client.netty.RemoteExceptionHandler)2