Search in sources :

Example 26 with InvalidConfigException

use of com.linkedin.databus.core.util.InvalidConfigException in project databus by linkedin.

the class TestClusterCheckpointPersistenceProvider method testClusterCheckpointPersistence.

@Test
public void testClusterCheckpointPersistence() {
    Checkpoint cp = new Checkpoint();
    cp.setWindowScn(50532L);
    cp.setWindowOffset(-1);
    cp.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
    String id = "4";
    String clusterName = "test-cluster-persistence";
    ClusterCheckpointPersistenceProvider.createCluster(zkAddr, clusterName);
    ClusterCheckpointPersistenceProvider.Config conf = new ClusterCheckpointPersistenceProvider.Config();
    conf.setClusterName(clusterName);
    conf.setZkAddr(zkAddr);
    ArrayList<String> sources = new ArrayList<String>(3);
    sources.add("source1");
    sources.add("source2");
    sources.add("source3");
    try {
        ClusterCheckpointPersistenceProvider ccp = new ClusterCheckpointPersistenceProvider(id, conf);
        ccp.storeCheckpoint(sources, cp);
        Checkpoint newCp = ccp.loadCheckpoint(sources);
        Assert.assertTrue(newCp != null);
        Assert.assertTrue(newCp.getWindowOffset() == cp.getWindowOffset());
        Assert.assertTrue(newCp.getWindowScn() == cp.getWindowScn());
        Assert.assertTrue(newCp.getConsumptionMode() == cp.getConsumptionMode());
    } catch (InvalidConfigException e) {
        System.err.println("Invalid config: " + e);
        Assert.assertTrue(false);
    } catch (IOException e) {
        System.err.println("Error storing checkpoint: " + e);
        Assert.assertTrue(false);
    } catch (ClusterCheckpointException e) {
        Assert.assertTrue(false);
    } finally {
        ClusterCheckpointPersistenceProvider.close(clusterName);
    }
}
Also used : Checkpoint(com.linkedin.databus.core.Checkpoint) ArrayList(java.util.ArrayList) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) IOException(java.io.IOException) ClusterCheckpointException(com.linkedin.databus.client.pub.ClusterCheckpointPersistenceProvider.ClusterCheckpointException) Test(org.testng.annotations.Test)

Example 27 with InvalidConfigException

use of com.linkedin.databus.core.util.InvalidConfigException 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 28 with InvalidConfigException

use of com.linkedin.databus.core.util.InvalidConfigException 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 29 with InvalidConfigException

use of com.linkedin.databus.core.util.InvalidConfigException in project databus by linkedin.

the class TestPhysicalSourceConfig method testPhysicalSourceConfig.

// test to see that we read and convert config correctly
@Test
public void testPhysicalSourceConfig() throws IOException {
    ObjectMapper mapper = new ObjectMapper();
    InputStreamReader isr = new InputStreamReader(IOUtils.toInputStream(_configSource));
    //PhysicalSourceConfig physicalSourceConfig = mapper.readValue(sourcesJson, PhysicalSourceConfig.class);
    PhysicalSourceConfig physicalSourceConfig = mapper.readValue(isr, PhysicalSourceConfig.class);
    PhysicalSourceStaticConfig pStatic = null;
    try {
        physicalSourceConfig.checkForNulls();
        pStatic = physicalSourceConfig.build();
    } catch (InvalidConfigException e) {
        fail("PhysicalSourceConfig.checkForNulls failed.", e);
    }
    // also assert basic stuff
    assertNotNull("Uri is null.", pStatic.getUri());
    assertNotNull("Name is null.", pStatic.getName());
    assertEquals(100, pStatic.getId(), "physical source id mismatch:");
    List<LogicalSourceConfig> lSources = physicalSourceConfig.getSources();
    assertEquals(4, lSources.size(), "number of logical sources");
    LogicalSourceStaticConfig lSource = null;
    try {
        lSource = lSources.get(0).build();
    } catch (InvalidConfigException e) {
        fail("get LogicalSourceStaticConfig failed", e);
    }
    assertEquals(2, lSource.getId(), "logical source id");
}
Also used : InputStreamReader(java.io.InputStreamReader) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) Test(org.testng.annotations.Test)

Aggregations

InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)29 DatabusException (com.linkedin.databus2.core.DatabusException)7 IOException (java.io.IOException)7 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)6 NoSuchSchemaException (com.linkedin.databus2.schemas.NoSuchSchemaException)6 ArrayList (java.util.ArrayList)6 DbusEventV2Factory (com.linkedin.databus.core.DbusEventV2Factory)5 SimpleObjectCaptureHandler (com.linkedin.databus2.test.container.SimpleObjectCaptureHandler)5 SimpleTestServerConnection (com.linkedin.databus2.test.container.SimpleTestServerConnection)5 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)5 ChannelPipelineFactory (org.jboss.netty.channel.ChannelPipelineFactory)5 HttpServerCodec (org.jboss.netty.handler.codec.http.HttpServerCodec)5 LoggingHandler (org.jboss.netty.handler.logging.LoggingHandler)5 Log4JLoggerFactory (org.jboss.netty.logging.Log4JLoggerFactory)5 BeforeClass (org.testng.annotations.BeforeClass)5 DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)4 UnsupportedKeyException (com.linkedin.databus.core.UnsupportedKeyException)4 OracleTriggerMonitoredSourceInfo (com.linkedin.databus2.producers.db.OracleTriggerMonitoredSourceInfo)4 Test (org.testng.annotations.Test)4 Checkpoint (com.linkedin.databus.core.Checkpoint)3