showuon commented on code in PR #14116:
URL: https://github.com/apache/kafka/pull/14116#discussion_r1308544259


##########
storage/src/test/java/org/apache/kafka/tiered/storage/utils/BrokerLocalStorage.java:
##########
@@ -0,0 +1,162 @@
+/*
+ * 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.tiered.storage.utils;
+
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.utils.Time;
+import org.apache.kafka.common.utils.Timer;
+import org.apache.kafka.common.utils.Utils;
+import org.apache.kafka.storage.internals.log.LogFileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+
+public final class BrokerLocalStorage {
+
+    private final Integer brokerId;
+    private final File brokerStorageDirectory;
+    private final Integer storageWaitTimeoutSec;
+
+    private final int storagePollPeriodSec = 1;
+    private final Time time = Time.SYSTEM;
+
+    public BrokerLocalStorage(Integer brokerId,
+                              String storageDirname,
+                              Integer storageWaitTimeoutSec) {
+        this.brokerId = brokerId;
+        this.brokerStorageDirectory = new File(storageDirname);
+        this.storageWaitTimeoutSec = storageWaitTimeoutSec;
+    }
+
+    public Integer getBrokerId() {
+        return brokerId;
+    }
+
+    /**
+     * Wait until the first segment offset in Apache Kafka storage for the 
given topic-partition is
+     * equal or greater to the provided offset.

Review Comment:
   I think we're waiting for `equal` only here, not greater, right?



##########
storage/src/test/java/org/apache/kafka/tiered/storage/actions/ShrinkReplicaAction.java:
##########
@@ -0,0 +1,83 @@
+/*
+ * 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.tiered.storage.actions;
+
+import org.apache.kafka.tiered.storage.TieredStorageTestAction;
+import org.apache.kafka.tiered.storage.TieredStorageTestContext;
+import org.apache.kafka.clients.admin.NewPartitionReassignment;
+import org.apache.kafka.common.TopicPartition;
+import org.apache.kafka.common.TopicPartitionInfo;
+import org.apache.kafka.test.TestUtils;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.concurrent.ExecutionException;
+
+import static org.apache.kafka.tiered.storage.utils.ActionUtils.describeTopic;
+
+public final class ShrinkReplicaAction implements TieredStorageTestAction {

Review Comment:
   Is this a real use case? TBH, I don't know Kafka supports shirnk replica 
action.



##########
storage/src/test/java/org/apache/kafka/tiered/storage/actions/CreateTopicAction.java:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.tiered.storage.actions;
+
+import org.apache.kafka.tiered.storage.TieredStorageTestAction;
+import org.apache.kafka.tiered.storage.TieredStorageTestContext;
+import org.apache.kafka.tiered.storage.specs.TopicSpec;
+import org.apache.kafka.common.config.TopicConfig;
+
+import java.io.PrintStream;
+import java.util.concurrent.ExecutionException;
+
+public final class CreateTopicAction implements TieredStorageTestAction {
+
+    private final TopicSpec spec;
+
+    public CreateTopicAction(TopicSpec spec) {
+        this.spec = spec;
+    }
+
+    @Override
+    public void doExecute(TieredStorageTestContext context) throws 
ExecutionException, InterruptedException {
+        // Ensure offset and time indexes are generated for every record.
+        spec.getProperties().put(TopicConfig.INDEX_INTERVAL_BYTES_CONFIG, "1");
+        // Leverage the use of the segment index size to create a log-segment 
accepting one and only one record.
+        // The minimum size of the indexes is that of an entry, which is 8 for 
the offset index and 12 for the
+        // time index. Hence, since the topic is configured to generate index 
entries for every record with, for
+        // a "small" number of records (i.e. such that the average record size 
times the number of records is
+        // much less than the segment size), the number of records which hold 
in a segment is the multiple of 12
+        // defined below.
+        if (spec.getMaxBatchCountPerSegment() != -1) {
+            spec.getProperties().put(
+                    TopicConfig.SEGMENT_INDEX_BYTES_CONFIG, String.valueOf(12 
* spec.getMaxBatchCountPerSegment()));

Review Comment:
   Could you let me know why it is not `8 * spec.getMaxBatchCountPerSegment()` 
for offset index?



-- 
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-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to