Skip to content

Commit df17f85

Browse files
authored
Remove Discovery.AckListener.onTimeout() (#30514)
The MasterService takes responsibility for timeouts of the AckListeners that it creates, and the rest of the Discovery subsystem is unaware of these timeouts, so there's no need for this to appear in the Discovery.AckListener interface. Also fix a typo in the name of DelegatingAckListener.
1 parent 37bb8f8 commit df17f85

File tree

3 files changed

+3
-22
lines changed

3 files changed

+3
-22
lines changed

server/src/main/java/org/elasticsearch/cluster/service/MasterService.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ public Discovery.AckListener createAckListener(ThreadPool threadPool, ClusterSta
386386
}
387387
});
388388

389-
return new DelegetingAckListener(ackListeners);
389+
return new DelegatingAckListener(ackListeners);
390390
}
391391

392392
public boolean clusterStateUnchanged() {
@@ -541,11 +541,11 @@ protected void warnAboutSlowTaskIfNeeded(TimeValue executionTime, String source)
541541
}
542542
}
543543

544-
private static class DelegetingAckListener implements Discovery.AckListener {
544+
private static class DelegatingAckListener implements Discovery.AckListener {
545545

546546
private final List<Discovery.AckListener> listeners;
547547

548-
private DelegetingAckListener(List<Discovery.AckListener> listeners) {
548+
private DelegatingAckListener(List<Discovery.AckListener> listeners) {
549549
this.listeners = listeners;
550550
}
551551

@@ -555,11 +555,6 @@ public void onNodeAck(DiscoveryNode node, @Nullable Exception e) {
555555
listener.onNodeAck(node, e);
556556
}
557557
}
558-
559-
@Override
560-
public void onTimeout() {
561-
throw new UnsupportedOperationException("no timeout delegation");
562-
}
563558
}
564559

565560
private static class AckCountDownListener implements Discovery.AckListener {
@@ -614,7 +609,6 @@ public void onNodeAck(DiscoveryNode node, @Nullable Exception e) {
614609
}
615610
}
616611

617-
@Override
618612
public void onTimeout() {
619613
if (countDown.fastForward()) {
620614
logger.trace("timeout waiting for acknowledgement for cluster_state update (version: {})", clusterStateVersion);

server/src/main/java/org/elasticsearch/discovery/Discovery.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public interface Discovery extends LifecycleComponent {
4949

5050
interface AckListener {
5151
void onNodeAck(DiscoveryNode node, @Nullable Exception e);
52-
void onTimeout();
5352
}
5453

5554
class FailedToCommitClusterStateException extends ElasticsearchException {

server/src/test/java/org/elasticsearch/discovery/zen/PublishClusterStateActionTests.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,6 @@ public AssertingAckListener publishState(PublishClusterStateAction action, Clust
814814

815815
public static class AssertingAckListener implements Discovery.AckListener {
816816
private final List<Tuple<DiscoveryNode, Throwable>> errors = new CopyOnWriteArrayList<>();
817-
private final AtomicBoolean timeoutOccurred = new AtomicBoolean();
818817
private final CountDownLatch countDown;
819818

820819
public AssertingAckListener(int nodeCount) {
@@ -829,23 +828,12 @@ public void onNodeAck(DiscoveryNode node, @Nullable Exception e) {
829828
countDown.countDown();
830829
}
831830

832-
@Override
833-
public void onTimeout() {
834-
timeoutOccurred.set(true);
835-
// Fast forward the counter - no reason to wait here
836-
long currentCount = countDown.getCount();
837-
for (long i = 0; i < currentCount; i++) {
838-
countDown.countDown();
839-
}
840-
}
841-
842831
public void await(long timeout, TimeUnit unit) throws InterruptedException {
843832
assertThat(awaitErrors(timeout, unit), emptyIterable());
844833
}
845834

846835
public List<Tuple<DiscoveryNode, Throwable>> awaitErrors(long timeout, TimeUnit unit) throws InterruptedException {
847836
countDown.await(timeout, unit);
848-
assertFalse(timeoutOccurred.get());
849837
return errors;
850838
}
851839

0 commit comments

Comments
 (0)