Search in sources :

Example 1 with KafkaConfigBackingStore

use of org.apache.kafka.connect.storage.KafkaConfigBackingStore in project kafka by apache.

the class ConnectDistributed method main.

public static void main(String[] args) throws Exception {
    if (args.length < 1) {
        log.info("Usage: ConnectDistributed worker.properties");
        Exit.exit(1);
    }
    String workerPropsFile = args[0];
    Map<String, String> workerProps = !workerPropsFile.isEmpty() ? Utils.propsToStringMap(Utils.loadProps(workerPropsFile)) : Collections.<String, String>emptyMap();
    Time time = Time.SYSTEM;
    ConnectorFactory connectorFactory = new ConnectorFactory();
    DistributedConfig config = new DistributedConfig(workerProps);
    RestServer rest = new RestServer(config);
    URI advertisedUrl = rest.advertisedUrl();
    String workerId = advertisedUrl.getHost() + ":" + advertisedUrl.getPort();
    KafkaOffsetBackingStore offsetBackingStore = new KafkaOffsetBackingStore();
    offsetBackingStore.configure(config);
    Worker worker = new Worker(workerId, time, connectorFactory, config, offsetBackingStore);
    StatusBackingStore statusBackingStore = new KafkaStatusBackingStore(time, worker.getInternalValueConverter());
    statusBackingStore.configure(config);
    ConfigBackingStore configBackingStore = new KafkaConfigBackingStore(worker.getInternalValueConverter(), config);
    DistributedHerder herder = new DistributedHerder(config, time, worker, statusBackingStore, configBackingStore, advertisedUrl.toString());
    final Connect connect = new Connect(herder, rest);
    try {
        connect.start();
    } catch (Exception e) {
        log.error("Failed to start Connect", e);
        connect.stop();
    }
    // Shutdown will be triggered by Ctrl-C or via HTTP shutdown request
    connect.awaitStop();
}
Also used : KafkaStatusBackingStore(org.apache.kafka.connect.storage.KafkaStatusBackingStore) StatusBackingStore(org.apache.kafka.connect.storage.StatusBackingStore) DistributedHerder(org.apache.kafka.connect.runtime.distributed.DistributedHerder) DistributedConfig(org.apache.kafka.connect.runtime.distributed.DistributedConfig) Connect(org.apache.kafka.connect.runtime.Connect) Time(org.apache.kafka.common.utils.Time) URI(java.net.URI) KafkaStatusBackingStore(org.apache.kafka.connect.storage.KafkaStatusBackingStore) KafkaConfigBackingStore(org.apache.kafka.connect.storage.KafkaConfigBackingStore) ConfigBackingStore(org.apache.kafka.connect.storage.ConfigBackingStore) KafkaConfigBackingStore(org.apache.kafka.connect.storage.KafkaConfigBackingStore) RestServer(org.apache.kafka.connect.runtime.rest.RestServer) ConnectorFactory(org.apache.kafka.connect.runtime.ConnectorFactory) Worker(org.apache.kafka.connect.runtime.Worker) KafkaOffsetBackingStore(org.apache.kafka.connect.storage.KafkaOffsetBackingStore)

Aggregations

URI (java.net.URI)1 Time (org.apache.kafka.common.utils.Time)1 Connect (org.apache.kafka.connect.runtime.Connect)1 ConnectorFactory (org.apache.kafka.connect.runtime.ConnectorFactory)1 Worker (org.apache.kafka.connect.runtime.Worker)1 DistributedConfig (org.apache.kafka.connect.runtime.distributed.DistributedConfig)1 DistributedHerder (org.apache.kafka.connect.runtime.distributed.DistributedHerder)1 RestServer (org.apache.kafka.connect.runtime.rest.RestServer)1 ConfigBackingStore (org.apache.kafka.connect.storage.ConfigBackingStore)1 KafkaConfigBackingStore (org.apache.kafka.connect.storage.KafkaConfigBackingStore)1 KafkaOffsetBackingStore (org.apache.kafka.connect.storage.KafkaOffsetBackingStore)1 KafkaStatusBackingStore (org.apache.kafka.connect.storage.KafkaStatusBackingStore)1 StatusBackingStore (org.apache.kafka.connect.storage.StatusBackingStore)1