Skip to content

Commit fedaab8

Browse files
committed
ZOOKEEPER-5059. Destroy Login thread in shutdown() method
1 parent 981a2fd commit fedaab8

7 files changed

Lines changed: 38 additions & 0 deletions

File tree

zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/QuorumPeer.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,12 @@ public void shutdown() {
17121712
LOG.warn("Error closing logs ", ie);
17131713
}
17141714
}
1715+
if (authServer != null) {
1716+
authServer.shutdown();
1717+
}
1718+
if (authLearner != null) {
1719+
authLearner.shutdown();
1720+
}
17151721
}
17161722

17171723
/**

zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/auth/NullQuorumAuthLearner.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ public void authenticate(Socket sock, String hostname) {
3131
return; // simply return don't require auth
3232
}
3333

34+
@Override
35+
public void shutdown() {
36+
// no-op
37+
}
38+
3439
}

zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/auth/NullQuorumAuthServer.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ public void authenticate(final Socket sock, final DataInputStream din) {
3232
// simply return don't require auth
3333
}
3434

35+
@Override
36+
public void shutdown() {
37+
// no-op
38+
}
39+
3540
}

zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/auth/QuorumAuthLearner.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ public interface QuorumAuthLearner {
3838
*/
3939
void authenticate(Socket sock, String hostname) throws IOException;
4040

41+
/**
42+
* Shutdown the learner and release resources.
43+
*/
44+
void shutdown();
4145
}

zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/auth/QuorumAuthServer.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ public interface QuorumAuthServer {
3838
*/
3939
void authenticate(Socket sock, DataInputStream din) throws IOException;
4040

41+
/**
42+
* Shut down the server and release resources.
43+
*/
44+
void shutdown();
4145
}

zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/auth/SaslQuorumAuthLearner.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,13 @@ public void authenticate(Socket sock, String hostName) throws IOException {
144144
}
145145
}
146146

147+
@Override
148+
public void shutdown() {
149+
if (learnerLogin != null) {
150+
learnerLogin.shutdown();
151+
}
152+
}
153+
147154
private void checkAuthStatus(Socket sock, QuorumAuth.Status qpStatus) throws SaslException {
148155
if (qpStatus == QuorumAuth.Status.SUCCESS) {
149156
LOG.info(

zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/auth/SaslQuorumAuthServer.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,13 @@ public void authenticate(Socket sock, DataInputStream din) throws SaslException
156156
}
157157
}
158158

159+
@Override
160+
public void shutdown() {
161+
if (serverLogin != null) {
162+
serverLogin.shutdown();
163+
}
164+
}
165+
159166
private byte[] receive(DataInputStream din) throws IOException {
160167
QuorumAuthPacket authPacket = new QuorumAuthPacket();
161168
BinaryInputArchive bia = BinaryInputArchive.getArchive(din);

0 commit comments

Comments
 (0)