当前位置: 首页>>代码示例>>Java>>正文


Java SinkConnector类代码示例

本文整理汇总了Java中org.apache.kafka.connect.sink.SinkConnector的典型用法代码示例。如果您正苦于以下问题:Java SinkConnector类的具体用法?Java SinkConnector怎么用?Java SinkConnector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SinkConnector类属于org.apache.kafka.connect.sink包,在下文中一共展示了SinkConnector类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: validateBasicConnectorConfig

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
@Override
protected Map<String, ConfigValue> validateBasicConnectorConfig(Connector connector,
                                                                ConfigDef configDef,
                                                                Map<String, String> config) {
    Map<String, ConfigValue> validatedConfig = super.validateBasicConnectorConfig(connector, configDef, config);
    if (connector instanceof SinkConnector) {
        ConfigValue validatedName = validatedConfig.get(ConnectorConfig.NAME_CONFIG);
        String name = (String) validatedName.value();

        if (workerGroupId.equals(SinkUtils.consumerGroupId(name))) {
            validatedName.addErrorMessage("Consumer group for sink connector named " + name +
                    " conflicts with Connect worker group " + workerGroupId);
        }
    }
    return validatedConfig;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:17,代码来源:DistributedHerder.java

示例2: testListConnectorPlugins

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
@Test
public void testListConnectorPlugins() throws Exception {
    expectPlugins();
    Set<ConnectorPluginInfo> connectorPlugins = new HashSet<>(connectorPluginsResource.listConnectorPlugins());
    assertFalse(connectorPlugins.contains(newInfo(Connector.class, "0.0")));
    assertFalse(connectorPlugins.contains(newInfo(SourceConnector.class, "0.0")));
    assertFalse(connectorPlugins.contains(newInfo(SinkConnector.class, "0.0")));
    assertFalse(connectorPlugins.contains(newInfo(VerifiableSourceConnector.class)));
    assertFalse(connectorPlugins.contains(newInfo(VerifiableSinkConnector.class)));
    assertFalse(connectorPlugins.contains(newInfo(MockSourceConnector.class)));
    assertFalse(connectorPlugins.contains(newInfo(MockSinkConnector.class)));
    assertFalse(connectorPlugins.contains(newInfo(MockConnector.class)));
    assertFalse(connectorPlugins.contains(newInfo(SchemaSourceConnector.class)));
    assertTrue(connectorPlugins.contains(newInfo(ConnectorPluginsResourceTestConnector.class)));
    PowerMock.verifyAll();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:17,代码来源:ConnectorPluginsResourceTest.java

示例3: before

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
@BeforeEach
public void before() throws MalformedURLException {
  log.info("before() - Configuring reflections to use package '{}'", packages());

  if (null == this.reflections) {
    this.reflections = new Reflections(new ConfigurationBuilder()
        .setUrls(ClasspathHelper.forJavaClassPath())
        .forPackages(packages())
    );
  }

  List<Class<? extends Transformation>> transformClasses = list(Transformation.class);
  List<Class<? extends SourceConnector>> sourceConnectorClasses = list(SourceConnector.class);
  List<Class<? extends SinkConnector>> sinkConnectorClasses = list(SinkConnector.class);

  this.pluginTemplate = PluginTemplate.from(sourceConnectorClasses, sinkConnectorClasses, transformClasses);
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:18,代码来源:BaseDocumentationTest.java

示例4: makeSinkProps

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
/**
 * Creates properties for test sink connector.
 *
 * @param topics Topics.
 * @return Test sink connector properties.
 */
private Map<String, String> makeSinkProps(String topics) {
    Map<String, String> props = new HashMap<>();

    props.put(SinkConnector.TOPICS_CONFIG, topics);
    props.put(ConnectorConfig.TASKS_MAX_CONFIG, "2");
    props.put(ConnectorConfig.NAME_CONFIG, "test-sink-connector");
    props.put(ConnectorConfig.CONNECTOR_CLASS_CONFIG, IgniteSinkConnectorMock.class.getName());
    props.put(IgniteSinkConstants.CACHE_NAME, "testCache");
    props.put(IgniteSinkConstants.CACHE_ALLOW_OVERWRITE, "true");
    props.put(IgniteSinkConstants.CACHE_CFG_PATH, "example-ignite.xml");
    props.put(IgniteSinkConstants.SINGLE_TUPLE_EXTRACTOR_CLASS,
        "org.apache.ignite.stream.kafka.connect.IgniteSinkConnectorTest$TestExtractor");

    return props;
}
 
开发者ID:apache,项目名称:ignite,代码行数:22,代码来源:IgniteSinkConnectorTest.java

示例5: setup

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
@Before
public void setup() {
    connector = new FileStreamSinkConnector();
    ctx = PowerMock.createMock(ConnectorContext.class);
    connector.initialize(ctx);

    sinkProperties = new HashMap<>();
    sinkProperties.put(SinkConnector.TOPICS_CONFIG, MULTIPLE_TOPICS);
    sinkProperties.put(FileStreamSinkConnector.FILE_CONFIG, FILENAME);
}
 
开发者ID:wngn123,项目名称:wngn-jms-kafka,代码行数:11,代码来源:FileStreamSinkConnectorTest.java

示例6: testPluginDescWithSystemClassLoader

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
@Test
public void testPluginDescWithSystemClassLoader() throws Exception {
    String location = "classpath";
    PluginDesc<SinkConnector> connectorDesc = new PluginDesc<>(
            SinkConnector.class,
            regularVersion,
            systemLoader
    );

    assertPluginDesc(connectorDesc, SinkConnector.class, regularVersion, location);

    PluginDesc<Converter> converterDesc = new PluginDesc<>(
            Converter.class,
            snaphotVersion,
            systemLoader
    );

    assertPluginDesc(converterDesc, Converter.class, snaphotVersion, location);

    PluginDesc<Transformation> transformDesc = new PluginDesc<>(
            Transformation.class,
            noVersion,
            systemLoader
    );

    assertPluginDesc(transformDesc, Transformation.class, noVersion, location);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:28,代码来源:PluginDescTest.java

示例7: from

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
public static PluginTemplate from(List<Class<? extends SourceConnector>> sourceConnectorClasses, List<Class<? extends SinkConnector>> sinkConnectorClasses, List<Class<? extends Transformation>> transformationClasses) {
  final List<SourceConnectorTemplate> sourceConnectors = sourceConnectorClasses.stream()
      .map(aClass -> new SourceConnectorTemplate(aClass))
      .collect(Collectors.toList());
  final List<SinkConnectorTemplate> sinkConnectors = sinkConnectorClasses.stream()
      .map(aClass -> new SinkConnectorTemplate(aClass))
      .collect(Collectors.toList());
  final List<TransformationTemplate> transformations = transformationClasses.stream()
      .map(aClass -> new TransformationTemplate(aClass))
      .collect(Collectors.toList());

  return new PluginTemplate(sourceConnectors, sinkConnectors, transformations);
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:14,代码来源:PluginTemplate.java

示例8: start

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
/**
 * A sink lifecycle method. Validates grid-specific sink properties.
 *
 * @param props Sink properties.
 */
@Override public void start(Map<String, String> props) {
    configProps = props;

    try {
        A.notNullOrEmpty(configProps.get(SinkConnector.TOPICS_CONFIG), "topics");
        A.notNullOrEmpty(configProps.get(IgniteSinkConstants.CACHE_NAME), "cache name");
        A.notNullOrEmpty(configProps.get(IgniteSinkConstants.CACHE_CFG_PATH), "path to cache config file");
    }
    catch (IllegalArgumentException e) {
        throw new ConnectException("Cannot start IgniteSinkConnector due to configuration error", e);
    }
}
 
开发者ID:apache,项目名称:ignite,代码行数:18,代码来源:IgniteSinkConnector.java

示例9: testConnectorType

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
@Test
public void testConnectorType() {
    Connector connector = new MQSinkConnector();
    assertTrue(SinkConnector.class.isAssignableFrom(connector.getClass()));
}
 
开发者ID:ibm-messaging,项目名称:kafka-connect-mq-sink,代码行数:6,代码来源:MQSinkConnectorTest.java

示例10: isSinkConnector

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
public boolean isSinkConnector() {
    return SinkConnector.class.isAssignableFrom(connector.getClass());
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:4,代码来源:WorkerConnector.java

示例11: testConnectorNameConflictsWithWorkerGroupId

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
@Test
public void testConnectorNameConflictsWithWorkerGroupId() throws Exception {
    EasyMock.expect(member.memberId()).andStubReturn("leader");
    expectRebalance(1, Collections.<String>emptyList(), Collections.<ConnectorTaskId>emptyList());
    expectPostRebalanceCatchup(SNAPSHOT);

    member.wakeup();
    PowerMock.expectLastCall();

    Map<String, String> config = new HashMap<>(CONN2_CONFIG);
    config.put(ConnectorConfig.NAME_CONFIG, "test-group");

    // config validation
    Connector connectorMock = PowerMock.createMock(SinkConnector.class);
    EasyMock.expect(worker.getPlugins()).andReturn(plugins).times(3);
    EasyMock.expect(plugins.compareAndSwapLoaders(connectorMock)).andReturn(delegatingLoader);
    EasyMock.expect(plugins.newConnector(EasyMock.anyString())).andReturn(connectorMock);
    EasyMock.expect(connectorMock.config()).andReturn(new ConfigDef());
    EasyMock.expect(connectorMock.validate(config)).andReturn(new Config(Collections.<ConfigValue>emptyList()));
    EasyMock.expect(Plugins.compareAndSwapLoaders(delegatingLoader)).andReturn(pluginLoader);

    // CONN2 creation should fail because the worker group id (connect-test-group) conflicts with
    // the consumer group id we would use for this sink

    Capture<Throwable> error = EasyMock.newCapture();
    putConnectorCallback.onCompletion(EasyMock.capture(error), EasyMock.isNull(Herder.Created.class));
    PowerMock.expectLastCall();

    member.poll(EasyMock.anyInt());
    PowerMock.expectLastCall();
    // No immediate action besides this -- change will be picked up via the config log

    PowerMock.replayAll();

    herder.putConnectorConfig(CONN2, config, false, putConnectorCallback);
    herder.tick();

    assertTrue(error.hasCaptured());
    assertTrue(error.getValue() instanceof BadRequestException);

    PowerMock.verifyAll();
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:43,代码来源:DistributedHerderTest.java

示例12: connectorType

import org.apache.kafka.connect.sink.SinkConnector; //导入依赖的package包/类
@Test
public void connectorType() {
  Connector connector = new S3SinkConnector();
  assertTrue(SinkConnector.class.isAssignableFrom(connector.getClass()));
}
 
开发者ID:confluentinc,项目名称:kafka-connect-storage-cloud,代码行数:6,代码来源:S3SinkConnectorTest.java


注:本文中的org.apache.kafka.connect.sink.SinkConnector类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。