MCPcopy Create free account
hub / github.com/e2wugui/zeze / restartNet

Method restartNet

ZezeJava/ZezeJava/src/main/java/Zeze/Raft/Test.java:766–788  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

764 }
765
766 public void restartNet() throws Exception {
767 logger.debug("Raft.Net {} Restart ...", raftName);
768 try {
769 if (raft != null)
770 raft.getServer().stop();
771 if (raft != null) {
772 for (int i = 0; ; ) {
773 try {
774 raft.getServer().start();
775 break;
776 } catch (Exception e) {
777 if (!(e instanceof BindException) && !(e.getCause() instanceof BindException) || ++i > 30)
778 throw e;
779 //noinspection BusyWait
780 Thread.sleep(100); // 稍等一小会,上个ServerSocket还没真正关闭
781 }
782 }
783 }
784 } catch (Exception e) {
785 logger.error("RestartNet exception", e);
786 throw e;
787 }
788 }
789
790 public void stopRaft() throws Exception {
791 lock();

Callers 1

runTraceMethod · 0.80

Calls 4

getServerMethod · 0.80
stopMethod · 0.65
startMethod · 0.65
sleepMethod · 0.45

Tested by

no test coverage detected