Search in sources :

Example 26 with JanusGraphException

use of org.janusgraph.core.JanusGraphException in project janusgraph by JanusGraph.

the class StandardJanusGraph method newTransaction.

public StandardJanusGraphTx newTransaction(final TransactionConfiguration configuration) {
    if (!isOpen)
        ExceptionFactory.graphShutdown();
    try {
        StandardJanusGraphTx tx = new StandardJanusGraphTx(this, configuration);
        tx.setBackendTransaction(openBackendTransaction(tx));
        openTransactions.add(tx);
        return tx;
    } catch (BackendException e) {
        throw new JanusGraphException("Could not start new transaction", e);
    }
}
Also used : StandardJanusGraphTx(org.janusgraph.graphdb.transaction.StandardJanusGraphTx) JanusGraphException(org.janusgraph.core.JanusGraphException) BackendException(org.janusgraph.diskstorage.BackendException)

Example 27 with JanusGraphException

use of org.janusgraph.core.JanusGraphException in project janusgraph by JanusGraph.

the class FulgoraGraphComputer method executeIterationOfJob.

private void executeIterationOfJob(VertexProgramScanJob.Executor job, int iteration) {
    initializeVertexMemoryForIteration();
    StandardScanner.Builder scanBuilder = createScanBuilderForJob(job, iteration);
    PartitionedVertexProgramExecutor programExecutor = new PartitionedVertexProgramExecutor(graph, memory, vertexMemory, vertexProgram);
    try {
        // Iterates over all vertices and computes the vertex program on all non-partitioned vertices. For partitioned ones, the data is aggregated
        ScanMetrics jobResult = executeOnNonPartitionedVertices(iteration, scanBuilder);
        executeOnPartitionedVertices(iteration, programExecutor, jobResult);
    } catch (Exception e) {
        throw new JanusGraphException(e);
    }
    vertexMemory.completeIteration();
}
Also used : StandardScanner(org.janusgraph.diskstorage.keycolumnvalue.scan.StandardScanner) JanusGraphException(org.janusgraph.core.JanusGraphException) ScanMetrics(org.janusgraph.diskstorage.keycolumnvalue.scan.ScanMetrics) JanusGraphException(org.janusgraph.core.JanusGraphException) BackendException(org.janusgraph.diskstorage.BackendException) ExecutionException(java.util.concurrent.ExecutionException)

Example 28 with JanusGraphException

use of org.janusgraph.core.JanusGraphException in project janusgraph by JanusGraph.

the class StandardLogProcessorFramework method shutdown.

@Override
public synchronized void shutdown() throws JanusGraphException {
    if (!isOpen)
        return;
    isOpen = false;
    try {
        ExceptionWrapper exceptionWrapper = new ExceptionWrapper();
        for (Log log : processorLogs.values()) {
            ExecuteUtil.executeWithCatching(log::close, exceptionWrapper);
        }
        ExecuteUtil.throwIfException(exceptionWrapper);
        processorLogs.clear();
    } catch (BackendException e) {
        throw new JanusGraphException(e);
    }
}
Also used : Log(org.janusgraph.diskstorage.log.Log) JanusGraphException(org.janusgraph.core.JanusGraphException) ExceptionWrapper(org.janusgraph.util.datastructures.ExceptionWrapper) BackendException(org.janusgraph.diskstorage.BackendException)

Example 29 with JanusGraphException

use of org.janusgraph.core.JanusGraphException in project janusgraph by JanusGraph.

the class IndexRepairJob method workerIterationEnd.

@Override
public void workerIterationEnd(final ScanMetrics metrics) {
    try {
        if (index instanceof JanusGraphIndex) {
            BackendTransaction mutator = writeTx.getTxHandle();
            IndexType indexType = managementSystem.getSchemaVertex(index).asIndexType();
            if (indexType.isMixedIndex() && documentsPerStore.size() > 0) {
                mutator.getIndexTransaction(indexType.getBackingIndexName()).restore(documentsPerStore);
                documentsPerStore = new HashMap<>();
            }
        }
    } catch (BackendException e) {
        throw new JanusGraphException(e.getMessage(), e);
    } finally {
        super.workerIterationEnd(metrics);
    }
}
Also used : JanusGraphException(org.janusgraph.core.JanusGraphException) JanusGraphIndex(org.janusgraph.core.schema.JanusGraphIndex) MixedIndexType(org.janusgraph.graphdb.types.MixedIndexType) IndexType(org.janusgraph.graphdb.types.IndexType) CompositeIndexType(org.janusgraph.graphdb.types.CompositeIndexType) BackendTransaction(org.janusgraph.diskstorage.BackendTransaction) BackendException(org.janusgraph.diskstorage.BackendException)

Example 30 with JanusGraphException

use of org.janusgraph.core.JanusGraphException in project janusgraph by JanusGraph.

the class IndexRemoveJob method process.

@Override
public void process(StaticBuffer key, Map<SliceQuery, EntryList> entries, ScanMetrics metrics) {
    // The queries are already tailored enough => everything should be removed
    try {
        BackendTransaction mutator = writeTx.getTxHandle();
        final List<Entry> deletions;
        if (entries.size() == 1) {
            deletions = entries.values().iterator().next();
        } else {
            final int size = IteratorUtils.stream(entries.values().iterator()).map(List::size).reduce(0, Integer::sum);
            deletions = new ArrayList<>(size);
            entries.values().forEach(deletions::addAll);
        }
        metrics.incrementCustom(DELETED_RECORDS_COUNT, deletions.size());
        if (isRelationTypeIndex()) {
            mutator.mutateEdges(key, KCVSCache.NO_ADDITIONS, deletions);
        } else {
            mutator.mutateIndex(key, KCVSCache.NO_ADDITIONS, deletions);
        }
    } catch (final Exception e) {
        managementSystem.rollback();
        writeTx.rollback();
        metrics.incrementCustom(FAILED_TX);
        throw new JanusGraphException(e.getMessage(), e);
    }
}
Also used : Entry(org.janusgraph.diskstorage.Entry) JanusGraphException(org.janusgraph.core.JanusGraphException) BackendTransaction(org.janusgraph.diskstorage.BackendTransaction) JanusGraphException(org.janusgraph.core.JanusGraphException)

Aggregations

JanusGraphException (org.janusgraph.core.JanusGraphException)46 BackendException (org.janusgraph.diskstorage.BackendException)18 PropertyKey (org.janusgraph.core.PropertyKey)9 Test (org.junit.jupiter.api.Test)7 JanusGraphIndex (org.janusgraph.core.schema.JanusGraphIndex)6 StandardScanner (org.janusgraph.diskstorage.keycolumnvalue.scan.StandardScanner)6 Set (java.util.Set)5 JanusGraphManagement (org.janusgraph.core.schema.JanusGraphManagement)5 CompositeIndexType (org.janusgraph.graphdb.types.CompositeIndexType)5 IndexType (org.janusgraph.graphdb.types.IndexType)5 MixedIndexType (org.janusgraph.graphdb.types.MixedIndexType)5 RepeatedIfExceptionsTest (io.github.artsok.RepeatedIfExceptionsTest)4 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 Map (java.util.Map)4 ExecutionException (java.util.concurrent.ExecutionException)4 Vertex (org.apache.tinkerpop.gremlin.structure.Vertex)4 JanusGraphVertex (org.janusgraph.core.JanusGraphVertex)4 RelationTypeIndex (org.janusgraph.core.schema.RelationTypeIndex)4 ScanMetrics (org.janusgraph.diskstorage.keycolumnvalue.scan.ScanMetrics)4