You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "m1a2st (via GitHub)" <gi...@apache.org> on 2025/02/05 11:45:13 UTC
[PR] KAFKA-18728 Move ListOffsetsPartitionStatus to server module [kafka]
m1a2st opened a new pull request, #18807:
URL: https://github.com/apache/kafka/pull/18807
Jira: https://issues.apache.org/jira/browse/KAFKA-18728
### Committer Checklist (excluded from commit message)
- [ ] Verify design and implementation
- [ ] Verify test coverage and CI build status
- [ ] Verify documentation (including upgrade notes)
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18728 Move ListOffsetsPartitionStatus to server module [kafka]
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #18807:
URL: https://github.com/apache/kafka/pull/18807#discussion_r1947868160
##########
server/src/main/java/org/apache/kafka/server/ListOffsetsPartitionStatus.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.server;
+
+import org.apache.kafka.common.errors.ApiException;
+import org.apache.kafka.common.message.ListOffsetsResponseData.ListOffsetsPartitionResponse;
+import org.apache.kafka.storage.internals.log.AsyncOffsetReadFutureHolder;
+import org.apache.kafka.storage.internals.log.OffsetResultHolder.FileRecordsOrError;
+
+import java.util.Optional;
+
+public class ListOffsetsPartitionStatus {
+
+ private final Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt;
+ private final Optional<Long> lastFetchableOffset;
+ private final Optional<ApiException> maybeOffsetsError;
+
+ private volatile Optional<ListOffsetsPartitionResponse> responseOpt = Optional.empty();
+ private volatile boolean completed = false;
+
+ private ListOffsetsPartitionStatus(
+ Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt,
+ Optional<Long> lastFetchableOffset,
+ Optional<ApiException> maybeOffsetsError
+ ) {
+ this.futureHolderOpt = futureHolderOpt;
+ this.lastFetchableOffset = lastFetchableOffset;
+ this.maybeOffsetsError = maybeOffsetsError;
+ }
+
+ public static ListOffsetsPartitionStatus build(
Review Comment:
Can we add a builder for `ListOffsetsPartitionStatus` class? Adding the builder may improve the code readability on the caller end:
(eg)
```
ListOffsetsPartitionStatus.build(Optional.of(partitionResponse), Optional.empty(), Optional.empty(), Optional.empty())
```
to
```
ListOffsetsPartitionStatus.builder().responseOpt(Optional.of(partitionResponse)).build()
```
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18728 Move ListOffsetsPartitionStatus to server module [kafka]
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on PR #18807:
URL: https://github.com/apache/kafka/pull/18807#issuecomment-2646890135
Rerunning the Java 17 junit tests
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18728 Move ListOffsetsPartitionStatus to server module [kafka]
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #18807:
URL: https://github.com/apache/kafka/pull/18807#discussion_r1953813541
##########
server/src/main/java/org/apache/kafka/server/ListOffsetsPartitionStatus.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.server;
+
+import org.apache.kafka.common.errors.ApiException;
+import org.apache.kafka.common.message.ListOffsetsResponseData.ListOffsetsPartitionResponse;
+import org.apache.kafka.storage.internals.log.AsyncOffsetReadFutureHolder;
+import org.apache.kafka.storage.internals.log.OffsetResultHolder.FileRecordsOrError;
+
+import java.util.Optional;
+
+public class ListOffsetsPartitionStatus {
+
+ private final Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt;
+ private final Optional<Long> lastFetchableOffset;
+ private final Optional<ApiException> maybeOffsetsError;
+
+ private volatile Optional<ListOffsetsPartitionResponse> responseOpt;
+ private volatile boolean completed = false;
+
+ private ListOffsetsPartitionStatus(
+ Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt,
+ Optional<Long> lastFetchableOffset,
+ Optional<ApiException> maybeOffsetsError,
+ Optional<ListOffsetsPartitionResponse> responseOpt
+ ) {
+ this.futureHolderOpt = futureHolderOpt;
+ this.lastFetchableOffset = lastFetchableOffset;
+ this.maybeOffsetsError = maybeOffsetsError;
+ this.responseOpt = responseOpt;
+ }
+
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public static class Builder {
+ private Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt = Optional.empty();
+ private Optional<Long> lastFetchableOffset = Optional.empty();
+ private Optional<ApiException> maybeOffsetsError = Optional.empty();
+ private volatile Optional<ListOffsetsPartitionResponse> responseOpt = Optional.empty();
+
+ public Builder futureHolderOpt(Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolder) {
+ this.futureHolderOpt = futureHolder;
+ return this;
+ }
+
+ public Builder lastFetchableOffset(Optional<Long> lastFetchableOffset) {
+ this.lastFetchableOffset = lastFetchableOffset;
+ return this;
+ }
+
+ public Builder maybeOffsetsError(Optional<ApiException> maybeOffsetsError) {
+ this.maybeOffsetsError = maybeOffsetsError;
+ return this;
+ }
+
+ public Builder responseOpt(Optional<ListOffsetsPartitionResponse> responseOpt) {
+ this.responseOpt = responseOpt;
+ return this;
+ }
+
+ public ListOffsetsPartitionStatus build() {
+ return new ListOffsetsPartitionStatus(
+ futureHolderOpt,
+ lastFetchableOffset,
+ maybeOffsetsError,
+ responseOpt
+ );
+ }
+
+ }
+
+ public Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt() {
+ return futureHolderOpt;
+ }
+
+ public Optional<Long> lastFetchableOffset() {
+ return lastFetchableOffset;
+ }
+
+ public Optional<ApiException> maybeOffsetsError() {
+ return maybeOffsetsError;
+ }
+
+ public void responseOpt(Optional<ListOffsetsPartitionResponse> responseOpt) {
+ this.responseOpt = responseOpt;
+ }
+
+ public Optional<ListOffsetsPartitionResponse> responseOpt() {
+ return responseOpt;
+ }
+
+ public void completed(boolean completed) {
+ this.completed = completed;
+ }
+
+ public boolean completed() {
+ return completed;
+ }
+
+ @Override
+ public String toString() {
+ return String.format("[responseOpt: %s, lastFetchableOffset: %s, " +
Review Comment:
`toString` without class-name looks odd. I understand that we ported the changes as is from scala -> java. And, the `toString` is used only in DelayedRemoteListOffsets logger, so should be fine.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18728 Move ListOffsetsPartitionStatus to server module [kafka]
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph merged PR #18807:
URL: https://github.com/apache/kafka/pull/18807
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18728 Move ListOffsetsPartitionStatus to server module [kafka]
Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #18807:
URL: https://github.com/apache/kafka/pull/18807#discussion_r1947929551
##########
server/src/main/java/org/apache/kafka/server/ListOffsetsPartitionStatus.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.server;
+
+import org.apache.kafka.common.errors.ApiException;
+import org.apache.kafka.common.message.ListOffsetsResponseData.ListOffsetsPartitionResponse;
+import org.apache.kafka.storage.internals.log.AsyncOffsetReadFutureHolder;
+import org.apache.kafka.storage.internals.log.OffsetResultHolder.FileRecordsOrError;
+
+import java.util.Optional;
+
+public class ListOffsetsPartitionStatus {
+
+ private final Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt;
+ private final Optional<Long> lastFetchableOffset;
+ private final Optional<ApiException> maybeOffsetsError;
+
+ private volatile Optional<ListOffsetsPartitionResponse> responseOpt = Optional.empty();
+ private volatile boolean completed = false;
+
+ private ListOffsetsPartitionStatus(
+ Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt,
+ Optional<Long> lastFetchableOffset,
+ Optional<ApiException> maybeOffsetsError
+ ) {
+ this.futureHolderOpt = futureHolderOpt;
+ this.lastFetchableOffset = lastFetchableOffset;
+ this.maybeOffsetsError = maybeOffsetsError;
+ }
+
+ public static ListOffsetsPartitionStatus build(
Review Comment:
> Instead of builder, let's add one more build method, most of the usages will refer to this one:
I think use builder pattern is more flexible :)
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-18728 Move ListOffsetsPartitionStatus to server module [kafka]
Posted by "kamalcph (via GitHub)" <gi...@apache.org>.
kamalcph commented on code in PR #18807:
URL: https://github.com/apache/kafka/pull/18807#discussion_r1947891621
##########
server/src/main/java/org/apache/kafka/server/ListOffsetsPartitionStatus.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.server;
+
+import org.apache.kafka.common.errors.ApiException;
+import org.apache.kafka.common.message.ListOffsetsResponseData.ListOffsetsPartitionResponse;
+import org.apache.kafka.storage.internals.log.AsyncOffsetReadFutureHolder;
+import org.apache.kafka.storage.internals.log.OffsetResultHolder.FileRecordsOrError;
+
+import java.util.Optional;
+
+public class ListOffsetsPartitionStatus {
+
+ private final Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt;
+ private final Optional<Long> lastFetchableOffset;
+ private final Optional<ApiException> maybeOffsetsError;
+
+ private volatile Optional<ListOffsetsPartitionResponse> responseOpt = Optional.empty();
+ private volatile boolean completed = false;
+
+ private ListOffsetsPartitionStatus(
+ Optional<AsyncOffsetReadFutureHolder<FileRecordsOrError>> futureHolderOpt,
+ Optional<Long> lastFetchableOffset,
+ Optional<ApiException> maybeOffsetsError
+ ) {
+ this.futureHolderOpt = futureHolderOpt;
+ this.lastFetchableOffset = lastFetchableOffset;
+ this.maybeOffsetsError = maybeOffsetsError;
+ }
+
+ public static ListOffsetsPartitionStatus build(
Review Comment:
Instead of builder, let's add one more `build` method, most of the usages will refer to this one:
```java
public static ListOffsetsPartitionStatus build(Optional<ListOffsetsPartitionResponse> responseOpt) {
return build(responseOpt, Optional.empty(), Optional.empty(), Optional.empty());
}
```
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org