use of org.apache.accumulo.manager.tserverOps.ShutdownTServer in project accumulo by apache.
the class ShutdownTServerTest method testSingleShutdown.
@Test
public void testSingleShutdown() throws Exception {
HostAndPort hap = HostAndPort.fromParts("localhost", 1234);
final TServerInstance tserver = new TServerInstance(hap, "fake");
final boolean force = false;
final ShutdownTServer op = new ShutdownTServer(tserver, force);
final Manager manager = EasyMock.createMock(Manager.class);
final long tid = 1L;
final TServerConnection tserverCnxn = EasyMock.createMock(TServerConnection.class);
final TabletServerStatus status = new TabletServerStatus();
status.tableMap = new HashMap<>();
// Put in a table info record, don't care what
status.tableMap.put("a_table", new TableInfo());
manager.shutdownTServer(tserver);
EasyMock.expectLastCall().once();
EasyMock.expect(manager.onlineTabletServers()).andReturn(Collections.singleton(tserver));
EasyMock.expect(manager.getConnection(tserver)).andReturn(tserverCnxn);
EasyMock.expect(tserverCnxn.getTableMap(false)).andReturn(status);
EasyMock.replay(tserverCnxn, manager);
// FATE op is not ready
long wait = op.isReady(tid, manager);
assertTrue("Expected wait to be greater than 0", wait > 0);
EasyMock.verify(tserverCnxn, manager);
// Reset the mocks
EasyMock.reset(tserverCnxn, manager);
// reset the table map to the empty set to simulate all tablets unloaded
status.tableMap = new HashMap<>();
manager.shutdownTServer(tserver);
EasyMock.expectLastCall().once();
EasyMock.expect(manager.onlineTabletServers()).andReturn(Collections.singleton(tserver));
EasyMock.expect(manager.getConnection(tserver)).andReturn(tserverCnxn);
EasyMock.expect(tserverCnxn.getTableMap(false)).andReturn(status);
EasyMock.expect(manager.getManagerLock()).andReturn(null);
tserverCnxn.halt(null);
EasyMock.expectLastCall().once();
EasyMock.replay(tserverCnxn, manager);
// FATE op is not ready
wait = op.isReady(tid, manager);
assertTrue("Expected wait to be 0", wait == 0);
Repo<Manager> op2 = op.call(tid, manager);
assertNull("Expected no follow on step", op2);
EasyMock.verify(tserverCnxn, manager);
}
use of org.apache.accumulo.manager.tserverOps.ShutdownTServer in project accumulo by apache.
the class ManagerClientServiceHandler method shutdownTabletServer.
@Override
public void shutdownTabletServer(TInfo info, TCredentials c, String tabletServer, boolean force) throws ThriftSecurityException {
if (!manager.security.canPerformSystemActions(c))
throw new ThriftSecurityException(c.getPrincipal(), SecurityErrorCode.PERMISSION_DENIED);
final TServerInstance doomed = manager.tserverSet.find(tabletServer);
if (!force) {
final TServerConnection server = manager.tserverSet.getConnection(doomed);
if (server == null) {
Manager.log.warn("No server found for name {}", tabletServer);
return;
}
}
long tid = manager.fate.startTransaction();
String msg = "Shutdown tserver " + tabletServer;
manager.fate.seedTransaction(tid, new TraceRepo<>(new ShutdownTServer(doomed, force)), false, msg);
manager.fate.waitForCompletion(tid);
manager.fate.delete(tid);
log.debug("FATE op shutting down " + tabletServer + " finished");
}
Aggregations