Search in sources :

Example 6 with EntryList

use of com.thinkaurelius.titan.diskstorage.EntryList in project titan by thinkaurelius.

the class LockCleanerRunnableTest method testDeleteSingleLock.

/**
     * Simplest case test of the lock cleaner.
     */
@Test
public void testDeleteSingleLock() throws BackendException {
    Instant now = Instant.ofEpochMilli(1L);
    Entry expiredLockCol = StaticArrayEntry.of(codec.toLockCol(now, defaultLockRid, TimestampProviders.MILLI), BufferUtil.getIntBuffer(0));
    EntryList expiredSingleton = StaticArrayEntryList.of(expiredLockCol);
    now = now.plusMillis(1);
    del = new StandardLockCleanerRunnable(store, kc, tx, codec, now, TimestampProviders.MILLI);
    expect(store.getSlice(eq(ksq), eq(tx))).andReturn(expiredSingleton);
    store.mutate(eq(key), eq(ImmutableList.<Entry>of()), eq(ImmutableList.<StaticBuffer>of(expiredLockCol.getColumn())), anyObject(StoreTransaction.class));
    ctrl.replay();
    del.run();
}
Also used : StandardLockCleanerRunnable(com.thinkaurelius.titan.diskstorage.locking.consistentkey.StandardLockCleanerRunnable) Entry(com.thinkaurelius.titan.diskstorage.Entry) StoreTransaction(com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction) Instant(java.time.Instant) StaticBuffer(com.thinkaurelius.titan.diskstorage.StaticBuffer) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) Test(org.junit.Test)

Example 7 with EntryList

use of com.thinkaurelius.titan.diskstorage.EntryList in project titan by thinkaurelius.

the class VertexJobConverter method process.

@Override
public void process(StaticBuffer key, Map<SliceQuery, EntryList> entries, ScanMetrics metrics) {
    long vertexId = getVertexId(key);
    assert entries.get(VERTEX_EXISTS_QUERY) != null;
    if (isGhostVertex(vertexId, entries.get(VERTEX_EXISTS_QUERY))) {
        metrics.incrementCustom(GHOST_VERTEX_COUNT);
        return;
    }
    TitanVertex vertex = tx.getInternalVertex(vertexId);
    Preconditions.checkArgument(vertex instanceof PreloadedVertex, "The bounding transaction is not configured correctly");
    PreloadedVertex v = (PreloadedVertex) vertex;
    v.setAccessCheck(PreloadedVertex.OPENSTAR_CHECK);
    for (Map.Entry<SliceQuery, EntryList> entry : entries.entrySet()) {
        SliceQuery sq = entry.getKey();
        if (sq.equals(VERTEX_EXISTS_QUERY))
            continue;
        EntryList entryList = entry.getValue();
        if (entryList.size() >= sq.getLimit())
            metrics.incrementCustom(TRUNCATED_ENTRY_LISTS);
        v.addToQueryCache(sq.updateLimit(Query.NO_LIMIT), entryList);
    }
    job.process(v, metrics);
}
Also used : PreloadedVertex(com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex) TitanVertex(com.thinkaurelius.titan.core.TitanVertex) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) Map(java.util.Map) SliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)

Example 8 with EntryList

use of com.thinkaurelius.titan.diskstorage.EntryList in project titan by thinkaurelius.

the class PartitionedVertexProgramExecutor method run.

public void run(int numThreads, ScanMetrics metrics) {
    StandardTitanTx tx = null;
    Map<Long, EntryList> pVertexAggregates = vertexMemory.retrievePartitionAggregates();
    //Nothing to do here
    if (pVertexAggregates.isEmpty())
        return;
    try (WorkerPool workers = new WorkerPool(numThreads)) {
        tx = VertexJobConverter.startTransaction(graph);
        for (Map.Entry<Long, EntryList> pvertices : pVertexAggregates.entrySet()) {
            if (pvertices.getValue() == null) {
                metrics.incrementCustom(GHOTST_PARTITION_VERTEX);
                continue;
            }
            workers.submit(new PartitionedVertexProcessor(pvertices.getKey(), pvertices.getValue(), tx, metrics));
        }
    } catch (Throwable ex) {
        log.error("Could not post-process partitioned vertices", ex);
        metrics.incrementCustom(PARTITION_VERTEX_POSTFAIL);
    } finally {
        if (tx != null && tx.isOpen())
            tx.rollback();
    }
}
Also used : WorkerPool(com.thinkaurelius.titan.graphdb.util.WorkerPool) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx) Map(java.util.Map)

Example 9 with EntryList

use of com.thinkaurelius.titan.diskstorage.EntryList in project titan by thinkaurelius.

the class VertexProgramScanJob method process.

@Override
public void process(TitanVertex vertex, ScanMetrics metrics) {
    PreloadedVertex v = (PreloadedVertex) vertex;
    long vertexId = v.longId();
    VertexMemoryHandler<M> vh = new VertexMemoryHandler(vertexMemory, v);
    v.setAccessCheck(PreloadedVertex.OPENSTAR_CHECK);
    if (idManager.isPartitionedVertex(vertexId)) {
        if (idManager.isCanonicalVertexId(vertexId)) {
            EntryList results = v.getFromCache(SYSTEM_PROPS_QUERY);
            if (results == null)
                results = EntryList.EMPTY_LIST;
            vertexMemory.setLoadedProperties(vertexId, results);
        }
        for (MessageScope scope : vertexMemory.getPreviousScopes()) {
            if (scope instanceof MessageScope.Local) {
                M combinedMsg = null;
                for (Iterator<M> msgIter = vh.receiveMessages(scope).iterator(); msgIter.hasNext(); ) {
                    M msg = msgIter.next();
                    if (combinedMsg == null)
                        combinedMsg = msg;
                    else
                        combinedMsg = combiner.combine(combinedMsg, msg);
                }
                if (combinedMsg != null)
                    vertexMemory.aggregateMessage(vertexId, combinedMsg, scope);
            }
        }
    } else {
        v.setPropertyMixing(vh);
        vertexProgram.execute(v, vh, memory);
    }
}
Also used : PreloadedVertex(com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) MessageScope(org.apache.tinkerpop.gremlin.process.computer.MessageScope)

Example 10 with EntryList

use of com.thinkaurelius.titan.diskstorage.EntryList in project titan by thinkaurelius.

the class GhostVertexRemover method process.

@Override
public void process(StaticBuffer key, Map<SliceQuery, EntryList> entries, ScanMetrics metrics) {
    long vertexId = getVertexId(key);
    assert entries.size() == 1;
    assert entries.get(everythingQueryLimit) != null;
    final EntryList everything = entries.get(everythingQueryLimit);
    if (!isGhostVertex(vertexId, everything)) {
        return;
    }
    if (everything.size() >= RELATION_COUNT_LIMIT) {
        metrics.incrementCustom(SKIPPED_GHOST_LIMIT_COUNT);
        return;
    }
    TitanVertex vertex = tx.getInternalVertex(vertexId);
    Preconditions.checkArgument(vertex instanceof CacheVertex, "The bounding transaction is not configured correctly");
    CacheVertex v = (CacheVertex) vertex;
    v.loadRelations(EVERYTHING_QUERY, new Retriever<SliceQuery, EntryList>() {

        @Override
        public EntryList get(SliceQuery input) {
            return everything;
        }
    });
    int removedRelations = 0;
    Iterator<TitanRelation> iter = v.query().noPartitionRestriction().relations().iterator();
    while (iter.hasNext()) {
        iter.next();
        iter.remove();
        removedRelations++;
    }
    //There should be no more system relations to remove
    metrics.incrementCustom(REMOVED_VERTEX_COUNT);
    metrics.incrementCustom(REMOVED_RELATION_COUNT, removedRelations);
}
Also used : TitanVertex(com.thinkaurelius.titan.core.TitanVertex) EntryList(com.thinkaurelius.titan.diskstorage.EntryList) CacheVertex(com.thinkaurelius.titan.graphdb.vertices.CacheVertex) TitanRelation(com.thinkaurelius.titan.core.TitanRelation) SliceQuery(com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)

Aggregations

EntryList (com.thinkaurelius.titan.diskstorage.EntryList)16 SliceQuery (com.thinkaurelius.titan.diskstorage.keycolumnvalue.SliceQuery)6 Entry (com.thinkaurelius.titan.diskstorage.Entry)5 StaticBuffer (com.thinkaurelius.titan.diskstorage.StaticBuffer)4 Map (java.util.Map)4 StandardLockCleanerRunnable (com.thinkaurelius.titan.diskstorage.locking.consistentkey.StandardLockCleanerRunnable)3 Test (org.junit.Test)3 LongArrayList (com.carrotsearch.hppc.LongArrayList)2 ImmutableList (com.google.common.collect.ImmutableList)2 TitanVertex (com.thinkaurelius.titan.core.TitanVertex)2 KeySliceQuery (com.thinkaurelius.titan.diskstorage.keycolumnvalue.KeySliceQuery)2 StoreTransaction (com.thinkaurelius.titan.diskstorage.keycolumnvalue.StoreTransaction)2 CacheTransaction (com.thinkaurelius.titan.diskstorage.keycolumnvalue.cache.CacheTransaction)2 StandardTitanTx (com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx)2 CacheVertex (com.thinkaurelius.titan.graphdb.vertices.CacheVertex)2 PreloadedVertex (com.thinkaurelius.titan.graphdb.vertices.PreloadedVertex)2 Instant (java.time.Instant)2 ArrayList (java.util.ArrayList)2 Preconditions (com.google.common.base.Preconditions)1 Iterables (com.google.common.collect.Iterables)1