Search in sources :

Example 6 with BadLocationStateException

use of org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException in project accumulo by apache.

the class MergeStats method verifyMergeConsistency.

private boolean verifyMergeConsistency(AccumuloClient accumuloClient, CurrentState manager) throws TableNotFoundException, IOException {
    MergeStats verify = new MergeStats(info);
    KeyExtent extent = info.getExtent();
    Scanner scanner = accumuloClient.createScanner(extent.isMeta() ? RootTable.NAME : MetadataTable.NAME, Authorizations.EMPTY);
    MetaDataTableScanner.configureScanner(scanner, manager);
    Text start = extent.prevEndRow();
    if (start == null) {
        start = new Text();
    }
    TableId tableId = extent.tableId();
    Text first = TabletsSection.encodeRow(tableId, start);
    Range range = new Range(first, false, null, true);
    scanner.setRange(range.clip(TabletsSection.getRange()));
    KeyExtent prevExtent = null;
    log.debug("Scanning range {}", range);
    for (Entry<Key, Value> entry : scanner) {
        TabletLocationState tls;
        try {
            tls = MetaDataTableScanner.createTabletLocationState(entry.getKey(), entry.getValue());
        } catch (BadLocationStateException e) {
            log.error("{}", e.getMessage(), e);
            return false;
        }
        log.debug("consistency check: {} walogs {}", tls, tls.walogs.size());
        if (!tls.extent.tableId().equals(tableId)) {
            break;
        }
        if (!tls.walogs.isEmpty() && verify.getMergeInfo().needsToBeChopped(tls.extent)) {
            log.debug("failing consistency: needs to be chopped {}", tls.extent);
            return false;
        }
        if (prevExtent == null) {
            // the start of the merge range
            if (tls.extent.prevEndRow() != null && tls.extent.prevEndRow().compareTo(start) > 0) {
                log.debug("failing consistency: prev row is too high {}", start);
                return false;
            }
            if (tls.getState(manager.onlineTabletServers()) != TabletState.UNASSIGNED && tls.getState(manager.onlineTabletServers()) != TabletState.SUSPENDED) {
                log.debug("failing consistency: assigned or hosted {}", tls);
                return false;
            }
        } else if (!tls.extent.isPreviousExtent(prevExtent)) {
            log.debug("hole in {}", MetadataTable.NAME);
            return false;
        }
        prevExtent = tls.extent;
        verify.update(tls.extent, tls.getState(manager.onlineTabletServers()), tls.chopped, !tls.walogs.isEmpty());
        // stop when we've seen the tablet just beyond our range
        if (tls.extent.prevEndRow() != null && extent.endRow() != null && tls.extent.prevEndRow().compareTo(extent.endRow()) > 0) {
            break;
        }
    }
    log.debug("chopped {} v.chopped {} unassigned {} v.unassigned {} verify.total {}", chopped, verify.chopped, unassigned, verify.unassigned, verify.total);
    return chopped == verify.chopped && unassigned == verify.unassigned && unassigned == verify.total;
}
Also used : TableId(org.apache.accumulo.core.data.TableId) MetaDataTableScanner(org.apache.accumulo.server.manager.state.MetaDataTableScanner) Scanner(org.apache.accumulo.core.client.Scanner) Value(org.apache.accumulo.core.data.Value) TabletLocationState(org.apache.accumulo.core.metadata.TabletLocationState) Text(org.apache.hadoop.io.Text) Range(org.apache.accumulo.core.data.Range) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) Key(org.apache.accumulo.core.data.Key) BadLocationStateException(org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException)

Aggregations

TabletLocationState (org.apache.accumulo.core.metadata.TabletLocationState)6 BadLocationStateException (org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException)6 TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)4 Key (org.apache.accumulo.core.data.Key)3 Value (org.apache.accumulo.core.data.Value)3 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)3 TableId (org.apache.accumulo.core.data.TableId)2 DistributedStoreException (org.apache.accumulo.server.manager.state.DistributedStoreException)2 Text (org.apache.hadoop.io.Text)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 AccumuloException (org.apache.accumulo.core.client.AccumuloException)1 MutationsRejectedException (org.apache.accumulo.core.client.MutationsRejectedException)1 Scanner (org.apache.accumulo.core.client.Scanner)1 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)1 Range (org.apache.accumulo.core.data.Range)1 ManagerState (org.apache.accumulo.core.manager.thrift.ManagerState)1