org.apache.kafka.connect.util.FutureCallback Java Examples

The following examples show how to use org.apache.kafka.connect.util.FutureCallback. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectStandalone.java    From mongo-kafka with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
void addConnector(final String name, final Properties properties) {
  FutureCallback<Herder.Created<ConnectorInfo>> cb =
      new FutureCallback<>(
          (error, info) -> {
            if (error != null) {
              LOGGER.error("Failed to create job for {}", properties);
            } else {
              LOGGER.info("Created connector {}", info.result().name());
            }
          });
  try {
    herder.putConnectorConfig(name, (Map) properties, true, cb);
    cb.get();
    sleep(1000);
  } catch (Exception e) {
    LOGGER.error("Failed to add connector for {}", properties);
    throw new ConnectorConfigurationException(e);
  }
}
 
Example #2
Source File: KafkaConnectRunner.java    From camel-kafka-connector with Apache License 2.0 5 votes vote down vote up
public void initializeConnector(ConnectorPropertyFactory connectorPropertyFactory,
                                Consumer<ConnectorInitState> callback) throws ExecutionException, InterruptedException {
    Properties connectorProps = connectorPropertyFactory.getProperties();

    FutureCallback<Herder.Created<ConnectorInfo>> cb = new FutureCallback<>((error, info) ->
            callback.accept(new ConnectorInitState(info.result().config(), info.created(), error)));

    herder.putConnectorConfig(
            connectorProps.getProperty(ConnectorConfig.NAME_CONFIG),
            Utils.propsToStringMap(connectorProps), false, cb);

    cb.get();
}
 
Example #3
Source File: KafkaConnectRunner.java    From camel-kafka-connector with Apache License 2.0 5 votes vote down vote up
public <T> void initializeConnector(ConnectorPropertyFactory connectorPropertyFactory,
                                    BiConsumer<ConnectorInitState, T> callback, T payload) throws ExecutionException, InterruptedException {
    Properties connectorProps = connectorPropertyFactory.getProperties();

    FutureCallback<Herder.Created<ConnectorInfo>> cb = new FutureCallback<>((error, info) ->
            callback.accept(new ConnectorInitState(info.result().config(), info.created(), error), payload));

    herder.putConnectorConfig(
            connectorProps.getProperty(ConnectorConfig.NAME_CONFIG),
            Utils.propsToStringMap(connectorProps), false, cb);

    cb.get();
}