Skip to content

Commit aed845b

Browse files
committed
BOOKKEEPER-114: add a shutdown hook to shut down bookie server safely. (Sijie via ivank)
git-svn-id: https://svn.apache.org/repos/asf/zookeeper/bookkeeper/trunk@1203790 13f79535-47bb-0310-9956-ffa450edef68
1 parent d33f843 commit aed845b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ BUGFIXES:
7878

7979
BOOKKEEPER-115: LocalBookKeeper fails after BOOKKEEPER-108 (ivank)
8080

81+
BOOKKEEPER-114: add a shutdown hook to shut down bookie server safely. (Sijie via ivank)
82+
8183
hedwig-server/
8284

8385
BOOKKEEPER-43: NullPointException when releasing topic (Sijie Guo via breed)

bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieServer.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,20 @@ public static void main(String[] args) throws IOException, InterruptedException,
243243
conf.getBookiePort(), conf.getZkServers(),
244244
conf.getJournalDirName(), sb);
245245
LOG.info(hello);
246-
BookieServer bs = new BookieServer(conf);
246+
final BookieServer bs = new BookieServer(conf);
247247
bs.start();
248+
Runtime.getRuntime().addShutdownHook(new Thread() {
249+
@Override
250+
public void run() {
251+
try {
252+
bs.shutdown();
253+
LOG.info("Shut down bookie server successfully");
254+
} catch (InterruptedException ie) {
255+
LOG.warn("Exception when shutting down bookie server : ", ie);
256+
}
257+
}
258+
});
259+
LOG.info("Register shutdown hook successfully");
248260
bs.join();
249261
}
250262

0 commit comments

Comments
 (0)