use of org.apache.accumulo.core.client.admin.Locations in project accumulo by apache.
the class LocatorIT method testBasic.
@Test
public void testBasic() throws Exception {
Connector conn = getConnector();
String tableName = getUniqueNames(1)[0];
conn.tableOperations().create(tableName);
Range r1 = new Range("m");
Range r2 = new Range("o", "x");
String tableId = conn.tableOperations().tableIdMap().get(tableName);
TabletId t1 = newTabletId(tableId, null, null);
TabletId t2 = newTabletId(tableId, "r", null);
TabletId t3 = newTabletId(tableId, null, "r");
ArrayList<Range> ranges = new ArrayList<>();
HashSet<String> tservers = new HashSet<>(conn.instanceOperations().getTabletServers());
ranges.add(r1);
Locations ret = conn.tableOperations().locate(tableName, ranges);
assertContains(ret, tservers, ImmutableMap.of(r1, ImmutableSet.of(t1)), ImmutableMap.of(t1, ImmutableSet.of(r1)));
ranges.add(r2);
ret = conn.tableOperations().locate(tableName, ranges);
assertContains(ret, tservers, ImmutableMap.of(r1, ImmutableSet.of(t1), r2, ImmutableSet.of(t1)), ImmutableMap.of(t1, ImmutableSet.of(r1, r2)));
TreeSet<Text> splits = new TreeSet<>();
splits.add(new Text("r"));
conn.tableOperations().addSplits(tableName, splits);
ret = conn.tableOperations().locate(tableName, ranges);
assertContains(ret, tservers, ImmutableMap.of(r1, ImmutableSet.of(t2), r2, ImmutableSet.of(t2, t3)), ImmutableMap.of(t2, ImmutableSet.of(r1, r2), t3, ImmutableSet.of(r2)));
conn.tableOperations().offline(tableName, true);
try {
conn.tableOperations().locate(tableName, ranges);
Assert.fail();
} catch (TableOfflineException e) {
// expected
}
conn.tableOperations().delete(tableName);
try {
conn.tableOperations().locate(tableName, ranges);
Assert.fail();
} catch (TableNotFoundException e) {
// expected
}
}
Aggregations