|
56 | 56 | import java.util.concurrent.atomic.AtomicInteger;
|
57 | 57 | import java.util.concurrent.atomic.AtomicReference;
|
58 | 58 | import java.util.function.Function;
|
| 59 | +import java.util.function.Predicate; |
59 | 60 | import java.util.function.Supplier;
|
60 | 61 | import java.util.stream.Stream;
|
61 | 62 |
|
|
90 | 91 | import org.apache.accumulo.server.init.Initialize;
|
91 | 92 | import org.apache.accumulo.server.util.AccumuloStatus;
|
92 | 93 | import org.apache.accumulo.server.util.PortUtils;
|
| 94 | +import org.apache.accumulo.server.util.ZooZap; |
93 | 95 | import org.apache.accumulo.start.Main;
|
94 | 96 | import org.apache.accumulo.start.classloader.vfs.MiniDFSUtil;
|
95 | 97 | import org.apache.accumulo.start.spi.KeywordExecutable;
|
@@ -824,9 +826,47 @@ public synchronized void stop() throws IOException, InterruptedException {
|
824 | 826 |
|
825 | 827 | control.stop(ServerType.GARBAGE_COLLECTOR, null);
|
826 | 828 | control.stop(ServerType.MANAGER, null);
|
| 829 | + control.stop(ServerType.COMPACTION_COORDINATOR); |
827 | 830 | control.stop(ServerType.TABLET_SERVER, null);
|
| 831 | + control.stop(ServerType.COMPACTOR, null); |
| 832 | + control.stop(ServerType.SCAN_SERVER, null); |
| 833 | + |
| 834 | + // The method calls above kill the server |
| 835 | + // Clean up the locks in ZooKeeper fo that if the cluster |
| 836 | + // is restarted, then the processes will start right away |
| 837 | + // and not wait for the old locks to be cleaned up. |
| 838 | + try { |
| 839 | + new ZooZap().zap(getServerContext().getSiteConfiguration(), "-manager", |
| 840 | + "-compaction-coordinators", "-tservers", "-compactors", "-sservers"); |
| 841 | + } catch (RuntimeException e) { |
| 842 | + log.error("Error zapping zookeeper locks", e); |
| 843 | + } |
828 | 844 | control.stop(ServerType.ZOOKEEPER, null);
|
829 | 845 |
|
| 846 | + // Clear the location of the servers in ZooCache. |
| 847 | + // When ZooKeeper was stopped in the previous method call, |
| 848 | + // the local ZooKeeper watcher did not fire. If MAC is |
| 849 | + // restarted, then ZooKeeper will start on the same port with |
| 850 | + // the same data, but no Watchers will fire. |
| 851 | + boolean startCalled = true; |
| 852 | + try { |
| 853 | + getServerContext(); |
| 854 | + } catch (RuntimeException e) { |
| 855 | + if (e.getMessage().startsWith("Accumulo not initialized")) { |
| 856 | + startCalled = false; |
| 857 | + } |
| 858 | + } |
| 859 | + if (startCalled) { |
| 860 | + final ServerContext ctx = getServerContext(); |
| 861 | + final String zRoot = getServerContext().getZooKeeperRoot(); |
| 862 | + Predicate<String> pred = path -> false; |
| 863 | + for (String lockPath : Set.of(Constants.ZMANAGER_LOCK, Constants.ZGC_LOCK, |
| 864 | + Constants.ZCOMPACTORS, Constants.ZSSERVERS, Constants.ZTSERVERS)) { |
| 865 | + pred = pred.or(path -> path.startsWith(zRoot + lockPath)); |
| 866 | + } |
| 867 | + ctx.getZooCache().clear(pred); |
| 868 | + } |
| 869 | + |
830 | 870 | // ACCUMULO-2985 stop the ExecutorService after we finished using it to stop accumulo procs
|
831 | 871 | if (executor != null) {
|
832 | 872 | List<Runnable> tasksRemaining = executor.shutdownNow();
|
|
0 commit comments