use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class BalanceAfterCommsFailureIT method checkBalance.
private void checkBalance(Connector c) throws Exception {
Credentials creds = new Credentials("root", new PasswordToken(ROOT_PASSWORD));
ClientContext context = new ClientContext(c.getInstance(), creds, getClientConfig());
MasterMonitorInfo stats = null;
int unassignedTablets = 1;
for (int i = 0; unassignedTablets > 0 && i < 10; i++) {
MasterClientService.Iface client = null;
while (true) {
try {
client = MasterClient.getConnectionWithRetry(context);
stats = client.getMasterStats(Tracer.traceInfo(), context.rpcCreds());
break;
} catch (ThriftNotActiveServiceException e) {
// Let it loop, fetching a new location
log.debug("Contacted a Master which is no longer active, retrying");
sleepUninterruptibly(100, TimeUnit.MILLISECONDS);
} finally {
if (client != null)
MasterClient.close(client);
}
}
unassignedTablets = stats.getUnassignedTablets();
if (unassignedTablets > 0) {
log.info("Found {} unassigned tablets, sleeping 3 seconds for tablet assignment", unassignedTablets);
Thread.sleep(3000);
}
}
assertEquals("Unassigned tablets were not assigned within 30 seconds", 0, unassignedTablets);
List<Integer> counts = new ArrayList<>();
for (TabletServerStatus server : stats.tServerInfo) {
int count = 0;
for (TableInfo table : server.tableMap.values()) {
count += table.onlineTablets;
}
counts.add(count);
}
assertTrue("Expected to have at least two TabletServers", counts.size() > 1);
for (int i = 1; i < counts.size(); i++) {
int diff = Math.abs(counts.get(0) - counts.get(i));
assertTrue("Expected difference in tablets to be less than or equal to " + counts.size() + " but was " + diff + ". Counts " + counts, diff <= counts.size());
}
}
use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class Master method getMasterMonitorInfo.
public MasterMonitorInfo getMasterMonitorInfo() {
final MasterMonitorInfo result = new MasterMonitorInfo();
result.tServerInfo = new ArrayList<>();
result.tableMap = new DefaultMap<>(new TableInfo());
for (Entry<TServerInstance, TabletServerStatus> serverEntry : tserverStatus.entrySet()) {
final TabletServerStatus status = serverEntry.getValue();
result.tServerInfo.add(status);
for (Entry<String, TableInfo> entry : status.tableMap.entrySet()) {
TableInfoUtil.add(result.tableMap.get(entry.getKey()), entry.getValue());
}
}
result.badTServers = new HashMap<>();
synchronized (badServers) {
for (TServerInstance bad : badServers.keySet()) {
result.badTServers.put(bad.hostPort(), TabletServerState.UNRESPONSIVE.getId());
}
}
result.state = getMasterState();
result.goalState = getMasterGoalState();
result.unassignedTablets = displayUnassigned();
result.serversShuttingDown = new HashSet<>();
synchronized (serversToShutdown) {
for (TServerInstance server : serversToShutdown) result.serversShuttingDown.add(server.hostPort());
}
DeadServerList obit = new DeadServerList(ZooUtil.getRoot(getInstance()) + Constants.ZDEADTSERVERS);
result.deadTabletServers = obit.getList();
result.bulkImports = bulkImportStatus.getBulkLoadStatus();
return result;
}
use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class BaseHostRegexTableLoadBalancerTest method createCurrent.
protected SortedMap<TServerInstance, TabletServerStatus> createCurrent(int numTservers) {
String base = "192.168.0.";
TreeMap<TServerInstance, TabletServerStatus> current = new TreeMap<>();
for (int i = 1; i <= numTservers; i++) {
TabletServerStatus status = new TabletServerStatus();
Map<String, TableInfo> tableMap = new HashMap<>();
tableMap.put(FOO.getId().canonicalID(), new TableInfo());
tableMap.put(BAR.getId().canonicalID(), new TableInfo());
tableMap.put(BAZ.getId().canonicalID(), new TableInfo());
status.setTableMap(tableMap);
current.put(new TServerInstance(base + i + ":9997", 1), status);
}
// now put all of the tablets on one server
for (Map.Entry<String, TServerInstance> entry : initialTableLocation.entrySet()) {
TabletServerStatus status = current.get(entry.getValue());
if (status != null) {
String tableId = getTableOperations().tableIdMap().get(entry.getKey());
status.getTableMap().get(tableId).setOnlineTablets(5);
}
}
return current;
}
use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class ChaoticLoadBalancerTest method testAssignMigrations.
@Test
public void testAssignMigrations() {
servers.clear();
servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1234), "a"), new FakeTServer());
servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1235), "b"), new FakeTServer());
servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1236), "c"), new FakeTServer());
Map<KeyExtent, TServerInstance> metadataTable = new TreeMap<>();
String table = "t1";
metadataTable.put(makeExtent(table, null, null), null);
table = "t2";
metadataTable.put(makeExtent(table, "a", null), null);
metadataTable.put(makeExtent(table, null, "a"), null);
table = "t3";
metadataTable.put(makeExtent(table, "a", null), null);
metadataTable.put(makeExtent(table, "b", "a"), null);
metadataTable.put(makeExtent(table, "c", "b"), null);
metadataTable.put(makeExtent(table, "d", "c"), null);
metadataTable.put(makeExtent(table, "e", "d"), null);
metadataTable.put(makeExtent(table, null, "e"), null);
TestChaoticLoadBalancer balancer = new TestChaoticLoadBalancer();
SortedMap<TServerInstance, TabletServerStatus> current = new TreeMap<>();
for (Entry<TServerInstance, FakeTServer> entry : servers.entrySet()) {
current.put(entry.getKey(), entry.getValue().getStatus(entry.getKey()));
}
Map<KeyExtent, TServerInstance> assignments = new HashMap<>();
balancer.getAssignments(getAssignments(servers), metadataTable, assignments);
assertEquals(assignments.size(), metadataTable.size());
}
use of org.apache.accumulo.core.master.thrift.TabletServerStatus in project accumulo by apache.
the class DefaultLoadBalancerTest method testAssignMigrations.
@Test
public void testAssignMigrations() {
servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.1", 1234), "a"), new FakeTServer());
servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.2", 1234), "b"), new FakeTServer());
servers.put(new TServerInstance(HostAndPort.fromParts("127.0.0.3", 1234), "c"), new FakeTServer());
List<KeyExtent> metadataTable = new ArrayList<>();
String table = "t1";
metadataTable.add(makeExtent(table, null, null));
table = "t2";
metadataTable.add(makeExtent(table, "a", null));
metadataTable.add(makeExtent(table, null, "a"));
table = "t3";
metadataTable.add(makeExtent(table, "a", null));
metadataTable.add(makeExtent(table, "b", "a"));
metadataTable.add(makeExtent(table, "c", "b"));
metadataTable.add(makeExtent(table, "d", "c"));
metadataTable.add(makeExtent(table, "e", "d"));
metadataTable.add(makeExtent(table, null, "e"));
Collections.sort(metadataTable);
TestDefaultLoadBalancer balancer = new TestDefaultLoadBalancer();
SortedMap<TServerInstance, TabletServerStatus> current = new TreeMap<>();
for (Entry<TServerInstance, FakeTServer> entry : servers.entrySet()) {
current.put(entry.getKey(), entry.getValue().getStatus(entry.getKey()));
}
assignTablets(metadataTable, servers, current, balancer);
// Verify that the counts on the tables are correct
Map<String, Integer> expectedCounts = new HashMap<>();
expectedCounts.put("t1", 1);
expectedCounts.put("t2", 1);
expectedCounts.put("t3", 2);
checkBalance(metadataTable, servers, expectedCounts);
// Rebalance once
for (Entry<TServerInstance, FakeTServer> entry : servers.entrySet()) {
current.put(entry.getKey(), entry.getValue().getStatus(entry.getKey()));
}
// Nothing should happen, we are balanced
ArrayList<TabletMigration> out = new ArrayList<>();
balancer.getMigrations(current, out);
assertEquals(out.size(), 0);
// Take down a tabletServer
TServerInstance first = current.keySet().iterator().next();
current.remove(first);
FakeTServer remove = servers.remove(first);
// reassign offline extents
assignTablets(remove.extents, servers, current, balancer);
checkBalance(metadataTable, servers, null);
}
Aggregations