Search in sources :

Example 91 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class TabletServerResource method doCurrentOperations.

private List<CurrentOperations> doCurrentOperations(List<TabletStats> tsStats) throws Exception {
    List<CurrentOperations> currentOperations = new ArrayList<>();
    for (TabletStats info : tsStats) {
        if (info.extent == null) {
            historical = info;
            continue;
        }
        total.numEntries += info.numEntries;
        ActionStatsUpdator.update(total.minors, info.minors);
        ActionStatsUpdator.update(total.majors, info.majors);
        KeyExtent extent = new KeyExtent(info.extent);
        Table.ID tableId = extent.getTableId();
        MessageDigest digester = MessageDigest.getInstance("MD5");
        if (extent.getEndRow() != null && extent.getEndRow().getLength() > 0) {
            digester.update(extent.getEndRow().getBytes(), 0, extent.getEndRow().getLength());
        }
        String obscuredExtent = Base64.getEncoder().encodeToString(digester.digest());
        String displayExtent = String.format("[%s]", obscuredExtent);
        String tableName = Tables.getPrintableTableInfoFromId(HdfsZooInstance.getInstance(), tableId);
        currentOperations.add(new CurrentOperations(tableName, tableId, displayExtent, info.numEntries, info.ingestRate, info.queryRate, info.minors.num != 0 ? info.minors.elapsed / info.minors.num : null, stddev(info.minors.elapsed, info.minors.num, info.minors.sumDev), info.minors.elapsed != 0 ? info.minors.count / info.minors.elapsed : null, info.majors.num != 0 ? info.majors.elapsed / info.majors.num : null, stddev(info.majors.elapsed, info.majors.num, info.majors.sumDev), info.majors.elapsed != 0 ? info.majors.count / info.majors.elapsed : null));
    }
    return currentOperations;
}
Also used : Table(org.apache.accumulo.core.client.impl.Table) TabletStats(org.apache.accumulo.core.tabletserver.thrift.TabletStats) ArrayList(java.util.ArrayList) MessageDigest(java.security.MessageDigest) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent)

Example 92 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class ConditionalWriterImpl method sendToServer.

private void sendToServer(HostAndPort location, TabletServerMutations<QCMutation> mutations) {
    TabletClientService.Iface client = null;
    TInfo tinfo = Tracer.traceInfo();
    Map<Long, CMK> cmidToCm = new HashMap<>();
    MutableLong cmid = new MutableLong(0);
    SessionID sessionId = null;
    try {
        Map<TKeyExtent, List<TConditionalMutation>> tmutations = new HashMap<>();
        CompressedIterators compressedIters = new CompressedIterators();
        convertMutations(mutations, cmidToCm, cmid, tmutations, compressedIters);
        // getClient() call must come after converMutations in case it throws a TException
        client = getClient(location);
        List<TCMResult> tresults = null;
        while (tresults == null) {
            try {
                sessionId = reserveSessionID(location, client, tinfo);
                tresults = client.conditionalUpdate(tinfo, sessionId.sessionID, tmutations, compressedIters.getSymbolTable());
            } catch (NoSuchScanIDException nssie) {
                sessionId = null;
                invalidateSessionID(location);
            }
        }
        HashSet<KeyExtent> extentsToInvalidate = new HashSet<>();
        ArrayList<QCMutation> ignored = new ArrayList<>();
        for (TCMResult tcmResult : tresults) {
            if (tcmResult.status == TCMStatus.IGNORED) {
                CMK cmk = cmidToCm.get(tcmResult.cmid);
                ignored.add(cmk.cm);
                extentsToInvalidate.add(cmk.ke);
            } else {
                QCMutation qcm = cmidToCm.get(tcmResult.cmid).cm;
                qcm.queueResult(new Result(fromThrift(tcmResult.status), qcm, location.toString()));
            }
        }
        for (KeyExtent ke : extentsToInvalidate) {
            locator.invalidateCache(ke);
        }
        queueRetry(ignored, location);
    } catch (ThriftSecurityException tse) {
        AccumuloSecurityException ase = new AccumuloSecurityException(context.getCredentials().getPrincipal(), tse.getCode(), Tables.getPrintableTableInfoFromId(context.getInstance(), tableId), tse);
        queueException(location, cmidToCm, ase);
    } catch (TTransportException e) {
        locator.invalidateCache(context.getInstance(), location.toString());
        invalidateSession(location, mutations, cmidToCm, sessionId);
    } catch (TApplicationException tae) {
        queueException(location, cmidToCm, new AccumuloServerException(location.toString(), tae));
    } catch (TException e) {
        locator.invalidateCache(context.getInstance(), location.toString());
        invalidateSession(location, mutations, cmidToCm, sessionId);
    } catch (Exception e) {
        queueException(location, cmidToCm, e);
    } finally {
        if (sessionId != null)
            unreserveSessionID(location);
        ThriftUtil.returnClient((TServiceClient) client);
    }
}
Also used : TException(org.apache.thrift.TException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TTransportException(org.apache.thrift.transport.TTransportException) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TCMResult(org.apache.accumulo.core.data.thrift.TCMResult) List(java.util.List) ArrayList(java.util.ArrayList) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) HashSet(java.util.HashSet) TInfo(org.apache.accumulo.core.trace.thrift.TInfo) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TCMResult(org.apache.accumulo.core.data.thrift.TCMResult) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) TableOfflineException(org.apache.accumulo.core.client.TableOfflineException) TTransportException(org.apache.thrift.transport.TTransportException) TableNotFoundException(org.apache.accumulo.core.client.TableNotFoundException) NoSuchScanIDException(org.apache.accumulo.core.tabletserver.thrift.NoSuchScanIDException) VisibilityParseException(org.apache.accumulo.core.security.VisibilityParseException) BadArgumentException(org.apache.accumulo.core.util.BadArgumentException) ThriftSecurityException(org.apache.accumulo.core.client.impl.thrift.ThriftSecurityException) TimedOutException(org.apache.accumulo.core.client.TimedOutException) TableDeletedException(org.apache.accumulo.core.client.TableDeletedException) AccumuloSecurityException(org.apache.accumulo.core.client.AccumuloSecurityException) NoSuchElementException(java.util.NoSuchElementException) TApplicationException(org.apache.thrift.TApplicationException) TException(org.apache.thrift.TException) AccumuloException(org.apache.accumulo.core.client.AccumuloException) TApplicationException(org.apache.thrift.TApplicationException) MutableLong(org.apache.commons.lang.mutable.MutableLong) MutableLong(org.apache.commons.lang.mutable.MutableLong) TabletClientService(org.apache.accumulo.core.tabletserver.thrift.TabletClientService)

Example 93 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class ConditionalWriterImpl method convertMutations.

private void convertMutations(TabletServerMutations<QCMutation> mutations, Map<Long, CMK> cmidToCm, MutableLong cmid, Map<TKeyExtent, List<TConditionalMutation>> tmutations, CompressedIterators compressedIters) {
    for (Entry<KeyExtent, List<QCMutation>> entry : mutations.getMutations().entrySet()) {
        TKeyExtent tke = entry.getKey().toThrift();
        ArrayList<TConditionalMutation> tcondMutaions = new ArrayList<>();
        List<QCMutation> condMutations = entry.getValue();
        for (QCMutation cm : condMutations) {
            TMutation tm = cm.toThrift();
            List<TCondition> conditions = convertConditions(cm, compressedIters);
            cmidToCm.put(cmid.longValue(), new CMK(entry.getKey(), cm));
            TConditionalMutation tcm = new TConditionalMutation(conditions, tm, cmid.longValue());
            cmid.increment();
            tcondMutaions.add(tcm);
        }
        tmutations.put(tke, tcondMutaions);
    }
}
Also used : ArrayList(java.util.ArrayList) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) TConditionalMutation(org.apache.accumulo.core.data.thrift.TConditionalMutation) TKeyExtent(org.apache.accumulo.core.data.thrift.TKeyExtent) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent) TCondition(org.apache.accumulo.core.data.thrift.TCondition) List(java.util.List) ArrayList(java.util.ArrayList) TMutation(org.apache.accumulo.core.data.thrift.TMutation)

Example 94 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class LogEntry method fromKeyValue.

public static LogEntry fromKeyValue(Key key, Value value) {
    String qualifier = key.getColumnQualifier().toString();
    if (qualifier.indexOf('/') < 1) {
        throw new IllegalArgumentException("Bad key for log entry: " + key);
    }
    KeyExtent extent = new KeyExtent(key.getRow(), EMPTY_TEXT);
    String[] parts = key.getColumnQualifier().toString().split("/", 2);
    String server = parts[0];
    // handle old-style log entries that specify log sets
    parts = value.toString().split("\\|")[0].split(";");
    String filename = parts[parts.length - 1];
    long timestamp = key.getTimestamp();
    return new LogEntry(extent, timestamp, server, filename);
}
Also used : KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent)

Example 95 with KeyExtent

use of org.apache.accumulo.core.data.impl.KeyExtent in project accumulo by apache.

the class MasterMetadataUtil method fixSplit.

public static KeyExtent fixSplit(ClientContext context, Text metadataEntry, SortedMap<ColumnFQ, Value> columns, TServerInstance tserver, ZooLock lock) throws AccumuloException, IOException {
    log.info("Incomplete split {} attempting to fix", metadataEntry);
    Value oper = columns.get(TabletsSection.TabletColumnFamily.OLD_PREV_ROW_COLUMN);
    if (columns.get(TabletsSection.TabletColumnFamily.SPLIT_RATIO_COLUMN) == null) {
        throw new IllegalArgumentException("Metadata entry does not have split ratio (" + metadataEntry + ")");
    }
    double splitRatio = Double.parseDouble(new String(columns.get(TabletsSection.TabletColumnFamily.SPLIT_RATIO_COLUMN).get(), UTF_8));
    Value prevEndRowIBW = columns.get(TabletsSection.TabletColumnFamily.PREV_ROW_COLUMN);
    if (prevEndRowIBW == null) {
        throw new IllegalArgumentException("Metadata entry does not have prev row (" + metadataEntry + ")");
    }
    Value time = columns.get(TabletsSection.ServerColumnFamily.TIME_COLUMN);
    if (time == null) {
        throw new IllegalArgumentException("Metadata entry does not have time (" + metadataEntry + ")");
    }
    Value flushID = columns.get(TabletsSection.ServerColumnFamily.FLUSH_COLUMN);
    long initFlushID = -1;
    if (flushID != null)
        initFlushID = Long.parseLong(flushID.toString());
    Value compactID = columns.get(TabletsSection.ServerColumnFamily.COMPACT_COLUMN);
    long initCompactID = -1;
    if (compactID != null)
        initCompactID = Long.parseLong(compactID.toString());
    Text metadataPrevEndRow = KeyExtent.decodePrevEndRow(prevEndRowIBW);
    Table.ID tableId = (new KeyExtent(metadataEntry, (Text) null)).getTableId();
    return fixSplit(context, tableId, metadataEntry, metadataPrevEndRow, oper, splitRatio, tserver, time.toString(), initFlushID, initCompactID, lock);
}
Also used : MetadataTable(org.apache.accumulo.core.metadata.MetadataTable) Table(org.apache.accumulo.core.client.impl.Table) DataFileValue(org.apache.accumulo.core.metadata.schema.DataFileValue) Value(org.apache.accumulo.core.data.Value) Text(org.apache.hadoop.io.Text) KeyExtent(org.apache.accumulo.core.data.impl.KeyExtent)

Aggregations

KeyExtent (org.apache.accumulo.core.data.impl.KeyExtent)219 Test (org.junit.Test)84 Text (org.apache.hadoop.io.Text)82 Value (org.apache.accumulo.core.data.Value)67 ArrayList (java.util.ArrayList)63 Key (org.apache.accumulo.core.data.Key)59 HashMap (java.util.HashMap)50 Mutation (org.apache.accumulo.core.data.Mutation)40 Scanner (org.apache.accumulo.core.client.Scanner)39 Range (org.apache.accumulo.core.data.Range)39 TreeMap (java.util.TreeMap)37 TServerInstance (org.apache.accumulo.server.master.state.TServerInstance)36 Table (org.apache.accumulo.core.client.impl.Table)34 HashSet (java.util.HashSet)30 List (java.util.List)29 TKeyExtent (org.apache.accumulo.core.data.thrift.TKeyExtent)29 Connector (org.apache.accumulo.core.client.Connector)28 IOException (java.io.IOException)27 MetadataTable (org.apache.accumulo.core.metadata.MetadataTable)25 DataFileValue (org.apache.accumulo.core.metadata.schema.DataFileValue)25