diff --git a/build.gradle b/build.gradle index a115ed07340b9..d3b171533471e 100644 --- a/build.gradle +++ b/build.gradle @@ -205,7 +205,6 @@ def excludedSpotlessModules = [':clients', ':connect:runtime', ':core', ':metadata', - ':raft', ':server', ':storage', ':storage:storage-api', // rename in settings.gradle diff --git a/raft/src/main/java/org/apache/kafka/raft/CandidateState.java b/raft/src/main/java/org/apache/kafka/raft/CandidateState.java index 9e08b3d7f556a..6e4b8b7248ff5 100644 --- a/raft/src/main/java/org/apache/kafka/raft/CandidateState.java +++ b/raft/src/main/java/org/apache/kafka/raft/CandidateState.java @@ -16,19 +16,21 @@ */ package org.apache.kafka.raft; -import java.util.HashMap; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import java.util.stream.Collectors; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.utils.LogContext; import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.Timer; import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.raft.internals.VoterSet; + import org.slf4j.Logger; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + public class CandidateState implements EpochState { private final int localId; private final Uuid localDirectoryId; diff --git a/raft/src/main/java/org/apache/kafka/raft/ControlRecord.java b/raft/src/main/java/org/apache/kafka/raft/ControlRecord.java index 8e2c261983031..641d4cb97924d 100644 --- a/raft/src/main/java/org/apache/kafka/raft/ControlRecord.java +++ b/raft/src/main/java/org/apache/kafka/raft/ControlRecord.java @@ -16,7 +16,6 @@ */ package org.apache.kafka.raft; -import java.util.Objects; import org.apache.kafka.common.message.KRaftVersionRecord; import org.apache.kafka.common.message.LeaderChangeMessage; import org.apache.kafka.common.message.SnapshotFooterRecord; @@ -25,6 +24,8 @@ import org.apache.kafka.common.protocol.ApiMessage; import org.apache.kafka.common.record.ControlRecordType; +import java.util.Objects; + public final class ControlRecord { private final ControlRecordType recordType; private final ApiMessage message; diff --git a/raft/src/main/java/org/apache/kafka/raft/ElectionState.java b/raft/src/main/java/org/apache/kafka/raft/ElectionState.java index 5c6dc14671b83..367f104cbfa20 100644 --- a/raft/src/main/java/org/apache/kafka/raft/ElectionState.java +++ b/raft/src/main/java/org/apache/kafka/raft/ElectionState.java @@ -16,15 +16,16 @@ */ package org.apache.kafka.raft; +import org.apache.kafka.common.Uuid; +import org.apache.kafka.raft.generated.QuorumStateData; +import org.apache.kafka.raft.internals.ReplicaKey; + import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.OptionalInt; import java.util.Set; import java.util.stream.Collectors; -import org.apache.kafka.common.Uuid; -import org.apache.kafka.raft.generated.QuorumStateData; -import org.apache.kafka.raft.internals.ReplicaKey; /** * Encapsulate election state stored on disk after every state change. diff --git a/raft/src/main/java/org/apache/kafka/raft/EpochState.java b/raft/src/main/java/org/apache/kafka/raft/EpochState.java index c9ab157a8a9cb..fc11a743b474f 100644 --- a/raft/src/main/java/org/apache/kafka/raft/EpochState.java +++ b/raft/src/main/java/org/apache/kafka/raft/EpochState.java @@ -16,9 +16,10 @@ */ package org.apache.kafka.raft; +import org.apache.kafka.raft.internals.ReplicaKey; + import java.io.Closeable; import java.util.Optional; -import org.apache.kafka.raft.internals.ReplicaKey; public interface EpochState extends Closeable { diff --git a/raft/src/main/java/org/apache/kafka/raft/FileQuorumStateStore.java b/raft/src/main/java/org/apache/kafka/raft/FileQuorumStateStore.java index 439d19a6aa8e7..8633d1eda391b 100644 --- a/raft/src/main/java/org/apache/kafka/raft/FileQuorumStateStore.java +++ b/raft/src/main/java/org/apache/kafka/raft/FileQuorumStateStore.java @@ -16,13 +16,15 @@ */ package org.apache.kafka.raft; +import org.apache.kafka.common.utils.Utils; +import org.apache.kafka.raft.generated.QuorumStateData; +import org.apache.kafka.raft.generated.QuorumStateDataJsonConverter; + import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ShortNode; -import org.apache.kafka.common.utils.Utils; -import org.apache.kafka.raft.generated.QuorumStateData; -import org.apache.kafka.raft.generated.QuorumStateDataJsonConverter; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/raft/src/main/java/org/apache/kafka/raft/FollowerState.java b/raft/src/main/java/org/apache/kafka/raft/FollowerState.java index 0491689505e23..bfbd257ece238 100644 --- a/raft/src/main/java/org/apache/kafka/raft/FollowerState.java +++ b/raft/src/main/java/org/apache/kafka/raft/FollowerState.java @@ -16,17 +16,19 @@ */ package org.apache.kafka.raft; -import java.util.Optional; -import java.util.OptionalLong; -import java.util.Set; import org.apache.kafka.common.Node; import org.apache.kafka.common.utils.LogContext; import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.Timer; import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.snapshot.RawSnapshotWriter; + import org.slf4j.Logger; +import java.util.Optional; +import java.util.OptionalLong; +import java.util.Set; + public class FollowerState implements EpochState { private final int fetchTimeoutMs; private final int epoch; diff --git a/raft/src/main/java/org/apache/kafka/raft/KafkaNetworkChannel.java b/raft/src/main/java/org/apache/kafka/raft/KafkaNetworkChannel.java index f6341b76e7e35..d8bf24b884304 100644 --- a/raft/src/main/java/org/apache/kafka/raft/KafkaNetworkChannel.java +++ b/raft/src/main/java/org/apache/kafka/raft/KafkaNetworkChannel.java @@ -37,6 +37,7 @@ import org.apache.kafka.common.utils.Time; import org.apache.kafka.server.util.InterBrokerSendThread; import org.apache.kafka.server.util.RequestAndCompletionHandler; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java b/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java index e2b0ee5c629ce..c2894def7f5e9 100644 --- a/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java +++ b/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClient.java @@ -82,6 +82,7 @@ import org.apache.kafka.snapshot.RecordsSnapshotWriter; import org.apache.kafka.snapshot.SnapshotReader; import org.apache.kafka.snapshot.SnapshotWriter; + import org.slf4j.Logger; import java.net.InetSocketAddress; diff --git a/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClientDriver.java b/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClientDriver.java index 67fa3eff930b4..710c8b102f23a 100644 --- a/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClientDriver.java +++ b/raft/src/main/java/org/apache/kafka/raft/KafkaRaftClientDriver.java @@ -21,6 +21,7 @@ import org.apache.kafka.common.utils.LogContext; import org.apache.kafka.server.fault.FaultHandler; import org.apache.kafka.server.util.ShutdownableThread; + import org.slf4j.Logger; import java.util.concurrent.CompletableFuture; diff --git a/raft/src/main/java/org/apache/kafka/raft/LeaderState.java b/raft/src/main/java/org/apache/kafka/raft/LeaderState.java index fcb4a5950bc7f..a5f7c0b8f4b48 100644 --- a/raft/src/main/java/org/apache/kafka/raft/LeaderState.java +++ b/raft/src/main/java/org/apache/kafka/raft/LeaderState.java @@ -28,6 +28,7 @@ import org.apache.kafka.raft.internals.BatchAccumulator; import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.raft.internals.VoterSet; + import org.slf4j.Logger; import java.util.ArrayList; diff --git a/raft/src/main/java/org/apache/kafka/raft/QuorumState.java b/raft/src/main/java/org/apache/kafka/raft/QuorumState.java index b46d520a6202c..6e8da1eac417c 100644 --- a/raft/src/main/java/org/apache/kafka/raft/QuorumState.java +++ b/raft/src/main/java/org/apache/kafka/raft/QuorumState.java @@ -16,15 +16,6 @@ */ package org.apache.kafka.raft; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.Random; -import java.util.function.Supplier; - import org.apache.kafka.common.Node; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.network.ListenerName; @@ -33,8 +24,18 @@ import org.apache.kafka.raft.internals.BatchAccumulator; import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.raft.internals.VoterSet; + import org.slf4j.Logger; +import java.io.IOException; +import java.io.UncheckedIOException; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.Random; +import java.util.function.Supplier; + /** * This class is responsible for managing the current state of this node and ensuring * only valid state transitions. Below we define the possible state transitions and diff --git a/raft/src/main/java/org/apache/kafka/raft/RaftRequest.java b/raft/src/main/java/org/apache/kafka/raft/RaftRequest.java index 5a1fe708e84c9..a7ad8f2e61f05 100644 --- a/raft/src/main/java/org/apache/kafka/raft/RaftRequest.java +++ b/raft/src/main/java/org/apache/kafka/raft/RaftRequest.java @@ -16,8 +16,8 @@ */ package org.apache.kafka.raft; -import org.apache.kafka.common.protocol.ApiMessage; import org.apache.kafka.common.Node; +import org.apache.kafka.common.protocol.ApiMessage; import java.util.concurrent.CompletableFuture; diff --git a/raft/src/main/java/org/apache/kafka/raft/ReplicatedCounter.java b/raft/src/main/java/org/apache/kafka/raft/ReplicatedCounter.java index 18a90a7b0bd3f..2758481ef6936 100644 --- a/raft/src/main/java/org/apache/kafka/raft/ReplicatedCounter.java +++ b/raft/src/main/java/org/apache/kafka/raft/ReplicatedCounter.java @@ -16,14 +16,17 @@ */ package org.apache.kafka.raft; -import java.util.Optional; -import java.util.OptionalInt; import org.apache.kafka.common.KafkaException; import org.apache.kafka.common.utils.LogContext; import org.apache.kafka.raft.errors.NotLeaderException; import org.apache.kafka.snapshot.SnapshotReader; import org.apache.kafka.snapshot.SnapshotWriter; + import org.slf4j.Logger; + +import java.util.Optional; +import java.util.OptionalInt; + import static java.util.Collections.singletonList; public class ReplicatedCounter implements RaftClient.Listener { diff --git a/raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java b/raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java index fdc5c5fb0df3c..dbf5133f35bbc 100644 --- a/raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java +++ b/raft/src/main/java/org/apache/kafka/raft/ReplicatedLog.java @@ -16,13 +16,14 @@ */ package org.apache.kafka.raft; -import java.util.Optional; import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.record.Records; import org.apache.kafka.snapshot.RawSnapshotReader; import org.apache.kafka.snapshot.RawSnapshotWriter; +import java.util.Optional; + public interface ReplicatedLog extends AutoCloseable { /** diff --git a/raft/src/main/java/org/apache/kafka/raft/RequestManager.java b/raft/src/main/java/org/apache/kafka/raft/RequestManager.java index ad331cdde8343..d850ea4ab5867 100644 --- a/raft/src/main/java/org/apache/kafka/raft/RequestManager.java +++ b/raft/src/main/java/org/apache/kafka/raft/RequestManager.java @@ -16,6 +16,8 @@ */ package org.apache.kafka.raft; +import org.apache.kafka.common.Node; + import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -24,7 +26,6 @@ import java.util.Optional; import java.util.OptionalLong; import java.util.Random; -import org.apache.kafka.common.Node; /** * The request manager keeps tracks of the connection with remote replicas. diff --git a/raft/src/main/java/org/apache/kafka/raft/ResignedState.java b/raft/src/main/java/org/apache/kafka/raft/ResignedState.java index 58f1d5d2fa0c3..a28c3155594e2 100644 --- a/raft/src/main/java/org/apache/kafka/raft/ResignedState.java +++ b/raft/src/main/java/org/apache/kafka/raft/ResignedState.java @@ -20,6 +20,7 @@ import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.Timer; import org.apache.kafka.raft.internals.ReplicaKey; + import org.slf4j.Logger; import java.util.HashSet; diff --git a/raft/src/main/java/org/apache/kafka/raft/UnattachedState.java b/raft/src/main/java/org/apache/kafka/raft/UnattachedState.java index a5ed20cc6da9d..e7805ce061e55 100644 --- a/raft/src/main/java/org/apache/kafka/raft/UnattachedState.java +++ b/raft/src/main/java/org/apache/kafka/raft/UnattachedState.java @@ -20,6 +20,7 @@ import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.Timer; import org.apache.kafka.raft.internals.ReplicaKey; + import org.slf4j.Logger; import java.util.Optional; diff --git a/raft/src/main/java/org/apache/kafka/raft/VotedState.java b/raft/src/main/java/org/apache/kafka/raft/VotedState.java index 550f0147548fe..b95803ce867d1 100644 --- a/raft/src/main/java/org/apache/kafka/raft/VotedState.java +++ b/raft/src/main/java/org/apache/kafka/raft/VotedState.java @@ -16,14 +16,16 @@ */ package org.apache.kafka.raft; -import java.util.Optional; -import java.util.Set; import org.apache.kafka.common.utils.LogContext; import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.Timer; import org.apache.kafka.raft.internals.ReplicaKey; + import org.slf4j.Logger; +import java.util.Optional; +import java.util.Set; + /** * The "voted" state is for voters who have cast their vote for a specific candidate. * diff --git a/raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java b/raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java index 2f2ac952c87cf..ce629cc44ef9e 100644 --- a/raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java +++ b/raft/src/main/java/org/apache/kafka/raft/internals/BatchAccumulator.java @@ -19,6 +19,9 @@ import org.apache.kafka.common.compress.Compression; import org.apache.kafka.common.errors.RecordBatchTooLargeException; import org.apache.kafka.common.memory.MemoryPool; +import org.apache.kafka.common.message.LeaderChangeMessage; +import org.apache.kafka.common.message.SnapshotFooterRecord; +import org.apache.kafka.common.message.SnapshotHeaderRecord; import org.apache.kafka.common.protocol.ObjectSerializationCache; import org.apache.kafka.common.record.MemoryRecords; import org.apache.kafka.common.record.MutableRecordBatch; @@ -28,20 +31,17 @@ import org.apache.kafka.raft.errors.UnexpectedBaseOffsetException; import org.apache.kafka.server.common.serialization.RecordSerde; -import org.apache.kafka.common.message.LeaderChangeMessage; -import org.apache.kafka.common.message.SnapshotHeaderRecord; -import org.apache.kafka.common.message.SnapshotFooterRecord; import java.io.Closeable; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.Iterator; import java.util.List; import java.util.Objects; import java.util.Optional; import java.util.OptionalInt; import java.util.OptionalLong; -import java.util.Iterator; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.locks.ReentrantLock; diff --git a/raft/src/main/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachine.java b/raft/src/main/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachine.java index 6c5321777a0c9..c4c7b274fabda 100644 --- a/raft/src/main/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachine.java +++ b/raft/src/main/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachine.java @@ -16,8 +16,6 @@ */ package org.apache.kafka.raft.internals; -import java.util.Optional; -import java.util.OptionalLong; import org.apache.kafka.common.message.KRaftVersionRecord; import org.apache.kafka.common.message.VotersRecord; import org.apache.kafka.common.utils.BufferSupplier; @@ -31,8 +29,12 @@ import org.apache.kafka.snapshot.RawSnapshotReader; import org.apache.kafka.snapshot.RecordsSnapshotReader; import org.apache.kafka.snapshot.SnapshotReader; + import org.slf4j.Logger; +import java.util.Optional; +import java.util.OptionalLong; + /** * The KRaft state machine for tracking control records in the topic partition. * diff --git a/raft/src/main/java/org/apache/kafka/raft/internals/RecordsIterator.java b/raft/src/main/java/org/apache/kafka/raft/internals/RecordsIterator.java index 6123f5188ed3b..8299138974802 100644 --- a/raft/src/main/java/org/apache/kafka/raft/internals/RecordsIterator.java +++ b/raft/src/main/java/org/apache/kafka/raft/internals/RecordsIterator.java @@ -16,17 +16,6 @@ */ package org.apache.kafka.raft.internals; -import java.io.IOException; -import java.io.InputStream; -import java.io.UncheckedIOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Optional; -import java.util.function.BiFunction; import org.apache.kafka.common.protocol.ApiMessage; import org.apache.kafka.common.protocol.ByteBufferAccessor; import org.apache.kafka.common.record.ControlRecordType; @@ -43,6 +32,18 @@ import org.apache.kafka.raft.ControlRecord; import org.apache.kafka.server.common.serialization.RecordSerde; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.function.BiFunction; + public final class RecordsIterator implements Iterator>, AutoCloseable { private final Records records; private final RecordSerde serde; diff --git a/raft/src/main/java/org/apache/kafka/raft/internals/ReplicaKey.java b/raft/src/main/java/org/apache/kafka/raft/internals/ReplicaKey.java index 002a2dee1914a..a222787137abc 100644 --- a/raft/src/main/java/org/apache/kafka/raft/internals/ReplicaKey.java +++ b/raft/src/main/java/org/apache/kafka/raft/internals/ReplicaKey.java @@ -16,9 +16,10 @@ */ package org.apache.kafka.raft.internals; +import org.apache.kafka.common.Uuid; + import java.util.Objects; import java.util.Optional; -import org.apache.kafka.common.Uuid; public final class ReplicaKey { private final int id; diff --git a/raft/src/main/java/org/apache/kafka/raft/internals/TreeMapLogHistory.java b/raft/src/main/java/org/apache/kafka/raft/internals/TreeMapLogHistory.java index fdffc6b0f41b4..5625eeb5c177d 100644 --- a/raft/src/main/java/org/apache/kafka/raft/internals/TreeMapLogHistory.java +++ b/raft/src/main/java/org/apache/kafka/raft/internals/TreeMapLogHistory.java @@ -16,10 +16,10 @@ */ package org.apache.kafka.raft.internals; +import java.util.Map; import java.util.NavigableMap; import java.util.Optional; import java.util.TreeMap; -import java.util.Map; /** * A implementation for {@code LogHistory} which uses a red-black tree to store values sorted by offset. diff --git a/raft/src/main/java/org/apache/kafka/raft/internals/VoterSet.java b/raft/src/main/java/org/apache/kafka/raft/internals/VoterSet.java index ae245e0b91fe5..faff794c81d03 100644 --- a/raft/src/main/java/org/apache/kafka/raft/internals/VoterSet.java +++ b/raft/src/main/java/org/apache/kafka/raft/internals/VoterSet.java @@ -16,6 +16,13 @@ */ package org.apache.kafka.raft.internals; +import org.apache.kafka.common.Node; +import org.apache.kafka.common.Uuid; +import org.apache.kafka.common.feature.SupportedVersionRange; +import org.apache.kafka.common.message.VotersRecord; +import org.apache.kafka.common.network.ListenerName; +import org.apache.kafka.common.utils.Utils; + import java.net.InetSocketAddress; import java.util.Collections; import java.util.HashMap; @@ -30,13 +37,6 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.kafka.common.Node; -import org.apache.kafka.common.Uuid; -import org.apache.kafka.common.feature.SupportedVersionRange; -import org.apache.kafka.common.message.VotersRecord; -import org.apache.kafka.common.network.ListenerName; -import org.apache.kafka.common.utils.Utils; - /** * A type for representing the set of voters for a topic partition. * diff --git a/raft/src/main/java/org/apache/kafka/snapshot/NotifyingRawSnapshotWriter.java b/raft/src/main/java/org/apache/kafka/snapshot/NotifyingRawSnapshotWriter.java index 0ffba500953e9..76b27f45c82f6 100644 --- a/raft/src/main/java/org/apache/kafka/snapshot/NotifyingRawSnapshotWriter.java +++ b/raft/src/main/java/org/apache/kafka/snapshot/NotifyingRawSnapshotWriter.java @@ -16,11 +16,12 @@ */ package org.apache.kafka.snapshot; -import java.util.function.Consumer; import org.apache.kafka.common.record.MemoryRecords; import org.apache.kafka.common.record.UnalignedMemoryRecords; import org.apache.kafka.raft.OffsetAndEpoch; +import java.util.function.Consumer; + /** * A thin facade for a {@code RawSnapshotWriter} that notifies a callback when freeze completes successfully. */ diff --git a/raft/src/main/java/org/apache/kafka/snapshot/RecordsSnapshotReader.java b/raft/src/main/java/org/apache/kafka/snapshot/RecordsSnapshotReader.java index 20b6c0eaab857..c865dc2a1a469 100644 --- a/raft/src/main/java/org/apache/kafka/snapshot/RecordsSnapshotReader.java +++ b/raft/src/main/java/org/apache/kafka/snapshot/RecordsSnapshotReader.java @@ -17,9 +17,6 @@ package org.apache.kafka.snapshot; -import java.util.NoSuchElementException; -import java.util.Optional; -import java.util.OptionalLong; import org.apache.kafka.common.message.SnapshotHeaderRecord; import org.apache.kafka.common.record.ControlRecordType; import org.apache.kafka.common.utils.BufferSupplier; @@ -28,6 +25,10 @@ import org.apache.kafka.raft.internals.RecordsIterator; import org.apache.kafka.server.common.serialization.RecordSerde; +import java.util.NoSuchElementException; +import java.util.Optional; +import java.util.OptionalLong; + public final class RecordsSnapshotReader implements SnapshotReader { private final OffsetAndEpoch snapshotId; private final RecordsIterator iterator; diff --git a/raft/src/main/java/org/apache/kafka/snapshot/RecordsSnapshotWriter.java b/raft/src/main/java/org/apache/kafka/snapshot/RecordsSnapshotWriter.java index 51839fe192a20..30176bdfc70c7 100644 --- a/raft/src/main/java/org/apache/kafka/snapshot/RecordsSnapshotWriter.java +++ b/raft/src/main/java/org/apache/kafka/snapshot/RecordsSnapshotWriter.java @@ -28,8 +28,8 @@ import org.apache.kafka.common.record.TimestampType; import org.apache.kafka.common.utils.Time; import org.apache.kafka.raft.OffsetAndEpoch; -import org.apache.kafka.raft.internals.BatchAccumulator.CompletedBatch; import org.apache.kafka.raft.internals.BatchAccumulator; +import org.apache.kafka.raft.internals.BatchAccumulator.CompletedBatch; import org.apache.kafka.raft.internals.VoterSet; import org.apache.kafka.server.common.serialization.RecordSerde; diff --git a/raft/src/main/java/org/apache/kafka/snapshot/SnapshotPath.java b/raft/src/main/java/org/apache/kafka/snapshot/SnapshotPath.java index 16237a91f886c..9a7d95e45e9c4 100644 --- a/raft/src/main/java/org/apache/kafka/snapshot/SnapshotPath.java +++ b/raft/src/main/java/org/apache/kafka/snapshot/SnapshotPath.java @@ -16,9 +16,10 @@ */ package org.apache.kafka.snapshot; -import java.nio.file.Path; import org.apache.kafka.raft.OffsetAndEpoch; +import java.nio.file.Path; + public final class SnapshotPath { public final Path path; public final OffsetAndEpoch snapshotId; diff --git a/raft/src/main/java/org/apache/kafka/snapshot/SnapshotWriter.java b/raft/src/main/java/org/apache/kafka/snapshot/SnapshotWriter.java index 244cc5478f46e..5a43d81a07b28 100644 --- a/raft/src/main/java/org/apache/kafka/snapshot/SnapshotWriter.java +++ b/raft/src/main/java/org/apache/kafka/snapshot/SnapshotWriter.java @@ -16,8 +16,8 @@ */ package org.apache.kafka.snapshot; -import org.apache.kafka.raft.OffsetAndEpoch; import org.apache.kafka.common.message.SnapshotFooterRecord; +import org.apache.kafka.raft.OffsetAndEpoch; import java.util.List; diff --git a/raft/src/main/java/org/apache/kafka/snapshot/Snapshots.java b/raft/src/main/java/org/apache/kafka/snapshot/Snapshots.java index 2a4d4f37a6e9c..c3c008a116579 100644 --- a/raft/src/main/java/org/apache/kafka/snapshot/Snapshots.java +++ b/raft/src/main/java/org/apache/kafka/snapshot/Snapshots.java @@ -17,10 +17,11 @@ package org.apache.kafka.snapshot; import org.apache.kafka.common.utils.BufferSupplier; +import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.KafkaRaftClient; import org.apache.kafka.raft.OffsetAndEpoch; -import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.internals.IdentitySerde; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/raft/src/test/java/org/apache/kafka/raft/CandidateStateTest.java b/raft/src/test/java/org/apache/kafka/raft/CandidateStateTest.java index 9aa5eeab4994e..42904f994d299 100644 --- a/raft/src/test/java/org/apache/kafka/raft/CandidateStateTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/CandidateStateTest.java @@ -22,6 +22,7 @@ import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.raft.internals.VoterSet; import org.apache.kafka.raft.internals.VoterSetTest; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/ControlRecordTest.java b/raft/src/test/java/org/apache/kafka/raft/ControlRecordTest.java index fc5c670beb075..fed7bf21664ad 100644 --- a/raft/src/test/java/org/apache/kafka/raft/ControlRecordTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/ControlRecordTest.java @@ -23,10 +23,12 @@ import org.apache.kafka.common.message.VotersRecord; import org.apache.kafka.common.protocol.ApiMessage; import org.apache.kafka.common.record.ControlRecordType; + import org.junit.jupiter.api.Test; import org.mockito.Mockito; -import static org.junit.jupiter.api.Assertions.assertThrows; + import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public final class ControlRecordTest { @Test diff --git a/raft/src/test/java/org/apache/kafka/raft/ElectionStateTest.java b/raft/src/test/java/org/apache/kafka/raft/ElectionStateTest.java index c0b135c60f1c6..26ec18bbe3245 100644 --- a/raft/src/test/java/org/apache/kafka/raft/ElectionStateTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/ElectionStateTest.java @@ -16,17 +16,20 @@ */ package org.apache.kafka.raft; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.generated.QuorumStateData; import org.apache.kafka.raft.internals.ReplicaKey; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Optional; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/raft/src/test/java/org/apache/kafka/raft/FileQuorumStateStoreTest.java b/raft/src/test/java/org/apache/kafka/raft/FileQuorumStateStoreTest.java index d7ed2c8fa9407..b39f069ade483 100644 --- a/raft/src/test/java/org/apache/kafka/raft/FileQuorumStateStoreTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/FileQuorumStateStoreTest.java @@ -16,8 +16,6 @@ */ package org.apache.kafka.raft; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.protocol.types.TaggedFields; import org.apache.kafka.common.utils.Utils; @@ -25,6 +23,13 @@ import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.test.TestUtils; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; + import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; @@ -35,9 +40,6 @@ import java.util.Collections; import java.util.Optional; import java.util.Set; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.ValueSource; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/raft/src/test/java/org/apache/kafka/raft/FollowerStateTest.java b/raft/src/test/java/org/apache/kafka/raft/FollowerStateTest.java index ab699159d0df5..a6008905f074e 100644 --- a/raft/src/test/java/org/apache/kafka/raft/FollowerStateTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/FollowerStateTest.java @@ -21,6 +21,7 @@ import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.internals.ReplicaKey; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/KafkaNetworkChannelTest.java b/raft/src/test/java/org/apache/kafka/raft/KafkaNetworkChannelTest.java index 6b013bac46284..725c4ea10247d 100644 --- a/raft/src/test/java/org/apache/kafka/raft/KafkaNetworkChannelTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/KafkaNetworkChannelTest.java @@ -49,6 +49,7 @@ import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.common.utils.Time; import org.apache.kafka.common.utils.annotation.ApiKeyVersionsSource; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; diff --git a/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientDriverTest.java b/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientDriverTest.java index f4206dab4de61..77ca890b8fbab 100644 --- a/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientDriverTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientDriverTest.java @@ -18,6 +18,7 @@ import org.apache.kafka.common.utils.LogContext; import org.apache.kafka.server.fault.MockFaultHandler; + import org.junit.jupiter.api.Test; import org.mockito.Mockito; diff --git a/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientSnapshotTest.java b/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientSnapshotTest.java index bfa9f9854178b..3f8bc98559a83 100644 --- a/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientSnapshotTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientSnapshotTest.java @@ -30,10 +30,11 @@ import org.apache.kafka.raft.internals.StringSerde; import org.apache.kafka.snapshot.RawSnapshotReader; import org.apache.kafka.snapshot.RawSnapshotWriter; -import org.apache.kafka.snapshot.SnapshotWriter; -import org.apache.kafka.snapshot.SnapshotReader; import org.apache.kafka.snapshot.RecordsSnapshotWriter; +import org.apache.kafka.snapshot.SnapshotReader; +import org.apache.kafka.snapshot.SnapshotWriter; import org.apache.kafka.snapshot.SnapshotWriterReaderTest; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -44,16 +45,16 @@ import java.util.Collections; import java.util.List; import java.util.Optional; -import java.util.OptionalLong; import java.util.OptionalInt; +import java.util.OptionalLong; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertInstanceOf; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; public final class KafkaRaftClientSnapshotTest { @Test diff --git a/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java b/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java index 3844725ec12ac..23b3447543b3f 100644 --- a/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/KafkaRaftClientTest.java @@ -24,9 +24,9 @@ import org.apache.kafka.common.message.DescribeQuorumResponseData; import org.apache.kafka.common.message.DescribeQuorumResponseData.ReplicaState; import org.apache.kafka.common.message.EndQuorumEpochResponseData; +import org.apache.kafka.common.message.FetchRequestData; import org.apache.kafka.common.message.FetchResponseData; import org.apache.kafka.common.message.VoteResponseData; -import org.apache.kafka.common.message.FetchRequestData; import org.apache.kafka.common.metrics.KafkaMetric; import org.apache.kafka.common.metrics.Metrics; import org.apache.kafka.common.protocol.ApiKeys; @@ -46,6 +46,7 @@ import org.apache.kafka.raft.errors.UnexpectedBaseOffsetException; import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.test.TestUtils; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/LeaderStateTest.java b/raft/src/test/java/org/apache/kafka/raft/LeaderStateTest.java index 20b9e0b3f29c7..dadddc522c47c 100644 --- a/raft/src/test/java/org/apache/kafka/raft/LeaderStateTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/LeaderStateTest.java @@ -23,6 +23,7 @@ import org.apache.kafka.raft.internals.BatchAccumulator; import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.raft.internals.VoterSet; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/MockExpirationServiceTest.java b/raft/src/test/java/org/apache/kafka/raft/MockExpirationServiceTest.java index 10ee16aafd9df..57fb701304743 100644 --- a/raft/src/test/java/org/apache/kafka/raft/MockExpirationServiceTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/MockExpirationServiceTest.java @@ -19,6 +19,7 @@ import org.apache.kafka.common.errors.TimeoutException; import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.test.TestUtils; + import org.junit.jupiter.api.Test; import java.util.concurrent.CompletableFuture; diff --git a/raft/src/test/java/org/apache/kafka/raft/MockLog.java b/raft/src/test/java/org/apache/kafka/raft/MockLog.java index cd977a193bc72..8247e13708628 100644 --- a/raft/src/test/java/org/apache/kafka/raft/MockLog.java +++ b/raft/src/test/java/org/apache/kafka/raft/MockLog.java @@ -33,6 +33,7 @@ import org.apache.kafka.snapshot.MockRawSnapshotWriter; import org.apache.kafka.snapshot.RawSnapshotReader; import org.apache.kafka.snapshot.RawSnapshotWriter; + import org.slf4j.Logger; import java.nio.ByteBuffer; diff --git a/raft/src/test/java/org/apache/kafka/raft/MockLogTest.java b/raft/src/test/java/org/apache/kafka/raft/MockLogTest.java index f57669da86411..c56bbe01adb2f 100644 --- a/raft/src/test/java/org/apache/kafka/raft/MockLogTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/MockLogTest.java @@ -31,6 +31,7 @@ import org.apache.kafka.common.utils.Utils; import org.apache.kafka.snapshot.RawSnapshotReader; import org.apache.kafka.snapshot.RawSnapshotWriter; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/raft/src/test/java/org/apache/kafka/raft/MockQuorumStateStore.java b/raft/src/test/java/org/apache/kafka/raft/MockQuorumStateStore.java index 0a94a217358aa..b164fc2bf8e91 100644 --- a/raft/src/test/java/org/apache/kafka/raft/MockQuorumStateStore.java +++ b/raft/src/test/java/org/apache/kafka/raft/MockQuorumStateStore.java @@ -16,10 +16,11 @@ */ package org.apache.kafka.raft; +import org.apache.kafka.raft.generated.QuorumStateData; + import java.nio.file.FileSystems; import java.nio.file.Path; import java.util.Optional; -import org.apache.kafka.raft.generated.QuorumStateData; public class MockQuorumStateStore implements QuorumStateStore { private Optional current = Optional.empty(); diff --git a/raft/src/test/java/org/apache/kafka/raft/QuorumStateTest.java b/raft/src/test/java/org/apache/kafka/raft/QuorumStateTest.java index 94567dce6658c..3438ecf50a27c 100644 --- a/raft/src/test/java/org/apache/kafka/raft/QuorumStateTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/QuorumStateTest.java @@ -25,6 +25,7 @@ import org.apache.kafka.raft.internals.ReplicaKey; import org.apache.kafka.raft.internals.VoterSet; import org.apache.kafka.raft.internals.VoterSetTest; + import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; import org.mockito.Mockito; diff --git a/raft/src/test/java/org/apache/kafka/raft/RaftEventSimulationTest.java b/raft/src/test/java/org/apache/kafka/raft/RaftEventSimulationTest.java index c074f8c7617c6..88c3d00c86688 100644 --- a/raft/src/test/java/org/apache/kafka/raft/RaftEventSimulationTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/RaftEventSimulationTest.java @@ -16,11 +16,6 @@ */ package org.apache.kafka.raft; -import net.jqwik.api.AfterFailureMode; -import net.jqwik.api.ForAll; -import net.jqwik.api.Property; -import net.jqwik.api.Tag; -import net.jqwik.api.constraints.IntRange; import org.apache.kafka.common.Node; import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.Uuid; @@ -42,6 +37,12 @@ import org.apache.kafka.snapshot.RecordsSnapshotReader; import org.apache.kafka.snapshot.SnapshotReader; +import net.jqwik.api.AfterFailureMode; +import net.jqwik.api.ForAll; +import net.jqwik.api.Property; +import net.jqwik.api.Tag; +import net.jqwik.api.constraints.IntRange; + import java.net.InetSocketAddress; import java.nio.ByteBuffer; import java.util.ArrayList; diff --git a/raft/src/test/java/org/apache/kafka/raft/RequestManagerTest.java b/raft/src/test/java/org/apache/kafka/raft/RequestManagerTest.java index 326222e18c47d..a07426ee07bfc 100644 --- a/raft/src/test/java/org/apache/kafka/raft/RequestManagerTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/RequestManagerTest.java @@ -18,6 +18,7 @@ import org.apache.kafka.common.Node; import org.apache.kafka.common.utils.MockTime; + import org.junit.jupiter.api.Test; import java.util.List; @@ -28,8 +29,8 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class RequestManagerTest { private final MockTime time = new MockTime(); diff --git a/raft/src/test/java/org/apache/kafka/raft/ResignedStateTest.java b/raft/src/test/java/org/apache/kafka/raft/ResignedStateTest.java index 88e6f9ff7b24f..17a85450f9978 100644 --- a/raft/src/test/java/org/apache/kafka/raft/ResignedStateTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/ResignedStateTest.java @@ -20,6 +20,7 @@ import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.internals.ReplicaKey; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/UnattachedStateTest.java b/raft/src/test/java/org/apache/kafka/raft/UnattachedStateTest.java index 3550cd92cbaae..3240d60107e14 100644 --- a/raft/src/test/java/org/apache/kafka/raft/UnattachedStateTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/UnattachedStateTest.java @@ -20,6 +20,7 @@ import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.internals.ReplicaKey; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/VotedStateTest.java b/raft/src/test/java/org/apache/kafka/raft/VotedStateTest.java index dca1a08b318ef..07eed8968bcef 100644 --- a/raft/src/test/java/org/apache/kafka/raft/VotedStateTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/VotedStateTest.java @@ -20,12 +20,13 @@ import org.apache.kafka.common.utils.LogContext; import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.raft.internals.ReplicaKey; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; -import java.util.Optional; import java.util.Collections; +import java.util.Optional; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/BatchAccumulatorTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/BatchAccumulatorTest.java index 9b70afbd7f53d..bb52b38e8e6e7 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/BatchAccumulatorTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/BatchAccumulatorTest.java @@ -34,6 +34,7 @@ import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.errors.UnexpectedBaseOffsetException; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/BatchBuilderTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/BatchBuilderTest.java index ba356fff4b6a1..5e82c0be82c22 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/BatchBuilderTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/BatchBuilderTest.java @@ -22,6 +22,7 @@ import org.apache.kafka.common.record.MutableRecordBatch; import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.common.utils.Utils; + import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/BatchMemoryPoolTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/BatchMemoryPoolTest.java index 5573f2a0f8346..ab4e7cf63231b 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/BatchMemoryPoolTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/BatchMemoryPoolTest.java @@ -16,11 +16,12 @@ */ package org.apache.kafka.raft.internals; +import org.junit.jupiter.api.Test; + import java.nio.ByteBuffer; import java.util.Collections; import java.util.IdentityHashMap; import java.util.Set; -import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/BlockingMessageQueueTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/BlockingMessageQueueTest.java index e752fbd6dd37d..eec68cc72b0c7 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/BlockingMessageQueueTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/BlockingMessageQueueTest.java @@ -17,6 +17,7 @@ package org.apache.kafka.raft.internals; import org.apache.kafka.raft.RaftMessage; + import org.junit.jupiter.api.Test; import org.mockito.Mockito; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachineTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachineTest.java index 82d51625eacbc..fc7c972404864 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachineTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/KRaftControlRecordStateMachineTest.java @@ -16,8 +16,6 @@ */ package org.apache.kafka.raft.internals; -import java.util.Optional; -import java.util.stream.IntStream; import org.apache.kafka.common.TopicPartition; import org.apache.kafka.common.Uuid; import org.apache.kafka.common.message.KRaftVersionRecord; @@ -28,7 +26,12 @@ import org.apache.kafka.raft.OffsetAndEpoch; import org.apache.kafka.server.common.serialization.RecordSerde; import org.apache.kafka.snapshot.RecordsSnapshotWriter; + import org.junit.jupiter.api.Test; + +import java.util.Optional; +import java.util.stream.IntStream; + import static org.junit.jupiter.api.Assertions.assertEquals; final class KRaftControlRecordStateMachineTest { diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/KafkaRaftMetricsTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/KafkaRaftMetricsTest.java index f84e81b18dd6e..49e749ebe5d01 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/KafkaRaftMetricsTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/KafkaRaftMetricsTest.java @@ -26,6 +26,7 @@ import org.apache.kafka.raft.MockQuorumStateStore; import org.apache.kafka.raft.OffsetAndEpoch; import org.apache.kafka.raft.QuorumState; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/MemoryBatchReaderTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/MemoryBatchReaderTest.java index 631b6b456d9cf..1ff6ccf9c51c2 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/MemoryBatchReaderTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/MemoryBatchReaderTest.java @@ -18,6 +18,7 @@ import org.apache.kafka.raft.Batch; import org.apache.kafka.raft.BatchReader; + import org.junit.jupiter.api.Test; import org.mockito.Mockito; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/RecordsBatchReaderTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/RecordsBatchReaderTest.java index 762fa4177a2de..6c125b50affc8 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/RecordsBatchReaderTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/RecordsBatchReaderTest.java @@ -26,6 +26,7 @@ import org.apache.kafka.raft.BatchReader; import org.apache.kafka.raft.ControlRecord; import org.apache.kafka.raft.internals.RecordsIteratorTest.TestBatch; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/RecordsIteratorTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/RecordsIteratorTest.java index e8896f3b57683..9acf142bce8e8 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/RecordsIteratorTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/RecordsIteratorTest.java @@ -16,24 +16,6 @@ */ package org.apache.kafka.raft.internals; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Objects; -import java.util.Optional; -import java.util.Random; -import java.util.Set; -import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.Collectors; -import java.util.stream.IntStream; -import java.util.stream.Stream; -import net.jqwik.api.ForAll; -import net.jqwik.api.Property; import org.apache.kafka.common.compress.Compression; import org.apache.kafka.common.errors.CorruptRecordException; import org.apache.kafka.common.message.KRaftVersionRecord; @@ -62,12 +44,34 @@ import org.apache.kafka.snapshot.MockRawSnapshotWriter; import org.apache.kafka.snapshot.RecordsSnapshotWriter; import org.apache.kafka.test.TestUtils; + +import net.jqwik.api.ForAll; +import net.jqwik.api.Property; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.EnumSource; import org.junit.jupiter.params.provider.MethodSource; import org.mockito.Mockito; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.Optional; +import java.util.Random; +import java.util.Set; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.Collectors; +import java.util.stream.IntStream; +import java.util.stream.Stream; + import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/ThresholdPurgatoryTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/ThresholdPurgatoryTest.java index 78164272e7b57..cb745239bca39 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/ThresholdPurgatoryTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/ThresholdPurgatoryTest.java @@ -20,6 +20,7 @@ import org.apache.kafka.common.errors.TimeoutException; import org.apache.kafka.common.utils.MockTime; import org.apache.kafka.raft.MockExpirationService; + import org.junit.jupiter.api.Test; import java.util.concurrent.CompletableFuture; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/TimeRatioTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/TimeRatioTest.java index 60901c0d63505..94e8844734db1 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/TimeRatioTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/TimeRatioTest.java @@ -18,6 +18,7 @@ import org.apache.kafka.common.metrics.MetricConfig; import org.apache.kafka.common.utils.MockTime; + import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/TreeMapLogHistoryTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/TreeMapLogHistoryTest.java index 852e935103aec..b428eda25a2f3 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/TreeMapLogHistoryTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/TreeMapLogHistoryTest.java @@ -16,8 +16,10 @@ */ package org.apache.kafka.raft.internals; -import java.util.Optional; import org.junit.jupiter.api.Test; + +import java.util.Optional; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/VoterSetHistoryTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/VoterSetHistoryTest.java index d0ca014d77456..4931614fed046 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/VoterSetHistoryTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/VoterSetHistoryTest.java @@ -16,11 +16,13 @@ */ package org.apache.kafka.raft.internals; +import org.junit.jupiter.api.Test; + import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.stream.IntStream; -import org.junit.jupiter.api.Test; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/raft/src/test/java/org/apache/kafka/raft/internals/VoterSetTest.java b/raft/src/test/java/org/apache/kafka/raft/internals/VoterSetTest.java index 2934d2f7efc8b..17ef319625acd 100644 --- a/raft/src/test/java/org/apache/kafka/raft/internals/VoterSetTest.java +++ b/raft/src/test/java/org/apache/kafka/raft/internals/VoterSetTest.java @@ -16,6 +16,14 @@ */ package org.apache.kafka.raft.internals; +import org.apache.kafka.common.Node; +import org.apache.kafka.common.Uuid; +import org.apache.kafka.common.feature.SupportedVersionRange; +import org.apache.kafka.common.network.ListenerName; +import org.apache.kafka.common.utils.Utils; + +import org.junit.jupiter.api.Test; + import java.net.InetSocketAddress; import java.util.Arrays; import java.util.Collections; @@ -27,12 +35,7 @@ import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; -import org.apache.kafka.common.Node; -import org.apache.kafka.common.Uuid; -import org.apache.kafka.common.feature.SupportedVersionRange; -import org.apache.kafka.common.network.ListenerName; -import org.apache.kafka.common.utils.Utils; -import org.junit.jupiter.api.Test; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/raft/src/test/java/org/apache/kafka/snapshot/FileRawSnapshotTest.java b/raft/src/test/java/org/apache/kafka/snapshot/FileRawSnapshotTest.java index 45c4ce5ca678e..9a906dd631f30 100644 --- a/raft/src/test/java/org/apache/kafka/snapshot/FileRawSnapshotTest.java +++ b/raft/src/test/java/org/apache/kafka/snapshot/FileRawSnapshotTest.java @@ -17,16 +17,17 @@ package org.apache.kafka.snapshot; import org.apache.kafka.common.compress.Compression; -import org.apache.kafka.common.utils.BufferSupplier.GrowableBufferSupplier; import org.apache.kafka.common.record.MemoryRecords; import org.apache.kafka.common.record.Record; import org.apache.kafka.common.record.RecordBatch; import org.apache.kafka.common.record.SimpleRecord; import org.apache.kafka.common.record.UnalignedFileRecords; import org.apache.kafka.common.record.UnalignedMemoryRecords; +import org.apache.kafka.common.utils.BufferSupplier.GrowableBufferSupplier; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.OffsetAndEpoch; import org.apache.kafka.test.TestUtils; + import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; diff --git a/raft/src/test/java/org/apache/kafka/snapshot/MockRawSnapshotReader.java b/raft/src/test/java/org/apache/kafka/snapshot/MockRawSnapshotReader.java index 0e0a35de86206..b1c84c3d4593e 100644 --- a/raft/src/test/java/org/apache/kafka/snapshot/MockRawSnapshotReader.java +++ b/raft/src/test/java/org/apache/kafka/snapshot/MockRawSnapshotReader.java @@ -16,13 +16,14 @@ */ package org.apache.kafka.snapshot; -import java.nio.ByteBuffer; import org.apache.kafka.common.record.MemoryRecords; import org.apache.kafka.common.record.Records; import org.apache.kafka.common.record.UnalignedMemoryRecords; import org.apache.kafka.common.record.UnalignedRecords; import org.apache.kafka.raft.OffsetAndEpoch; +import java.nio.ByteBuffer; + public final class MockRawSnapshotReader implements RawSnapshotReader { private final OffsetAndEpoch snapshotId; private final MemoryRecords data; diff --git a/raft/src/test/java/org/apache/kafka/snapshot/MockRawSnapshotWriter.java b/raft/src/test/java/org/apache/kafka/snapshot/MockRawSnapshotWriter.java index 103eb3781c696..edc33ee4e2974 100644 --- a/raft/src/test/java/org/apache/kafka/snapshot/MockRawSnapshotWriter.java +++ b/raft/src/test/java/org/apache/kafka/snapshot/MockRawSnapshotWriter.java @@ -16,13 +16,14 @@ */ package org.apache.kafka.snapshot; -import java.nio.ByteBuffer; -import java.util.function.Consumer; import org.apache.kafka.common.record.MemoryRecords; import org.apache.kafka.common.record.UnalignedMemoryRecords; import org.apache.kafka.common.utils.ByteBufferOutputStream; import org.apache.kafka.raft.OffsetAndEpoch; +import java.nio.ByteBuffer; +import java.util.function.Consumer; + public final class MockRawSnapshotWriter implements RawSnapshotWriter { private final ByteBufferOutputStream data = new ByteBufferOutputStream(0); private final OffsetAndEpoch snapshotId; diff --git a/raft/src/test/java/org/apache/kafka/snapshot/NotifyingRawSnapshotWriterTest.java b/raft/src/test/java/org/apache/kafka/snapshot/NotifyingRawSnapshotWriterTest.java index 4b9232134cc89..7e9de94c589cc 100644 --- a/raft/src/test/java/org/apache/kafka/snapshot/NotifyingRawSnapshotWriterTest.java +++ b/raft/src/test/java/org/apache/kafka/snapshot/NotifyingRawSnapshotWriterTest.java @@ -16,12 +16,15 @@ */ package org.apache.kafka.snapshot; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.function.Consumer; import org.apache.kafka.common.record.MemoryRecords; import org.apache.kafka.common.record.UnalignedMemoryRecords; import org.apache.kafka.raft.OffsetAndEpoch; + import org.junit.jupiter.api.Test; + +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.function.Consumer; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/raft/src/test/java/org/apache/kafka/snapshot/RecordsSnapshotWriterTest.java b/raft/src/test/java/org/apache/kafka/snapshot/RecordsSnapshotWriterTest.java index 32a980296b10b..ea25ce1d12058 100644 --- a/raft/src/test/java/org/apache/kafka/snapshot/RecordsSnapshotWriterTest.java +++ b/raft/src/test/java/org/apache/kafka/snapshot/RecordsSnapshotWriterTest.java @@ -17,11 +17,6 @@ package org.apache.kafka.snapshot; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Optional; -import java.util.concurrent.atomic.AtomicReference; -import java.util.stream.IntStream; import org.apache.kafka.common.message.KRaftVersionRecord; import org.apache.kafka.common.message.SnapshotFooterRecord; import org.apache.kafka.common.message.SnapshotHeaderRecord; @@ -34,7 +29,15 @@ import org.apache.kafka.raft.internals.VoterSet; import org.apache.kafka.raft.internals.VoterSetTest; import org.apache.kafka.server.common.serialization.RecordSerde; + import org.junit.jupiter.api.Test; + +import java.nio.ByteBuffer; +import java.util.HashMap; +import java.util.Optional; +import java.util.concurrent.atomic.AtomicReference; +import java.util.stream.IntStream; + import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertThrows; diff --git a/raft/src/test/java/org/apache/kafka/snapshot/SnapshotWriterReaderTest.java b/raft/src/test/java/org/apache/kafka/snapshot/SnapshotWriterReaderTest.java index c1ffadda45455..0bc823a2728d6 100644 --- a/raft/src/test/java/org/apache/kafka/snapshot/SnapshotWriterReaderTest.java +++ b/raft/src/test/java/org/apache/kafka/snapshot/SnapshotWriterReaderTest.java @@ -16,28 +16,30 @@ */ package org.apache.kafka.snapshot; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import java.util.Optional; -import java.util.OptionalInt; -import java.util.Random; -import java.util.Set; import org.apache.kafka.common.message.SnapshotFooterRecord; import org.apache.kafka.common.message.SnapshotHeaderRecord; import org.apache.kafka.common.record.ControlRecordUtils; import org.apache.kafka.common.record.Record; import org.apache.kafka.common.record.RecordBatch; -import org.apache.kafka.common.utils.BufferSupplier.GrowableBufferSupplier; import org.apache.kafka.common.utils.BufferSupplier; +import org.apache.kafka.common.utils.BufferSupplier.GrowableBufferSupplier; import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.Batch; import org.apache.kafka.raft.OffsetAndEpoch; import org.apache.kafka.raft.RaftClientTestContext; import org.apache.kafka.raft.internals.StringSerde; + import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; +import java.util.OptionalInt; +import java.util.Random; +import java.util.Set; + import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; diff --git a/raft/src/test/java/org/apache/kafka/snapshot/SnapshotsTest.java b/raft/src/test/java/org/apache/kafka/snapshot/SnapshotsTest.java index bf32d64637835..5f7e25b5dde08 100644 --- a/raft/src/test/java/org/apache/kafka/snapshot/SnapshotsTest.java +++ b/raft/src/test/java/org/apache/kafka/snapshot/SnapshotsTest.java @@ -19,6 +19,7 @@ import org.apache.kafka.common.utils.Utils; import org.apache.kafka.raft.OffsetAndEpoch; import org.apache.kafka.test.TestUtils; + import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource;