frankvicky commented on code in PR #19452:
URL: https://github.com/apache/kafka/pull/19452#discussion_r2041315836
##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/RestartRequest.java:
##########
@@ -25,33 +25,26 @@
* A request to restart a connector and/or task instances.
* <p>
* The natural order is based first upon the connector name and then requested
restart behaviors.
- * If two requests have the same connector name, then the requests are ordered
based on the
+ * If two requests have the same connector name, then the requests are ordered
based on the
* probable number of tasks/connector this request is going to restart.
+ * @param connectorName the name of the connector; may not be null
+ * @param onlyFailed true if only failed instances should be restarted
+ * @param includeTasks true if tasks should be restarted, or false if only
the connector should be restarted
*/
-public class RestartRequest implements Comparable<RestartRequest> {
+public record RestartRequest(String connectorName,
+ boolean onlyFailed,
+ boolean includeTasks) implements
Comparable<RestartRequest> {
- private final String connectorName;
- private final boolean onlyFailed;
- private final boolean includeTasks;
-
- /**
- * Create a new request to restart a connector and optionally its tasks.
- *
- * @param connectorName the name of the connector; may not be null
- * @param onlyFailed true if only failed instances should be restarted
- * @param includeTasks true if tasks should be restarted, or false if
only the connector should be restarted
- */
- public RestartRequest(String connectorName, boolean onlyFailed, boolean
includeTasks) {
- this.connectorName = Objects.requireNonNull(connectorName, "Connector
name may not be null");
- this.onlyFailed = onlyFailed;
- this.includeTasks = includeTasks;
+ public RestartRequest {
+ Objects.requireNonNull(connectorName, "Connector name may not be
null");
}
/**
* Get the name of the connector.
*
* @return the connector name; never null
*/
+ @Override
public String connectorName() {
Review Comment:
Could we remove these getters?
connectorName(), onlyFailed(), includeTasks()
##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/health/ConnectClusterDetailsImpl.java:
##########
@@ -19,16 +19,6 @@
import org.apache.kafka.connect.health.ConnectClusterDetails;
-public class ConnectClusterDetailsImpl implements ConnectClusterDetails {
+public record ConnectClusterDetailsImpl(String kafkaClusterId) implements
ConnectClusterDetails {
Review Comment:
nit: We could remove this empty line to keep a compact style.
##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/SessionKey.java:
##########
@@ -23,14 +23,12 @@
/**
* A session key, which can be used to validate internal REST requests between
workers.
*/
-public class SessionKey {
-
- private final SecretKey key;
- private final long creationTimestamp;
+public record SessionKey(SecretKey key, long creationTimestamp) {
Review Comment:
Similar to https://github.com/apache/kafka/pull/19452/files#r2041156088
We could use the compact constructor to minimize the code.
We could transfer the javadocs of getters to the class-level `@param` docs
and then remove the redundant getter.
##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/rest/ConnectRestExtensionContextImpl.java:
##########
@@ -22,26 +22,7 @@
import jakarta.ws.rs.core.Configurable;
-public class ConnectRestExtensionContextImpl implements
ConnectRestExtensionContext {
+public record ConnectRestExtensionContextImpl(Configurable<? extends
Configurable<?>> configurable,
+ ConnectClusterState
clusterState) implements ConnectRestExtensionContext {
Review Comment:
nit: We could remove this empty line to keep a compact style.
##########
connect/runtime/src/test/java/org/apache/kafka/connect/integration/StartsAndStops.java:
##########
@@ -17,21 +17,6 @@
package org.apache.kafka.connect.integration;
-public class StartsAndStops {
- private final int starts;
- private final int stops;
-
- public StartsAndStops(int starts, int stops) {
- this.starts = starts;
- this.stops = stops;
- }
-
- public int starts() {
- return starts;
- }
-
- public int stops() {
- return stops;
- }
+public record StartsAndStops(int starts, int stops) {
Review Comment:
nit: We could remove this empty line to keep a compact style.
##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/Herder.java:
##########
@@ -392,35 +391,7 @@ enum ConfigReloadAction {
RESTART
}
- class Created<T> {
- private final boolean created;
- private final T result;
-
- public Created(boolean created, T result) {
- this.created = created;
- this.result = result;
- }
-
- public boolean created() {
- return created;
- }
-
- public T result() {
- return result;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Created<?> created1 = (Created<?>) o;
- return Objects.equals(created, created1.created) &&
- Objects.equals(result, created1.result);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(created, result);
- }
+ record Created<T>(boolean created, T result) {
+
Review Comment:
nit: We could remove this empty line to keep a compact style.
##########
connect/runtime/src/main/java/org/apache/kafka/connect/runtime/SubmittedRecords.java:
##########
@@ -228,20 +228,18 @@ private Map<String, Object> offset() {
* Contains a snapshot of offsets that can be committed for a source task
and metadata for that offset commit
* (such as the number of messages for which offsets can and cannot be
committed).
*/
- static class CommittableOffsets {
+ record CommittableOffsets(Map<Map<String, Object>, Map<String, Object>>
offsets,
Review Comment:
ditto
We could leave `offsets()` since it is wrapped by an immutable Map.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]