Skip to content

Commit 25bff77

Browse files
committed
KAFKA-16907: reformat
1 parent 5acb0bc commit 25bff77

File tree

8 files changed

+368
-368
lines changed

8 files changed

+368
-368
lines changed

raft/src/main/java/org/apache/kafka/raft/utils/BeginQuorumEpochRpc.java

+57-57
Original file line numberDiff line numberDiff line change
@@ -31,72 +31,72 @@
3131

3232
public class BeginQuorumEpochRpc {
3333
public static BeginQuorumEpochRequestData singletonBeginQuorumEpochRequest(
34-
TopicPartition topicPartition,
35-
String clusterId,
36-
int leaderEpoch,
37-
int leaderId,
38-
Endpoints leaderEndpoints,
39-
ReplicaKey voterKey
34+
TopicPartition topicPartition,
35+
String clusterId,
36+
int leaderEpoch,
37+
int leaderId,
38+
Endpoints leaderEndpoints,
39+
ReplicaKey voterKey
4040
) {
4141
return new BeginQuorumEpochRequestData()
42-
.setClusterId(clusterId)
43-
.setVoterId(voterKey.id())
44-
.setTopics(
45-
Collections.singletonList(
46-
new BeginQuorumEpochRequestData.TopicData()
47-
.setTopicName(topicPartition.topic())
48-
.setPartitions(
49-
Collections.singletonList(
50-
new BeginQuorumEpochRequestData.PartitionData()
51-
.setPartitionIndex(topicPartition.partition())
52-
.setLeaderEpoch(leaderEpoch)
53-
.setLeaderId(leaderId)
54-
.setVoterDirectoryId(voterKey.directoryId().orElse(ReplicaKey.NO_DIRECTORY_ID))
55-
)
56-
)
42+
.setClusterId(clusterId)
43+
.setVoterId(voterKey.id())
44+
.setTopics(
45+
Collections.singletonList(
46+
new BeginQuorumEpochRequestData.TopicData()
47+
.setTopicName(topicPartition.topic())
48+
.setPartitions(
49+
Collections.singletonList(
50+
new BeginQuorumEpochRequestData.PartitionData()
51+
.setPartitionIndex(topicPartition.partition())
52+
.setLeaderEpoch(leaderEpoch)
53+
.setLeaderId(leaderId)
54+
.setVoterDirectoryId(voterKey.directoryId().orElse(ReplicaKey.NO_DIRECTORY_ID))
55+
)
5756
)
5857
)
59-
.setLeaderEndpoints(leaderEndpoints.toBeginQuorumEpochRequest());
58+
)
59+
.setLeaderEndpoints(leaderEndpoints.toBeginQuorumEpochRequest());
6060
}
6161

6262
public static BeginQuorumEpochResponseData singletonBeginQuorumEpochResponse(
63-
ListenerName listenerName,
64-
short apiVersion,
65-
Errors topLevelError,
66-
TopicPartition topicPartition,
67-
Errors partitionLevelError,
68-
int leaderEpoch,
69-
int leaderId,
70-
Endpoints endpoints
63+
ListenerName listenerName,
64+
short apiVersion,
65+
Errors topLevelError,
66+
TopicPartition topicPartition,
67+
Errors partitionLevelError,
68+
int leaderEpoch,
69+
int leaderId,
70+
Endpoints endpoints
7171
) {
7272
BeginQuorumEpochResponseData response = new BeginQuorumEpochResponseData()
73-
.setErrorCode(topLevelError.code())
74-
.setTopics(
75-
Collections.singletonList(
76-
new BeginQuorumEpochResponseData.TopicData()
77-
.setTopicName(topicPartition.topic())
78-
.setPartitions(
79-
Collections.singletonList(
80-
new BeginQuorumEpochResponseData.PartitionData()
81-
.setErrorCode(partitionLevelError.code())
82-
.setLeaderId(leaderId)
83-
.setLeaderEpoch(leaderEpoch)
84-
)
85-
)
73+
.setErrorCode(topLevelError.code())
74+
.setTopics(
75+
Collections.singletonList(
76+
new BeginQuorumEpochResponseData.TopicData()
77+
.setTopicName(topicPartition.topic())
78+
.setPartitions(
79+
Collections.singletonList(
80+
new BeginQuorumEpochResponseData.PartitionData()
81+
.setErrorCode(partitionLevelError.code())
82+
.setLeaderId(leaderId)
83+
.setLeaderEpoch(leaderEpoch)
84+
)
8685
)
87-
);
86+
)
87+
);
8888

8989
if (apiVersion >= 1) {
9090
Optional<InetSocketAddress> address = endpoints.address(listenerName);
9191
if (address.isPresent() && leaderId >= 0) {
9292
// Populate the node endpoints
9393
BeginQuorumEpochResponseData.NodeEndpointCollection nodeEndpoints =
94-
new BeginQuorumEpochResponseData.NodeEndpointCollection(1);
94+
new BeginQuorumEpochResponseData.NodeEndpointCollection(1);
9595
nodeEndpoints.add(
96-
new BeginQuorumEpochResponseData.NodeEndpoint()
97-
.setNodeId(leaderId)
98-
.setHost(address.get().getHostString())
99-
.setPort(address.get().getPort())
96+
new BeginQuorumEpochResponseData.NodeEndpoint()
97+
.setNodeId(leaderId)
98+
.setHost(address.get().getHostString())
99+
.setPort(address.get().getPort())
100100
);
101101
response.setNodeEndpoints(nodeEndpoints);
102102
}
@@ -107,21 +107,21 @@ public static BeginQuorumEpochResponseData singletonBeginQuorumEpochResponse(
107107

108108
public static boolean hasValidTopicPartition(BeginQuorumEpochRequestData data, TopicPartition topicPartition) {
109109
return data.topics().size() == 1 &&
110-
data.topics().get(0).topicName().equals(topicPartition.topic()) &&
111-
data.topics().get(0).partitions().size() == 1 &&
112-
data.topics().get(0).partitions().get(0).partitionIndex() == topicPartition.partition();
110+
data.topics().get(0).topicName().equals(topicPartition.topic()) &&
111+
data.topics().get(0).partitions().size() == 1 &&
112+
data.topics().get(0).partitions().get(0).partitionIndex() == topicPartition.partition();
113113
}
114114

115115
public static boolean hasValidTopicPartition(BeginQuorumEpochResponseData data, TopicPartition topicPartition) {
116116
return data.topics().size() == 1 &&
117-
data.topics().get(0).topicName().equals(topicPartition.topic()) &&
118-
data.topics().get(0).partitions().size() == 1 &&
119-
data.topics().get(0).partitions().get(0).partitionIndex() == topicPartition.partition();
117+
data.topics().get(0).topicName().equals(topicPartition.topic()) &&
118+
data.topics().get(0).partitions().size() == 1 &&
119+
data.topics().get(0).partitions().get(0).partitionIndex() == topicPartition.partition();
120120
}
121121

122122
public static Optional<ReplicaKey> beginQuorumEpochRequestVoterKey(
123-
BeginQuorumEpochRequestData request,
124-
BeginQuorumEpochRequestData.PartitionData partition
123+
BeginQuorumEpochRequestData request,
124+
BeginQuorumEpochRequestData.PartitionData partition
125125
) {
126126
if (request.voterId() < 0) {
127127
return Optional.empty();

raft/src/main/java/org/apache/kafka/raft/utils/DescribeQuorumRpc.java

+55-55
Original file line numberDiff line numberDiff line change
@@ -31,55 +31,55 @@
3131

3232
public class DescribeQuorumRpc {
3333
public static DescribeQuorumRequestData singletonDescribeQuorumRequest(
34-
TopicPartition topicPartition
34+
TopicPartition topicPartition
3535
) {
3636
return new DescribeQuorumRequestData()
37-
.setTopics(
38-
Collections.singletonList(
39-
new DescribeQuorumRequestData.TopicData()
40-
.setTopicName(topicPartition.topic())
41-
.setPartitions(
42-
Collections.singletonList(
43-
new DescribeQuorumRequestData.PartitionData()
44-
.setPartitionIndex(topicPartition.partition())
45-
)
46-
)
37+
.setTopics(
38+
Collections.singletonList(
39+
new DescribeQuorumRequestData.TopicData()
40+
.setTopicName(topicPartition.topic())
41+
.setPartitions(
42+
Collections.singletonList(
43+
new DescribeQuorumRequestData.PartitionData()
44+
.setPartitionIndex(topicPartition.partition())
45+
)
4746
)
48-
);
47+
)
48+
);
4949
}
5050

5151
public static DescribeQuorumResponseData singletonDescribeQuorumResponse(
52-
short apiVersion,
53-
TopicPartition topicPartition,
54-
int leaderId,
55-
int leaderEpoch,
56-
long highWatermark,
57-
Collection<LeaderState.ReplicaState> voters,
58-
Collection<LeaderState.ReplicaState> observers,
59-
long currentTimeMs
52+
short apiVersion,
53+
TopicPartition topicPartition,
54+
int leaderId,
55+
int leaderEpoch,
56+
long highWatermark,
57+
Collection<LeaderState.ReplicaState> voters,
58+
Collection<LeaderState.ReplicaState> observers,
59+
long currentTimeMs
6060
) {
6161
DescribeQuorumResponseData response = new DescribeQuorumResponseData()
62-
.setTopics(
63-
Collections.singletonList(
64-
new DescribeQuorumResponseData.TopicData()
65-
.setTopicName(topicPartition.topic())
66-
.setPartitions(
67-
Collections.singletonList(
68-
new DescribeQuorumResponseData.PartitionData()
69-
.setPartitionIndex(topicPartition.partition())
70-
.setErrorCode(Errors.NONE.code())
71-
.setLeaderId(leaderId)
72-
.setLeaderEpoch(leaderEpoch)
73-
.setHighWatermark(highWatermark)
74-
.setCurrentVoters(toReplicaStates(apiVersion, leaderId, voters, currentTimeMs))
75-
.setObservers(toReplicaStates(apiVersion, leaderId, observers, currentTimeMs))))));
62+
.setTopics(
63+
Collections.singletonList(
64+
new DescribeQuorumResponseData.TopicData()
65+
.setTopicName(topicPartition.topic())
66+
.setPartitions(
67+
Collections.singletonList(
68+
new DescribeQuorumResponseData.PartitionData()
69+
.setPartitionIndex(topicPartition.partition())
70+
.setErrorCode(Errors.NONE.code())
71+
.setLeaderId(leaderId)
72+
.setLeaderEpoch(leaderEpoch)
73+
.setHighWatermark(highWatermark)
74+
.setCurrentVoters(toReplicaStates(apiVersion, leaderId, voters, currentTimeMs))
75+
.setObservers(toReplicaStates(apiVersion, leaderId, observers, currentTimeMs))))));
7676
if (apiVersion >= 2) {
7777
DescribeQuorumResponseData.NodeCollection nodes = new DescribeQuorumResponseData.NodeCollection(voters.size());
7878
for (LeaderState.ReplicaState voter : voters) {
7979
nodes.add(
80-
new DescribeQuorumResponseData.Node()
81-
.setNodeId(voter.replicaKey().id())
82-
.setListeners(voter.listeners().toDescribeQuorumResponseListeners())
80+
new DescribeQuorumResponseData.Node()
81+
.setNodeId(voter.replicaKey().id())
82+
.setListeners(voter.listeners().toDescribeQuorumResponseListeners())
8383
);
8484
}
8585
response.setNodes(nodes);
@@ -88,22 +88,22 @@ public static DescribeQuorumResponseData singletonDescribeQuorumResponse(
8888
}
8989

9090
private static List<DescribeQuorumResponseData.ReplicaState> toReplicaStates(
91-
short apiVersion,
92-
int leaderId,
93-
Collection<LeaderState.ReplicaState> states,
94-
long currentTimeMs
91+
short apiVersion,
92+
int leaderId,
93+
Collection<LeaderState.ReplicaState> states,
94+
long currentTimeMs
9595
) {
9696
return states
97-
.stream()
98-
.map(replicaState -> toReplicaState(apiVersion, leaderId, replicaState, currentTimeMs))
99-
.collect(Collectors.toList());
97+
.stream()
98+
.map(replicaState -> toReplicaState(apiVersion, leaderId, replicaState, currentTimeMs))
99+
.collect(Collectors.toList());
100100
}
101101

102102
private static DescribeQuorumResponseData.ReplicaState toReplicaState(
103-
short apiVersion,
104-
int leaderId,
105-
LeaderState.ReplicaState replicaState,
106-
long currentTimeMs
103+
short apiVersion,
104+
int leaderId,
105+
LeaderState.ReplicaState replicaState,
106+
long currentTimeMs
107107
) {
108108
final long lastCaughtUpTimestamp;
109109
final long lastFetchTimestamp;
@@ -115,10 +115,10 @@ private static DescribeQuorumResponseData.ReplicaState toReplicaState(
115115
lastFetchTimestamp = replicaState.lastFetchTimestamp();
116116
}
117117
DescribeQuorumResponseData.ReplicaState replicaStateData = new DescribeQuorumResponseData.ReplicaState()
118-
.setReplicaId(replicaState.replicaKey().id())
119-
.setLogEndOffset(replicaState.endOffset().map(LogOffsetMetadata::offset).orElse(-1L))
120-
.setLastCaughtUpTimestamp(lastCaughtUpTimestamp)
121-
.setLastFetchTimestamp(lastFetchTimestamp);
118+
.setReplicaId(replicaState.replicaKey().id())
119+
.setLogEndOffset(replicaState.endOffset().map(LogOffsetMetadata::offset).orElse(-1L))
120+
.setLastCaughtUpTimestamp(lastCaughtUpTimestamp)
121+
.setLastFetchTimestamp(lastFetchTimestamp);
122122

123123
if (apiVersion >= 2) {
124124
replicaStateData.setReplicaDirectoryId(replicaState.replicaKey().directoryId().orElse(ReplicaKey.NO_DIRECTORY_ID));
@@ -128,8 +128,8 @@ private static DescribeQuorumResponseData.ReplicaState toReplicaState(
128128

129129
public static boolean hasValidTopicPartition(DescribeQuorumRequestData data, TopicPartition topicPartition) {
130130
return data.topics().size() == 1 &&
131-
data.topics().get(0).topicName().equals(topicPartition.topic()) &&
132-
data.topics().get(0).partitions().size() == 1 &&
133-
data.topics().get(0).partitions().get(0).partitionIndex() == topicPartition.partition();
131+
data.topics().get(0).topicName().equals(topicPartition.topic()) &&
132+
data.topics().get(0).partitions().size() == 1 &&
133+
data.topics().get(0).partitions().get(0).partitionIndex() == topicPartition.partition();
134134
}
135135
}

0 commit comments

Comments
 (0)