Search in sources :

Example 1 with SuspendingTServer

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);
}
Also used : ArrayList(java.util.ArrayList) Text(org.apache.hadoop.io.Text) KeyExtent(org.apache.accumulo.core.dataImpl.KeyExtent) TServerInstance(org.apache.accumulo.core.metadata.TServerInstance) BadLocationStateException(org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException) SuspendingTServer(org.apache.accumulo.core.metadata.SuspendingTServer) Value(org.apache.accumulo.core.data.Value) Collection(java.util.Collection) TabletLocationState(org.apache.accumulo.core.metadata.TabletLocationState) Key(org.apache.accumulo.core.data.Key)

Aggregations

ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Key (org.apache.accumulo.core.data.Key)1 Value (org.apache.accumulo.core.data.Value)1 KeyExtent (org.apache.accumulo.core.dataImpl.KeyExtent)1 SuspendingTServer (org.apache.accumulo.core.metadata.SuspendingTServer)1 TServerInstance (org.apache.accumulo.core.metadata.TServerInstance)1 TabletLocationState (org.apache.accumulo.core.metadata.TabletLocationState)1 BadLocationStateException (org.apache.accumulo.core.metadata.TabletLocationState.BadLocationStateException)1 Text (org.apache.hadoop.io.Text)1