keith-turner commented on code in PR #4295:
URL: https://github.com/apache/accumulo/pull/4295#discussion_r1499954148


##########
test/src/main/java/org/apache/accumulo/test/manager/SuspendedTabletsIT.java:
##########
@@ -330,6 +301,95 @@ void eliminateTabletServers(ClientContext ctx, 
TabletLocations locs, int count)
         throws Exception;
   }
 
+  private class ShutdownTserverKiller implements TServerKiller {
+
+    @Override
+    public void eliminateTabletServers(ClientContext ctx, TabletLocations 
locs, int count)
+        throws Exception {
+
+      Set<TServerInstance> tserverSet = new HashSet<>();
+      Set<TServerInstance> metadataServerSet = new HashSet<>();
+
+      TabletLocator tl = TabletLocator.getLocator(ctx, MetadataTable.ID);
+      for (TabletLocationState tls : locs.locationStates.values()) {
+        if (tls.current != null) {
+          // add to set of all servers
+          tserverSet.add(tls.current.getServerInstance());
+
+          // get server that the current tablets metadata is on
+          TabletLocator.TabletLocation tab =
+              tl.locateTablet(ctx, tls.extent.toMetaRow(), false, false);
+          // add it to the set of servers with metadata
+          metadataServerSet
+              .add(new TServerInstance(tab.tablet_location, 
Long.valueOf(tab.tablet_session, 16)));
+        }
+      }
+
+      // remove servers with metadata on them from the list of servers to be 
shutdown
+      assertEquals(1, metadataServerSet.size(), "Expecting a single tServer in 
metadataServerSet");
+      tserverSet.removeAll(metadataServerSet);
+
+      assertEquals(TSERVERS - 1, tserverSet.size(),
+          "Expecting " + (TSERVERS - 1) + " tServers in shutdown-list");
+
+      List<TServerInstance> tserversList = new ArrayList<>(tserverSet);
+      Collections.shuffle(tserversList, random);
+
+      for (int i1 = 0; i1 < count; ++i1) {
+        final String tserverName = tserversList.get(i1).getHostPortSession();
+        ThriftClientTypes.MANAGER.executeVoid(ctx, client -> {
+          log.info("Sending shutdown command to {} via ManagerClientService", 
tserverName);
+          client.shutdownTabletServer(null, ctx.rpcCreds(), tserverName, 
false);
+        });
+      }
+
+      log.info("Waiting for tserver process{} to die", count == 1 ? "" : "es");
+      for (int i2 = 0; i2 < 10; ++i2) {
+        List<ProcessReference> deadProcs = new ArrayList<>();
+        for (ProcessReference pr1 : 
getCluster().getProcesses().get(ServerType.TABLET_SERVER)) {
+          Process p = pr1.getProcess();
+          if (!p.isAlive()) {
+            deadProcs.add(pr1);
+          }
+        }
+        for (ProcessReference pr2 : deadProcs) {
+          log.info("Process {} is dead, informing cluster control about this", 
pr2.getProcess());
+          
getCluster().getClusterControl().killProcess(ServerType.TABLET_SERVER, pr2);
+          --count;
+        }
+        if (count == 0) {
+          return;
+        } else {
+          Thread.sleep(SECONDS.toMillis(2));
+        }
+      }
+      throw new IllegalStateException("Tablet servers didn't die!");
+
+    }
+  }
+
+  private class CrashTserverKiller implements TServerKiller {
+
+    @Override
+    public void eliminateTabletServers(ClientContext ctx, TabletLocations 
locs, int count)

Review Comment:
   The code in this methos was also copied w/o change from an existing lambda 
in the test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to