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;
}
Aggregations