Search in sources :

Example 1 with ConfigLoader

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

the class BootstrapAvroFileSeederMain method init.

public static void init(String[] args) throws Exception {
    parseArgs(args);
    File sourcesJson = new File(_sSourcesConfigFile);
    ObjectMapper mapper = new ObjectMapper();
    PhysicalSourceConfig physicalSourceConfig = mapper.readValue(sourcesJson, PhysicalSourceConfig.class);
    physicalSourceConfig.checkForNulls();
    Config config = new Config();
    ConfigLoader<StaticConfig> configLoader = new ConfigLoader<StaticConfig>("databus.seed.", config);
    _sStaticConfig = configLoader.loadConfig(_sBootstrapConfigProps);
    // Make sure the URI from the configuration file identifies an Oracle JDBC source.
    String uri = physicalSourceConfig.getUri();
    if (!uri.startsWith("jdbc:oracle")) {
        throw new InvalidConfigException("Invalid source URI (" + physicalSourceConfig.getUri() + "). Only jdbc:oracle: URIs are supported.");
    }
    OracleEventProducerFactory factory = new BootstrapSeederOracleEventProducerFactory(_sStaticConfig.getController().getPKeyNameMap());
    // Parse each one of the logical sources
    _sources = new ArrayList<OracleTriggerMonitoredSourceInfo>();
    FileSystemSchemaRegistryService schemaRegistryService = FileSystemSchemaRegistryService.build(_sStaticConfig.getSchemaRegistry().getFileSystem());
    for (LogicalSourceConfig sourceConfig : physicalSourceConfig.getSources()) {
        OracleTriggerMonitoredSourceInfo source = factory.buildOracleMonitoredSourceInfo(sourceConfig.build(), physicalSourceConfig.build(), schemaRegistryService);
        _sources.add(source);
    }
    _sSeeder = new BootstrapDBSeeder(_sStaticConfig.getBootstrap(), _sources);
    _sBootstrapBuffer = new BootstrapEventBuffer(_sStaticConfig.getController().getCommitInterval() * 2);
    _sWriterThread = new BootstrapSeederWriterThread(_sBootstrapBuffer, _sSeeder);
    _sReader = new BootstrapAvroFileEventReader(_sStaticConfig.getController(), _sources, _sSeeder.getLastRows(), _sBootstrapBuffer);
}
Also used : LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) ConfigLoader(com.linkedin.databus.core.util.ConfigLoader) LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) SchemaRegistryStaticConfig(com.linkedin.databus2.schemas.SchemaRegistryStaticConfig) BootstrapConfig(com.linkedin.databus.bootstrap.common.BootstrapConfig) BootstrapReadOnlyConfig(com.linkedin.databus.bootstrap.common.BootstrapReadOnlyConfig) PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) SchemaRegistryStaticConfig(com.linkedin.databus2.schemas.SchemaRegistryStaticConfig) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) FileSystemSchemaRegistryService(com.linkedin.databus2.schemas.FileSystemSchemaRegistryService) OracleTriggerMonitoredSourceInfo(com.linkedin.databus2.producers.db.OracleTriggerMonitoredSourceInfo) PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) OracleEventProducerFactory(com.linkedin.databus2.relay.OracleEventProducerFactory) File(java.io.File) ObjectMapper(org.codehaus.jackson.map.ObjectMapper)

Example 2 with ConfigLoader

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

the class BootstrapHttpServer method main.

public static void main(String[] args) throws Exception {
    // use server container to pass the command line
    Properties startupProps = ServerContainer.processCommandLineArgs(args);
    BootstrapServerConfig config = new BootstrapServerConfig();
    ConfigLoader<BootstrapServerStaticConfig> configLoader = new ConfigLoader<BootstrapServerStaticConfig>("databus.bootstrap.", config);
    BootstrapServerStaticConfig staticConfig = configLoader.loadConfig(startupProps);
    BootstrapHttpServer bootstrapServer = new BootstrapHttpServer(staticConfig);
    // Bind and start to accept incoming connections.
    try {
        bootstrapServer.registerShutdownHook();
        bootstrapServer.startAndBlock();
    } catch (Exception e) {
        LOG.error("Error starting the bootstrap server", e);
    }
    LOG.info("Exiting bootstrap server");
}
Also used : ConfigLoader(com.linkedin.databus.core.util.ConfigLoader) Properties(java.util.Properties) DatabusException(com.linkedin.databus2.core.DatabusException) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) IOException(java.io.IOException) SQLException(java.sql.SQLException)

Example 3 with ConfigLoader

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

the class DatabusBootstrapProducer method main.

public static void main(String[] args) throws Exception {
    // Properties startupProps = BootstrapConfig.loadConfigProperties(args);
    Properties startupProps = ServerContainer.processCommandLineArgs(args);
    BootstrapProducerConfig producerConfig = new BootstrapProducerConfig();
    ConfigLoader<BootstrapProducerStaticConfig> staticProducerConfigLoader = new ConfigLoader<BootstrapProducerStaticConfig>("databus.bootstrap.", producerConfig);
    BootstrapProducerStaticConfig staticProducerConfig = staticProducerConfigLoader.loadConfig(startupProps);
    DatabusBootstrapProducer bootstrapProducer = new DatabusBootstrapProducer(staticProducerConfig);
    bootstrapProducer.registerShutdownHook();
    bootstrapProducer.startAndBlock();
}
Also used : ConfigLoader(com.linkedin.databus.core.util.ConfigLoader) Properties(java.util.Properties)

Example 4 with ConfigLoader

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

the class BootstrapDBCleanerMain method main.

/**
 * @param args
 */
public static void main(String[] args) throws Exception {
    parseArgs(args);
    BootstrapCleanerConfig config = new BootstrapCleanerConfig();
    BootstrapConfig bsConfig = new BootstrapConfig();
    ConfigLoader<BootstrapCleanerStaticConfig> configLoader = new ConfigLoader<BootstrapCleanerStaticConfig>("databus.bootstrap.cleaner.", config);
    ConfigLoader<BootstrapReadOnlyConfig> configLoader2 = new ConfigLoader<BootstrapReadOnlyConfig>("databus.bootstrap.db.", bsConfig);
    _sCleanerConfig = configLoader.loadConfig(_sBootstrapConfigProps);
    _sBootstrapConfig = configLoader2.loadConfig(_sBootstrapConfigProps);
    BootstrapDBCleaner cleaner = new BootstrapDBCleaner("StandAloneCleaner", _sCleanerConfig, _sBootstrapConfig, null, _sSources);
    cleaner.doClean();
}
Also used : BootstrapReadOnlyConfig(com.linkedin.databus.bootstrap.common.BootstrapReadOnlyConfig) BootstrapCleanerStaticConfig(com.linkedin.databus.bootstrap.common.BootstrapCleanerStaticConfig) BootstrapDBCleaner(com.linkedin.databus.bootstrap.common.BootstrapDBCleaner) ConfigLoader(com.linkedin.databus.core.util.ConfigLoader) BootstrapConfig(com.linkedin.databus.bootstrap.common.BootstrapConfig) BootstrapCleanerConfig(com.linkedin.databus.bootstrap.common.BootstrapCleanerConfig)

Example 5 with ConfigLoader

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

the class BootstrapSeederMain method init.

public static void init(String[] args) throws Exception {
    parseArgs(args);
    // Load the source configuration JSON file
    // File sourcesJson = new File("integration-test/config/sources-member2.json");
    File sourcesJson = new File(_sSourcesConfigFile);
    ObjectMapper mapper = new ObjectMapper();
    PhysicalSourceConfig physicalSourceConfig = mapper.readValue(sourcesJson, PhysicalSourceConfig.class);
    physicalSourceConfig.checkForNulls();
    Config config = new Config();
    ConfigLoader<StaticConfig> configLoader = new ConfigLoader<StaticConfig>("databus.seed.", config);
    _sStaticConfig = configLoader.loadConfig(_sBootstrapConfigProps);
    // Make sure the URI from the configuration file identifies an Oracle JDBC source.
    String uri = physicalSourceConfig.getUri();
    if (!uri.startsWith("jdbc:oracle")) {
        throw new InvalidConfigException("Invalid source URI (" + physicalSourceConfig.getUri() + "). Only jdbc:oracle: URIs are supported.");
    }
    String sourceTypeStr = physicalSourceConfig.getReplBitSetter().getSourceType();
    if (SourceType.TOKEN.toString().equalsIgnoreCase(sourceTypeStr))
        throw new InvalidConfigException("Token Source-type for Replication bit setter config cannot be set for trigger-based Databus relay !!");
    // Create the OracleDataSource used to get DB connection(s)
    try {
        Class oracleDataSourceClass = OracleJarUtils.loadClass("oracle.jdbc.pool.OracleDataSource");
        Object ods = oracleDataSourceClass.newInstance();
        Method setURLMethod = oracleDataSourceClass.getMethod("setURL", String.class);
        setURLMethod.invoke(ods, uri);
        _sDataStore = (DataSource) ods;
    } catch (Exception e) {
        String errMsg = "Error creating a data source object ";
        LOG.error(errMsg, e);
        throw e;
    }
    // TODO: Need a better way than relaying on RelayFactory for generating MonitoredSourceInfo
    OracleEventProducerFactory factory = new BootstrapSeederOracleEventProducerFactory(_sStaticConfig.getController().getPKeyNameMap());
    // Parse each one of the logical sources
    _sources = new ArrayList<OracleTriggerMonitoredSourceInfo>();
    FileSystemSchemaRegistryService schemaRegistryService = FileSystemSchemaRegistryService.build(_sStaticConfig.getSchemaRegistry().getFileSystem());
    Set<String> seenUris = new HashSet<String>();
    for (LogicalSourceConfig sourceConfig : physicalSourceConfig.getSources()) {
        String srcUri = sourceConfig.getUri();
        if (seenUris.contains(srcUri)) {
            String msg = "Uri (" + srcUri + ") is used for more than one sources. Currently Bootstrap Seeder cannot support seeding sources with the same URI together. Please have them run seperately !!";
            LOG.fatal(msg);
            throw new InvalidConfigException(msg);
        }
        seenUris.add(srcUri);
        OracleTriggerMonitoredSourceInfo source = factory.buildOracleMonitoredSourceInfo(sourceConfig.build(), physicalSourceConfig.build(), schemaRegistryService);
        _sources.add(source);
    }
    _sSeeder = new BootstrapDBSeeder(_sStaticConfig.getBootstrap(), _sources);
    _sBootstrapBuffer = new BootstrapEventBuffer(_sStaticConfig.getController().getCommitInterval() * 2);
    _sWriterThread = new BootstrapSeederWriterThread(_sBootstrapBuffer, _sSeeder);
    _sReader = new BootstrapSrcDBEventReader(_sDataStore, _sBootstrapBuffer, _sStaticConfig.getController(), _sources, _sSeeder.getLastRows(), _sSeeder.getLastKeys(), 0);
}
Also used : LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) LogicalSourceConfig(com.linkedin.databus2.relay.config.LogicalSourceConfig) SchemaRegistryStaticConfig(com.linkedin.databus2.schemas.SchemaRegistryStaticConfig) BootstrapConfig(com.linkedin.databus.bootstrap.common.BootstrapConfig) BootstrapReadOnlyConfig(com.linkedin.databus.bootstrap.common.BootstrapReadOnlyConfig) PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) FileSystemSchemaRegistryService(com.linkedin.databus2.schemas.FileSystemSchemaRegistryService) OracleTriggerMonitoredSourceInfo(com.linkedin.databus2.producers.db.OracleTriggerMonitoredSourceInfo) OracleEventProducerFactory(com.linkedin.databus2.relay.OracleEventProducerFactory) ObjectMapper(org.codehaus.jackson.map.ObjectMapper) HashSet(java.util.HashSet) ConfigLoader(com.linkedin.databus.core.util.ConfigLoader) SchemaRegistryStaticConfig(com.linkedin.databus2.schemas.SchemaRegistryStaticConfig) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) Method(java.lang.reflect.Method) InvalidConfigException(com.linkedin.databus.core.util.InvalidConfigException) IOException(java.io.IOException) ParseException(org.apache.commons.cli.ParseException) PhysicalSourceConfig(com.linkedin.databus2.relay.config.PhysicalSourceConfig) File(java.io.File)

Aggregations

ConfigLoader (com.linkedin.databus.core.util.ConfigLoader)21 Properties (java.util.Properties)14 BootstrapConfig (com.linkedin.databus.bootstrap.common.BootstrapConfig)6 BootstrapReadOnlyConfig (com.linkedin.databus.bootstrap.common.BootstrapReadOnlyConfig)6 DbusKeyCompositeFilterConfig (com.linkedin.databus2.core.filter.DbusKeyCompositeFilterConfig)6 DatabusHttpClientImpl (com.linkedin.databus.client.DatabusHttpClientImpl)3 LoggingConsumer (com.linkedin.databus.client.consumer.LoggingConsumer)3 RemoteExceptionHandler (com.linkedin.databus.client.netty.RemoteExceptionHandler)3 ServerInfo (com.linkedin.databus.client.pub.ServerInfo)3 DbusEventBuffer (com.linkedin.databus.core.DbusEventBuffer)3 AbstractActorMessageQueue (com.linkedin.databus.core.async.AbstractActorMessageQueue)3 ActorMessageQueue (com.linkedin.databus.core.async.ActorMessageQueue)3 DatabusSubscription (com.linkedin.databus.core.data_model.DatabusSubscription)3 DbusEventsStatisticsCollector (com.linkedin.databus.core.monitoring.mbean.DbusEventsStatisticsCollector)3 IdNamePair (com.linkedin.databus.core.util.IdNamePair)3 InvalidConfigException (com.linkedin.databus.core.util.InvalidConfigException)3 FileSystemSchemaRegistryService (com.linkedin.databus2.schemas.FileSystemSchemaRegistryService)3 ArrayList (java.util.ArrayList)3 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)3 DatabusRegistration (com.linkedin.databus.client.pub.DatabusRegistration)2