use of org.apache.accumulo.master.tserverOps.ShutdownTServer in project accumulo by apache.
the class MasterClientServiceHandler method shutdownTabletServer.
@Override
public void shutdownTabletServer(TInfo info, TCredentials c, String tabletServer, boolean force) throws ThriftSecurityException {
master.security.canPerformSystemActions(c);
final TServerInstance doomed = master.tserverSet.find(tabletServer);
if (!force) {
final TServerConnection server = master.tserverSet.getConnection(doomed);
if (server == null) {
Master.log.warn("No server found for name {}", tabletServer);
return;
}
}
long tid = master.fate.startTransaction();
log.debug("Seeding FATE op to shutdown " + tabletServer + " with tid " + tid);
master.fate.seedTransaction(tid, new TraceRepo<>(new ShutdownTServer(doomed, force)), false);
master.fate.waitForCompletion(tid);
master.fate.delete(tid);
log.debug("FATE op shutting down " + tabletServer + " finished");
}
use of org.apache.accumulo.master.tserverOps.ShutdownTServer in project accumulo by apache.
the class ShutdownTServerTest method testSingleShutdown.
@Test
public void testSingleShutdown() throws Exception {
final TServerInstance tserver = EasyMock.createMock(TServerInstance.class);
final boolean force = false;
final ShutdownTServer op = new ShutdownTServer(tserver, force);
final Master master = EasyMock.createMock(Master.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());
master.shutdownTServer(tserver);
EasyMock.expectLastCall().once();
EasyMock.expect(master.onlineTabletServers()).andReturn(Collections.singleton(tserver));
EasyMock.expect(master.getConnection(tserver)).andReturn(tserverCnxn);
EasyMock.expect(tserverCnxn.getTableMap(false)).andReturn(status);
EasyMock.replay(tserver, tserverCnxn, master);
// FATE op is not ready
long wait = op.isReady(tid, master);
assertTrue("Expected wait to be greater than 0", wait > 0);
EasyMock.verify(tserver, tserverCnxn, master);
// Reset the mocks
EasyMock.reset(tserver, tserverCnxn, master);
// The same as above, but should not expect call shutdownTServer on master again
EasyMock.expect(master.onlineTabletServers()).andReturn(Collections.singleton(tserver));
EasyMock.expect(master.getConnection(tserver)).andReturn(tserverCnxn);
EasyMock.expect(tserverCnxn.getTableMap(false)).andReturn(status);
EasyMock.replay(tserver, tserverCnxn, master);
// FATE op is not ready
wait = op.isReady(tid, master);
assertTrue("Expected wait to be greater than 0", wait > 0);
EasyMock.verify(tserver, tserverCnxn, master);
}
Aggregations