org.apache.kafka.connect.connector.Connector Java Examples

The following examples show how to use org.apache.kafka.connect.connector.Connector. 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: BaseDocumentationTest.java    From connect-utils with Apache License 2.0 5 votes vote down vote up
private String connectorConfig(Plugin.Connector connector, Plugin.ConnectorExample example) throws JsonProcessingException {
  ObjectNode config = ObjectMapperFactory.INSTANCE.createObjectNode();
  config.put("connector.class", connector.getCls().getName());
  if (connector instanceof Plugin.SinkConnector) {
    config.put("topic", "<required setting>");
  }
  for (Map.Entry<String, String> e : example.getConfig().entrySet()) {
    config.put(e.getKey(), e.getValue());
  }

  if (null != example.transformations() && !example.transformations().isEmpty()) {
    config.put("transforms", Joiner.on(',').join(example.transformations().keySet()));
    for (Map.Entry<String, Map<String, String>> transform : example.transformations().entrySet()) {
      assertTrue(
          transform.getValue().containsKey("type"),
          String.format("Transform '%s' does not have a type property.", transform.getKey())
      );

      for (Map.Entry<String, String> entry : transform.getValue().entrySet()) {
        String key = String.format("transforms.%s.%s", transform.getKey(), entry.getKey());
        config.put(key, entry.getValue());
      }
    }
  }

  return writeValueAsIndentedString(config);
}
 
Example #2
Source File: PluginLoader.java    From connect-utils with Apache License 2.0 5 votes vote down vote up
ConfigDef connectorConfig(Class<? extends Connector> connectorClass) {
  try {
    return connectorClass.newInstance().config();
  } catch (InstantiationException | IllegalAccessException e) {
    throw new IllegalStateException(e);
  }
}
 
Example #3
Source File: MQSinkConnectorTest.java    From kafka-connect-mq-sink with Apache License 2.0 4 votes vote down vote up
@Test
public void testConnectorType() {
    Connector connector = new MQSinkConnector();
    assertTrue(SinkConnector.class.isAssignableFrom(connector.getClass()));
}
 
Example #4
Source File: MQSourceConnectorTest.java    From kafka-connect-mq-source with Apache License 2.0 4 votes vote down vote up
@Test
public void testConnectorType() {
    Connector connector = new MQSourceConnector();
    assertTrue(SourceConnector.class.isAssignableFrom(connector.getClass()));
}