Class MockConnector

java.lang.Object
org.apache.kafka.connect.connector.Connector
org.apache.kafka.connect.tools.MockConnector
All Implemented Interfaces:
Versioned

public class MockConnector extends Connector
This connector provides support for mocking certain connector behaviors. For example, this can be used to simulate connector or task failures. It works by passing a "mock mode" through configuration from the system test. New mock behavior can be implemented either in the connector or in the task by providing a new mode implementation.

At the moment, this connector only supports a single task and shares configuration between the connector and its tasks.

See Also:
  • Field Details

  • Constructor Details

    • MockConnector

      public MockConnector()
  • Method Details

    • version

      public String version()
      Description copied from interface: Versioned
      Get the version of this component.
      Returns:
      the version, formatted as a String. The version may not be null or empty.
    • start

      public void start(Map<String,String> config)
      Description copied from class: Connector
      Start this Connector. This method will only be called on a clean Connector, i.e. it has either just been instantiated and initialized or Connector.stop() has been invoked.
      Specified by:
      start in class Connector
      Parameters:
      config - configuration settings
    • taskClass

      public Class<? extends Task> taskClass()
      Description copied from class: Connector
      Returns the Task implementation for this Connector.
      Specified by:
      taskClass in class Connector
    • taskConfigs

      public List<Map<String,String>> taskConfigs(int maxTasks)
      Description copied from class: Connector
      Returns a set of configurations for Tasks based on the current configuration, producing at most maxTasks configurations.
      Specified by:
      taskConfigs in class Connector
      Parameters:
      maxTasks - maximum number of configurations to generate
      Returns:
      configurations for Tasks
    • stop

      public void stop()
      Description copied from class: Connector
      Stop this connector.
      Specified by:
      stop in class Connector
    • config

      public ConfigDef config()
      Description copied from class: Connector
      Define the configuration for the connector.
      Specified by:
      config in class Connector
      Returns:
      The ConfigDef for this connector; may not be null.