Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Add default implementations for new interface methods

...

As the title of this KIP suggests, the changes will affect the ConnectClusterState interface and its only current implementation, the ConnectClusterStateImpl class.

Each new method will come with a default implementation that throws an UnsupportedOperationException; this will enable users who have written their own implementation of the interface to rely on future versions of AK with the new interface methods without having to implement this method themselves. The ConnectClusterStateImpl class will be updated with working versions of each method that do not throw UnsupportedOperationExceptions.

Additional methods to add to the ConnectClusterState interface:

Code Block
languagejava
titleConnectClusterState interface - additional methods
/**
 * Lookup the current configuration of a connector. This provides the current snapshot of configuration by querying the underlying
 * herder. A connector returned by previous invocation of {@link #connectors()} may no longer be available and could result in {@link
 * org.apache.kafka.connect.errors.NotFoundException}.
 *
 * @param connName name of the connector
 * @return the configuration of the connector for the connector name
 * @throws org.apache.kafka.connect.errors.NotFoundException if the requested connector can't be found
 * @throws java.lang.UnsupportedOperationException if the default implementation has not been overridden
 */
default Map<String, String> connectorConfig(String connName) {
  throw new UnsupportedOperationException();
}

/**
 * Lookup the current task configurations of a connector. This provides the current snapshot of configuration by querying the underlying
 * herder. A connector returned by previous invocation of {@link #connectors()} may no longer be available and could result in {@link
 * org.apache.kafka.connect.errors.NotFoundException}.
 *
 * @param connName name of the connector
 * @return the configuration for each task ID
 * @throws org.apache.kafka.connect.errors.NotFoundException if the requested connector can't be found
 * @throws java.lang.UnsupportedOperationException if the default implementation has not been overridden
 **/
default Map<Integer, Map<String, String>> taskConfigs(String connName) {
  throw new UnsupportedOperationException();
}

/**
 * Get the cluster ID of the Kafka cluster backing this Connect cluster.
 * @return the cluster ID of the Kafka cluster backing this connect cluster
 * @throws java.lang.UnsupportedOperationException if the default implementation has not been overridden
 **/
default String kafkaClusterId() {
  throw new UnsupportedOperationException();
}

Proposed Changes

The basic idea here is to add as much information to the ConnectClusterState interface as is available via the Connect REST API; this includes all currently-available read-only methods of the Herder interface.

...

Not applicable; all proposed changes are backwards compatible.

Users who have written their own ConnectClusterState implementations will still be able to develop against releases of AK that contain the changes here, and will not need to implement the new methods. However, they must not call these new methods without overriding them with a functioning version themselves, or an exception will be thrown.

Since this is a feature addition and not a bug fix, the targeted version is the upcoming 2.3 release.

...