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.
This commit is contained in:
parent
37bb8f8075
commit
df17f85e14
|
@ -386,7 +386,7 @@ public class MasterService extends AbstractLifecycleComponent {
|
|||
}
|
||||
});
|
||||
|
||||
return new DelegetingAckListener(ackListeners);
|
||||
return new DelegatingAckListener(ackListeners);
|
||||
}
|
||||
|
||||
public boolean clusterStateUnchanged() {
|
||||
|
@ -541,11 +541,11 @@ public class MasterService extends AbstractLifecycleComponent {
|
|||
}
|
||||
}
|
||||
|
||||
private static class DelegetingAckListener implements Discovery.AckListener {
|
||||
private static class DelegatingAckListener implements Discovery.AckListener {
|
||||
|
||||
private final List<Discovery.AckListener> listeners;
|
||||
|
||||
private DelegetingAckListener(List<Discovery.AckListener> listeners) {
|
||||
private DelegatingAckListener(List<Discovery.AckListener> listeners) {
|
||||
this.listeners = listeners;
|
||||
}
|
||||
|
||||
|
@ -555,11 +555,6 @@ public class MasterService extends AbstractLifecycleComponent {
|
|||
listener.onNodeAck(node, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
throw new UnsupportedOperationException("no timeout delegation");
|
||||
}
|
||||
}
|
||||
|
||||
private static class AckCountDownListener implements Discovery.AckListener {
|
||||
|
@ -614,7 +609,6 @@ public class MasterService extends AbstractLifecycleComponent {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
if (countDown.fastForward()) {
|
||||
logger.trace("timeout waiting for acknowledgement for cluster_state update (version: {})", clusterStateVersion);
|
||||
|
|
|
@ -49,7 +49,6 @@ public interface Discovery extends LifecycleComponent {
|
|||
|
||||
interface AckListener {
|
||||
void onNodeAck(DiscoveryNode node, @Nullable Exception e);
|
||||
void onTimeout();
|
||||
}
|
||||
|
||||
class FailedToCommitClusterStateException extends ElasticsearchException {
|
||||
|
|
|
@ -814,7 +814,6 @@ public class PublishClusterStateActionTests extends ESTestCase {
|
|||
|
||||
public static class AssertingAckListener implements Discovery.AckListener {
|
||||
private final List<Tuple<DiscoveryNode, Throwable>> errors = new CopyOnWriteArrayList<>();
|
||||
private final AtomicBoolean timeoutOccurred = new AtomicBoolean();
|
||||
private final CountDownLatch countDown;
|
||||
|
||||
public AssertingAckListener(int nodeCount) {
|
||||
|
@ -829,23 +828,12 @@ public class PublishClusterStateActionTests extends ESTestCase {
|
|||
countDown.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
timeoutOccurred.set(true);
|
||||
// Fast forward the counter - no reason to wait here
|
||||
long currentCount = countDown.getCount();
|
||||
for (long i = 0; i < currentCount; i++) {
|
||||
countDown.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
public void await(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
assertThat(awaitErrors(timeout, unit), emptyIterable());
|
||||
}
|
||||
|
||||
public List<Tuple<DiscoveryNode, Throwable>> awaitErrors(long timeout, TimeUnit unit) throws InterruptedException {
|
||||
countDown.await(timeout, unit);
|
||||
assertFalse(timeoutOccurred.get());
|
||||
return errors;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue