use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method alterElementVisibility.
void alterElementVisibility(AccumuloElement element, Visibility newVisibility) {
String elementRowKey = element.getId();
Span trace = Trace.start("alterElementVisibility");
trace.data("elementRowKey", elementRowKey);
try {
if (element instanceof Edge) {
Edge edge = (Edge) element;
String vertexOutRowKey = edge.getVertexId(Direction.OUT);
Mutation vertexOutMutation = new Mutation(vertexOutRowKey);
if (elementMutationBuilder.alterEdgeVertexOutVertex(vertexOutMutation, edge, newVisibility)) {
addMutations(VertexiumObjectType.VERTEX, vertexOutMutation);
}
String vertexInRowKey = edge.getVertexId(Direction.IN);
Mutation vertexInMutation = new Mutation(vertexInRowKey);
if (elementMutationBuilder.alterEdgeVertexInVertex(vertexInMutation, edge, newVisibility)) {
addMutations(VertexiumObjectType.VERTEX, vertexInMutation);
}
}
Mutation m = new Mutation(elementRowKey);
if (elementMutationBuilder.alterElementVisibility(m, element, newVisibility)) {
addMutations(element, m);
}
element.setVisibility(newVisibility);
} finally {
trace.stop();
}
}
use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method traceOn.
@Override
public void traceOn(String description, Map<String, String> data) {
if (!distributedTraceEnabled) {
try {
ClientConfiguration conf = getConfiguration().getClientConfiguration();
DistributedTrace.enable(null, AccumuloGraph.class.getSimpleName(), conf);
distributedTraceEnabled = true;
} catch (Exception e) {
throw new VertexiumException("Could not enable DistributedTrace", e);
}
}
if (Trace.isTracing()) {
throw new VertexiumException("Trace already running");
}
Span span = Trace.on(description);
for (Map.Entry<String, String> dataEntry : data.entrySet()) {
span.data(dataEntry.getKey(), dataEntry.getValue());
}
LOGGER.info("Started trace '%s'", description);
}
use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method getVertices.
@Override
public CloseableIterable<Vertex> getVertices(Iterable<String> ids, final FetchHints fetchHints, final Long endTime, final Authorizations authorizations) {
final List<org.apache.accumulo.core.data.Range> ranges = new ArrayList<>();
int idCount = 0;
for (String id : ids) {
ranges.add(RangeUtils.createRangeFromString(id));
idCount++;
}
if (ranges.size() == 0) {
return new EmptyClosableIterable<>();
}
final Span trace = Trace.start("getVertices");
trace.data("idCount", Integer.toString(idCount));
traceDataFetchHints(trace, fetchHints);
final long timerStartTime = System.currentTimeMillis();
return new LookAheadIterable<Map.Entry<Key, Value>, Vertex>() {
public ScannerBase scanner;
@Override
protected boolean isIncluded(Map.Entry<Key, Value> src, Vertex dest) {
return dest != null;
}
@Override
protected Vertex convert(Map.Entry<Key, Value> row) {
return createVertexFromVertexIteratorValue(row.getKey(), row.getValue(), fetchHints, authorizations);
}
@Override
protected Iterator<Map.Entry<Key, Value>> createIterator() {
Long startTime = null;
scanner = createVertexScanner(fetchHints, 1, startTime, endTime, ranges, authorizations);
return scanner.iterator();
}
@Override
public void close() {
super.close();
scanner.close();
trace.stop();
GRAPH_LOGGER.logEndIterator(System.currentTimeMillis() - timerStartTime);
}
};
}
use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method getVertex.
@Override
public Vertex getVertex(String vertexId, FetchHints fetchHints, Long endTime, Authorizations authorizations) throws VertexiumException {
try {
if (vertexId == null) {
return null;
}
Span trace = Trace.start("getVertex");
trace.data("vertexId", vertexId);
traceDataFetchHints(trace, fetchHints);
return singleOrDefault(getVerticesInRange(trace, new org.apache.accumulo.core.data.Range(vertexId), fetchHints, endTime, authorizations), null);
} catch (IllegalStateException ex) {
throw new VertexiumException("Failed to find vertex with id: " + vertexId, ex);
} catch (RuntimeException ex) {
if (ex.getCause() instanceof AccumuloSecurityException) {
throw new SecurityVertexiumException("Could not get vertex " + vertexId + " with authorizations: " + authorizations, authorizations, ex.getCause());
}
throw ex;
}
}
use of org.apache.accumulo.core.trace.Span in project vertexium by visallo.
the class AccumuloGraph method prepareVertex.
@Override
public AccumuloVertexBuilder prepareVertex(String vertexId, Long timestamp, Visibility visibility) {
if (vertexId == null) {
vertexId = getIdGenerator().nextId();
}
if (timestamp == null) {
timestamp = IncreasingTime.currentTimeMillis();
}
final long timestampLong = timestamp;
final String finalVertexId = vertexId;
return new AccumuloVertexBuilder(finalVertexId, visibility, elementMutationBuilder) {
@Override
public Vertex save(Authorizations authorizations) {
Span trace = Trace.start("prepareVertex");
trace.data("vertexId", finalVertexId);
try {
// This has to occur before createVertex since it will mutate the properties
getElementMutationBuilder().saveVertexBuilder(AccumuloGraph.this, this, timestampLong);
AccumuloVertex vertex = createVertex(authorizations);
if (getIndexHint() != IndexHint.DO_NOT_INDEX) {
getSearchIndex().addElement(AccumuloGraph.this, vertex, authorizations);
getSearchIndex().addElementExtendedData(AccumuloGraph.this, vertex, getExtendedData(), authorizations);
for (ExtendedDataDeleteMutation m : getExtendedDataDeletes()) {
getSearchIndex().deleteExtendedData(AccumuloGraph.this, vertex, m.getTableName(), m.getRow(), m.getColumnName(), m.getKey(), m.getVisibility(), authorizations);
}
}
if (hasEventListeners()) {
queueEvent(new AddVertexEvent(AccumuloGraph.this, vertex));
queueEvents(vertex, getProperties(), getPropertyDeletes(), getPropertySoftDeletes(), getExtendedData(), getExtendedDataDeletes());
}
return vertex;
} finally {
trace.stop();
}
}
@Override
protected AccumuloVertex createVertex(Authorizations authorizations) {
Iterable<Visibility> hiddenVisibilities = null;
return new AccumuloVertex(AccumuloGraph.this, getElementId(), getVisibility(), getProperties(), getPropertyDeletes(), getPropertySoftDeletes(), hiddenVisibilities, getExtendedDataTableNames(), timestampLong, FetchHints.ALL_INCLUDING_HIDDEN, authorizations);
}
};
}
Aggregations