98
98
import java .net .InetSocketAddress ;
99
99
import java .nio .ByteBuffer ;
100
100
import java .util .Collection ;
101
- import java .util .Collections ;
102
101
import java .util .HexFormat ;
103
102
import java .util .IdentityHashMap ;
104
103
import java .util .Iterator ;
@@ -593,9 +592,7 @@ public void initialize(
593
592
this .updateVoterHandler = new UpdateVoterHandler (
594
593
nodeId ,
595
594
partitionState ,
596
- channel .listenerName (),
597
- time ,
598
- quorumConfig .requestTimeoutMs ()
595
+ channel .listenerName ()
599
596
);
600
597
}
601
598
@@ -654,7 +651,7 @@ private void onBecomeLeader(long currentTimeMs) {
654
651
log .initializeLeaderEpoch (quorum .epoch ());
655
652
656
653
// The high watermark can only be advanced once we have written a record
657
- // from the new leader's epoch. Hence we write a control message immediately
654
+ // from the new leader's epoch. Hence, we write a control message immediately
658
655
// to ensure there is no delay committing pending data.
659
656
state .appendStartOfEpochControlRecords (quorum .localVoterNodeOrThrow (), currentTimeMs );
660
657
@@ -1900,7 +1897,7 @@ private DescribeQuorumResponseData handleDescribeQuorumRequest(
1900
1897
* - {@link Errors#FENCED_LEADER_EPOCH} if the epoch is smaller than this node's epoch
1901
1898
* - {@link Errors#INVALID_REQUEST} if the request epoch is larger than the leader's current epoch
1902
1899
* or if either the fetch offset or the last fetched epoch is invalid
1903
- * - {@link Errors#SNAPSHOT_NOT_FOUND} if the request snapshot id does not exists
1900
+ * - {@link Errors#SNAPSHOT_NOT_FOUND} if the request snapshot id does not exist
1904
1901
* - {@link Errors#POSITION_OUT_OF_RANGE} if the request snapshot offset out of range
1905
1902
*/
1906
1903
private FetchSnapshotResponseData handleFetchSnapshotRequest (
@@ -2418,7 +2415,7 @@ private boolean handleUpdateVoterResponse(
2418
2415
final Endpoints leaderEndpoints ;
2419
2416
if (responseLeaderId .isPresent () && data .currentLeader ().host ().isEmpty ()) {
2420
2417
leaderEndpoints = Endpoints .fromInetSocketAddresses (
2421
- Collections . singletonMap (
2418
+ Map . of (
2422
2419
channel .listenerName (),
2423
2420
InetSocketAddress .createUnresolved (
2424
2421
data .currentLeader ().host (),
@@ -2887,15 +2884,11 @@ private FetchRequestData buildFetchRequest() {
2887
2884
2888
2885
private long maybeSendFetchToAnyBootstrap (long currentTimeMs ) {
2889
2886
Optional <Node > readyNode = requestManager .findReadyBootstrapServer (currentTimeMs );
2890
- if (readyNode .isPresent ()) {
2891
- return maybeSendRequest (
2892
- currentTimeMs ,
2893
- readyNode .get (),
2894
- this ::buildFetchRequest
2895
- );
2896
- } else {
2897
- return requestManager .backoffBeforeAvailableBootstrapServer (currentTimeMs );
2898
- }
2887
+ return readyNode .map (node -> maybeSendRequest (
2888
+ currentTimeMs ,
2889
+ node ,
2890
+ this ::buildFetchRequest
2891
+ )).orElseGet (() -> requestManager .backoffBeforeAvailableBootstrapServer (currentTimeMs ));
2899
2892
}
2900
2893
2901
2894
private FetchSnapshotRequestData buildFetchSnapshotRequest (OffsetAndEpoch snapshotId , long snapshotSize ) {
@@ -3331,7 +3324,7 @@ private long pollCurrentState(long currentTimeMs) {
3331
3324
}
3332
3325
3333
3326
private void pollListeners () {
3334
- // Apply all of the pending registration
3327
+ // Apply all the pending registration
3335
3328
while (true ) {
3336
3329
Registration <T > registration = pendingRegistrations .poll ();
3337
3330
if (registration == null ) {
@@ -3825,7 +3818,7 @@ private void fireHandleCommit(long baseOffset, Records records) {
3825
3818
* This API is used for committed records originating from {@link #prepareAppend(int, List)}
3826
3819
* on this instance. In this case, we are able to save the original record objects, which
3827
3820
* saves the need to read them back from disk. This is a nice optimization for the leader
3828
- * which is typically doing more work than all of the * followers.
3821
+ * which is typically doing more work than all the * followers.
3829
3822
*/
3830
3823
private void fireHandleCommit (
3831
3824
long baseOffset ,
@@ -3835,7 +3828,7 @@ private void fireHandleCommit(
3835
3828
List <T > records
3836
3829
) {
3837
3830
Batch <T > batch = Batch .data (baseOffset , epoch , appendTimestamp , sizeInBytes , records );
3838
- MemoryBatchReader <T > reader = MemoryBatchReader .of (Collections . singletonList (batch ), this );
3831
+ MemoryBatchReader <T > reader = MemoryBatchReader .of (List . of (batch ), this );
3839
3832
fireHandleCommit (reader );
3840
3833
}
3841
3834
0 commit comments