Search in sources :

Example 11 with Span

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();
    }
}
Also used : Mutation(org.apache.accumulo.core.data.Mutation) Span(org.apache.accumulo.core.trace.Span)

Example 12 with Span

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);
}
Also used : Span(org.apache.accumulo.core.trace.Span) IOException(java.io.IOException)

Example 13 with Span

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);
        }
    };
}
Also used : Span(org.apache.accumulo.core.trace.Span) IndexHint(org.vertexium.search.IndexHint) Value(org.apache.accumulo.core.data.Value) StreamingPropertyValue(org.vertexium.property.StreamingPropertyValue) Key(org.apache.accumulo.core.data.Key) PartialKey(org.apache.accumulo.core.data.PartialKey)

Example 14 with Span

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;
    }
}
Also used : Span(org.apache.accumulo.core.trace.Span)

Example 15 with Span

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);
        }
    };
}
Also used : ColumnVisibility(org.apache.accumulo.core.security.ColumnVisibility) Span(org.apache.accumulo.core.trace.Span)

Aggregations

Span (org.apache.accumulo.core.trace.Span)56 Key (org.apache.accumulo.core.data.Key)12 Value (org.apache.accumulo.core.data.Value)12 IOException (java.io.IOException)11 ColumnVisibility (org.apache.accumulo.core.security.ColumnVisibility)10 Text (org.apache.hadoop.io.Text)9 StreamingPropertyValue (org.vertexium.property.StreamingPropertyValue)8 AccumuloException (org.apache.accumulo.core.client.AccumuloException)7 AccumuloSecurityException (org.apache.accumulo.core.client.AccumuloSecurityException)7 TableNotFoundException (org.apache.accumulo.core.client.TableNotFoundException)6 PartialKey (org.apache.accumulo.core.data.PartialKey)6 Mutation (org.apache.accumulo.core.data.Mutation)5 IndexHint (org.vertexium.search.IndexHint)5 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 Connector (org.apache.accumulo.core.client.Connector)4 Scanner (org.apache.accumulo.core.client.Scanner)4 ReplicationTableOfflineException (org.apache.accumulo.core.replication.ReplicationTableOfflineException)4 Status (org.apache.accumulo.server.replication.proto.Replication.Status)4 Test (org.junit.Test)4 FileNotFoundException (java.io.FileNotFoundException)3