Search in sources :

Example 1 with ShutdownTServer

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");
}
Also used : TServerConnection(org.apache.accumulo.server.master.LiveTServerSet.TServerConnection) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) ShutdownTServer(org.apache.accumulo.master.tserverOps.ShutdownTServer)

Example 2 with ShutdownTServer

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);
}
Also used : Master(org.apache.accumulo.master.Master) TServerConnection(org.apache.accumulo.server.master.LiveTServerSet.TServerConnection) TableInfo(org.apache.accumulo.core.master.thrift.TableInfo) TServerInstance(org.apache.accumulo.server.master.state.TServerInstance) ShutdownTServer(org.apache.accumulo.master.tserverOps.ShutdownTServer) TabletServerStatus(org.apache.accumulo.core.master.thrift.TabletServerStatus) Test(org.junit.Test)

Aggregations

ShutdownTServer (org.apache.accumulo.master.tserverOps.ShutdownTServer)2 TServerConnection (org.apache.accumulo.server.master.LiveTServerSet.TServerConnection)2 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)2 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)1 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)1 Master (org.apache.accumulo.master.Master)1 Test (org.junit.Test)1