use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class TabletLocationStateTest method testGetState_Dead1.
@Test
public void testGetState_Dead1() throws Exception {
Set<TServerInstance> liveServers = new java.util.HashSet<>();
liveServers.add(current);
tls = new TabletLocationState(keyExtent, future, null, last, null, walogs, true);
assertEquals(TabletState.ASSIGNED_TO_DEAD_SERVER, tls.getState(liveServers));
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class Upgrader9to10 method getLocation.
protected TServerInstance getLocation(ServerContext context, String relpath) {
String str = getFromZK(context, relpath);
if (str == null) {
return null;
}
String[] parts = str.split("[|]", 2);
HostAndPort address = HostAndPort.fromString(parts[0]);
if (parts.length > 1 && parts[1] != null && !parts[1].isEmpty()) {
return new TServerInstance(address, parts[1]);
} else {
// a 1.2 location specification: DO NOT WANT
return null;
}
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class ManagerReplicationCoordinatorTest method randomServer.
@Test
public void randomServer() {
Manager manager = EasyMock.createMock(Manager.class);
ZooReader reader = EasyMock.createMock(ZooReader.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(context.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
EasyMock.expect(context.getZooReaderWriter()).andReturn(null).anyTimes();
EasyMock.expect(manager.getContext()).andReturn(context);
EasyMock.expect(manager.getInstanceID()).andReturn(InstanceId.of("1234"));
EasyMock.replay(manager, context, reader);
ManagerReplicationCoordinator coordinator = new ManagerReplicationCoordinator(manager, reader);
TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
assertEquals(inst1, coordinator.getRandomTServer(Collections.singleton(inst1), 0));
}
use of org.apache.accumulo.core.metadata.TServerInstance in project accumulo by apache.
the class ManagerReplicationCoordinatorTest method invalidOffset.
@Test
public void invalidOffset() {
Manager manager = EasyMock.createMock(Manager.class);
ServerContext context = EasyMock.createMock(ServerContext.class);
EasyMock.expect(context.getConfiguration()).andReturn(config).anyTimes();
EasyMock.expect(context.getInstanceID()).andReturn(InstanceId.of("1234")).anyTimes();
EasyMock.expect(context.getZooReaderWriter()).andReturn(null).anyTimes();
ZooReader reader = EasyMock.createMock(ZooReader.class);
EasyMock.expect(manager.getContext()).andReturn(context);
EasyMock.expect(manager.getInstanceID()).andReturn(InstanceId.of("1234"));
EasyMock.replay(manager, context, reader);
ManagerReplicationCoordinator coordinator = new ManagerReplicationCoordinator(manager, reader);
TServerInstance inst1 = new TServerInstance(HostAndPort.fromParts("host1", 1234), "session");
assertThrows(IllegalArgumentException.class, () -> coordinator.getRandomTServer(Collections.singleton(inst1), 1));
}
use of org.apache.accumulo.core.metadata.TServerInstance 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);
}
Aggregations