Search in sources :

Example 1 with StandardTransactionBuilder

use of org.janusgraph.graphdb.transaction.StandardTransactionBuilder in project janusgraph by JanusGraph.

the class VertexJobConverter method startTransaction.

public static StandardJanusGraphTx startTransaction(StandardJanusGraph graph) {
    StandardTransactionBuilder txb = graph.buildTransaction().readOnly();
    txb.setPreloadedData(true);
    txb.checkInternalVertexExistence(false);
    txb.dirtyVertexSize(0);
    txb.vertexCacheSize(0);
    return (StandardJanusGraphTx) txb.start();
}
Also used : StandardJanusGraphTx(org.janusgraph.graphdb.transaction.StandardJanusGraphTx) StandardTransactionBuilder(org.janusgraph.graphdb.transaction.StandardTransactionBuilder)

Example 2 with StandardTransactionBuilder

use of org.janusgraph.graphdb.transaction.StandardTransactionBuilder in project janusgraph by JanusGraph.

the class IndexUpdateJob method workerIterationStart.

public void workerIterationStart(JanusGraph graph, Configuration config, ScanMetrics metrics) {
    this.graph = (StandardJanusGraph) graph;
    Preconditions.checkArgument(config.has(GraphDatabaseConfiguration.JOB_START_TIME), "Invalid configuration for this job. Start time is required.");
    this.jobStartTime = Instant.ofEpochMilli(config.get(GraphDatabaseConfiguration.JOB_START_TIME));
    if (indexName == null) {
        Preconditions.checkArgument(config.has(INDEX_NAME), "Need to configure the name of the index to be repaired");
        indexName = config.get(INDEX_NAME);
        indexRelationTypeName = config.get(INDEX_RELATION_TYPE);
        log.info("Read index information: name={} type={}", indexName, indexRelationTypeName);
    }
    try {
        this.managementSystem = (ManagementSystem) graph.openManagement();
        if (isGlobalGraphIndex()) {
            index = managementSystem.getGraphIndex(indexName);
        } else {
            indexRelationType = managementSystem.getRelationType(indexRelationTypeName);
            Preconditions.checkArgument(indexRelationType != null, "Could not find relation type: %s", indexRelationTypeName);
            index = managementSystem.getRelationIndex(indexRelationType, indexName);
        }
        Preconditions.checkArgument(index != null, "Could not find index: %s [%s]", indexName, indexRelationTypeName);
        log.info("Found index {}", indexName);
        validateIndexStatus();
        StandardTransactionBuilder txb = this.graph.buildTransaction();
        txb.commitTime(jobStartTime);
        writeTx = (StandardJanusGraphTx) txb.start();
    } catch (final Exception e) {
        if (null != managementSystem && managementSystem.isOpen())
            managementSystem.rollback();
        if (writeTx != null && writeTx.isOpen())
            writeTx.rollback();
        metrics.incrementCustom(FAILED_TX);
        throw new JanusGraphException(e.getMessage(), e);
    }
}
Also used : JanusGraphException(org.janusgraph.core.JanusGraphException) JanusGraphException(org.janusgraph.core.JanusGraphException) StandardTransactionBuilder(org.janusgraph.graphdb.transaction.StandardTransactionBuilder)

Example 3 with StandardTransactionBuilder

use of org.janusgraph.graphdb.transaction.StandardTransactionBuilder in project janusgraph by JanusGraph.

the class GhostVertexRemover method workerIterationStart.

@Override
public void workerIterationStart(Configuration jobConfig, Configuration graphConfig, ScanMetrics metrics) {
    super.workerIterationStart(jobConfig, graphConfig, metrics);
    Preconditions.checkArgument(jobConfig.has(GraphDatabaseConfiguration.JOB_START_TIME), "Invalid configuration for this job. Start time is required.");
    this.jobStartTime = Instant.ofEpochMilli(jobConfig.get(GraphDatabaseConfiguration.JOB_START_TIME));
    assert tx != null && tx.isOpen();
    tx.rollback();
    StandardTransactionBuilder txb = graph.get().buildTransaction();
    txb.commitTime(jobStartTime);
    txb.checkExternalVertexExistence(false);
    txb.checkInternalVertexExistence(false);
    tx = (StandardJanusGraphTx) txb.start();
}
Also used : StandardTransactionBuilder(org.janusgraph.graphdb.transaction.StandardTransactionBuilder)

Aggregations

StandardTransactionBuilder (org.janusgraph.graphdb.transaction.StandardTransactionBuilder)3 JanusGraphException (org.janusgraph.core.JanusGraphException)1 StandardJanusGraphTx (org.janusgraph.graphdb.transaction.StandardJanusGraphTx)1