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