Search in sources :

Example 1 with ShutdownTServer

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

Example 2 with ShutdownTServer

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");
}
Also used : TServerConnection(org.apache.accumulo.server.manager.LiveTServerSet.TServerConnection) ThriftSecurityException(org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) ShutdownTServer(org.apache.accumulo.manager.tserverOps.ShutdownTServer)

Aggregations

TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)2 ShutdownTServer (org.apache.accumulo.manager.tserverOps.ShutdownTServer)2 TServerConnection (org.apache.accumulo.server.manager.LiveTServerSet.TServerConnection)2 ThriftSecurityException (org.apache.accumulo.core.clientImpl.thrift.ThriftSecurityException)1 TableInfo (org.apache.accumulo.core.master.thrift.TableInfo)1 TabletServerStatus (org.apache.accumulo.core.master.thrift.TabletServerStatus)1 HostAndPort (org.apache.accumulo.core.util.HostAndPort)1 Manager (org.apache.accumulo.manager.Manager)1 Test (org.junit.Test)1