use of org.apache.accumulo.core.metadata.SuspendingTServer in project accumulo by apache.
the class MetaDataTableScanner method createTabletLocationState.
public static TabletLocationState createTabletLocationState(Key k, Value v) throws IOException, BadLocationStateException {
final SortedMap<Key, Value> decodedRow = WholeRowIterator.decodeRow(k, v);
KeyExtent extent = null;
TServerInstance future = null;
TServerInstance current = null;
TServerInstance last = null;
SuspendingTServer suspend = null;
long lastTimestamp = 0;
List<Collection<String>> walogs = new ArrayList<>();
boolean chopped = false;
for (Entry<Key, Value> entry : decodedRow.entrySet()) {
Key key = entry.getKey();
Text row = key.getRow();
Text cf = key.getColumnFamily();
Text cq = key.getColumnQualifier();
if (cf.compareTo(FutureLocationColumnFamily.NAME) == 0) {
TServerInstance location = new TServerInstance(entry.getValue(), cq);
if (future != null) {
throw new BadLocationStateException("found two assignments for the same extent " + row + ": " + future + " and " + location, row);
}
future = location;
} else if (cf.compareTo(CurrentLocationColumnFamily.NAME) == 0) {
TServerInstance location = new TServerInstance(entry.getValue(), cq);
if (current != null) {
throw new BadLocationStateException("found two locations for the same extent " + row + ": " + current + " and " + location, row);
}
current = location;
} else if (cf.compareTo(LogColumnFamily.NAME) == 0) {
String[] split = entry.getValue().toString().split("\\|")[0].split(";");
walogs.add(Arrays.asList(split));
} else if (cf.compareTo(LastLocationColumnFamily.NAME) == 0) {
if (lastTimestamp < entry.getKey().getTimestamp()) {
last = new TServerInstance(entry.getValue(), cq);
}
} else if (cf.compareTo(ChoppedColumnFamily.NAME) == 0) {
chopped = true;
} else if (TabletColumnFamily.PREV_ROW_COLUMN.equals(cf, cq)) {
extent = KeyExtent.fromMetaPrevRow(entry);
} else if (SuspendLocationColumn.SUSPEND_COLUMN.equals(cf, cq)) {
suspend = SuspendingTServer.fromValue(entry.getValue());
}
}
if (extent == null) {
String msg = "No prev-row for key extent " + decodedRow;
log.error(msg);
throw new BadLocationStateException(msg, k.getRow());
}
return new TabletLocationState(extent, future, current, last, suspend, walogs, chopped);
}
Aggregations