Search in sources :

Example 6 with TabletId

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
    }
}
Also used : Connector(org.apache.accumulo.core.client.Connector) TableOfflineException(org.apache.accumulo.core.client.TableOfflineException) ArrayList(java.util.ArrayList) Locations(org.apache.accumulo.core.client.admin.Locations) Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) TreeSet(java.util.TreeSet) TabletId(org.apache.accumulo.core.data.TabletId) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with TabletId

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);
    }
}
Also used : Set(java.util.Set) TreeSet(java.util.TreeSet) HashSet(java.util.HashSet) HashMap(java.util.HashMap) SecurityErrorCode(org.apache.accumulo.core.client.impl.thrift.SecurityErrorCode) TabletIdImpl(org.apache.accumulo.core.data.impl.TabletIdImpl) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) ConstraintViolationSummary(org.apache.accumulo.core.data.ConstraintViolationSummary) TabletId(org.apache.accumulo.core.data.TabletId) HashSet(java.util.HashSet) MutationsRejectedException(org.apache.accumulo.core.client.MutationsRejectedException)

Aggregations

TabletId (org.apache.accumulo.core.data.TabletId)7 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Set (java.util.Set)4 TreeSet (java.util.TreeSet)4 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)4 HashMap (java.util.HashMap)3 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)3 AccumuloException (org.apache.accumulo.core.client.AccumuloException)2 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)2 IteratorSetting (org.apache.accumulo.core.client.IteratorSetting)2 NamespaceExistsException (org.apache.accumulo.core.client.NamespaceExistsException)2 NamespaceNotEmptyException (org.apache.accumulo.core.client.NamespaceNotEmptyException)2 NamespaceNotFoundException (org.apache.accumulo.core.client.NamespaceNotFoundException)2 TableExistsException (org.apache.accumulo.core.client.TableExistsException)2 ThriftTableOperationException (org.apache.accumulo.core.client.impl.thrift.ThriftTableOperationException)2 ConstraintViolationSummary (org.apache.accumulo.core.data.ConstraintViolationSummary)2 Range (org.apache.accumulo.core.data.Range)2 NoMoreEntriesException (org.apache.accumulo.proxy.thrift.NoMoreEntriesException)2 Text (org.apache.hadoop.io.Text)2