use of org.apache.accumulo.core.data.TabletId 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
}
}
use of org.apache.accumulo.core.data.TabletId in project accumulo by apache.
the class TabletServerBatchWriter method checkForFailures.
private void checkForFailures() throws MutationsRejectedException {
if (somethingFailed) {
List<ConstraintViolationSummary> cvsList = violations.asList();
HashMap<TabletId, Set<org.apache.accumulo.core.client.security.SecurityErrorCode>> af = new HashMap<>();
for (Entry<KeyExtent, Set<SecurityErrorCode>> entry : authorizationFailures.entrySet()) {
HashSet<org.apache.accumulo.core.client.security.SecurityErrorCode> codes = new HashSet<>();
for (SecurityErrorCode sce : entry.getValue()) {
codes.add(org.apache.accumulo.core.client.security.SecurityErrorCode.valueOf(sce.name()));
}
af.put(new TabletIdImpl(entry.getKey()), codes);
}
throw new MutationsRejectedException(context.getInstance(), cvsList, af, serverSideErrors, unknownErrors, lastUnknownError);
}
}
Aggregations