Skip to content

Commit

Permalink
[FLINK-32010][runtime] Leader election/retrieval drivers should prope…
Browse files Browse the repository at this point in the history
…rly extend AutoCloseable instead of having their own close method with the same signature.
  • Loading branch information
dmvk committed May 5, 2023
1 parent 075f359 commit 6009e81
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* <p><strong>Important</strong>: The {@link LeaderElectionDriver} could not guarantee that there is
* no {@link LeaderElectionEventHandler} callbacks happen after {@link #close()}.
*/
public interface LeaderElectionDriver {
public interface LeaderElectionDriver extends AutoCloseable {

/**
* Write the current leader information to external persistent storage(e.g. Zookeeper,
Expand All @@ -49,7 +49,4 @@ public interface LeaderElectionDriver {
* @return Return whether the driver has leadership.
*/
boolean hasLeadership();

/** Close the services used for leader election. */
void close() throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,4 @@
* <p><strong>Important</strong>: The {@link LeaderRetrievalDriver} could not guarantee that there
* is no {@link LeaderRetrievalEventHandler} callbacks happen after {@link #close()}.
*/
public interface LeaderRetrievalDriver {

/** Close the services used for leader retrieval. */
void close() throws Exception;
}
public interface LeaderRetrievalDriver extends AutoCloseable {}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* testing purposes.
*/
public class TestingLeaderElectionEventHandler extends TestingLeaderBase
implements LeaderElectionEventHandler {
implements LeaderElectionEventHandler, AutoCloseable {

private final Object lock = new Object();

Expand Down Expand Up @@ -135,6 +135,7 @@ public LeaderInformation getConfirmedLeaderInformation() {
}
}

@Override
public void close() {
synchronized (lock) {
running = false;
Expand Down

0 comments on commit 6009e81

Please sign in to comment.