Search in sources :

Example 1 with StandardTransactionBuilder

use of com.thinkaurelius.titan.graphdb.transaction.StandardTransactionBuilder in project titan by thinkaurelius.

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 = (StandardTitanTx) txb.start();
}
Also used : StandardTransactionBuilder(com.thinkaurelius.titan.graphdb.transaction.StandardTransactionBuilder)

Example 2 with StandardTransactionBuilder

use of com.thinkaurelius.titan.graphdb.transaction.StandardTransactionBuilder in project titan by thinkaurelius.

the class VertexJobConverter method startTransaction.

public static StandardTitanTx startTransaction(StandardTitanGraph graph) {
    StandardTransactionBuilder txb = graph.buildTransaction().readOnly();
    txb.setPreloadedData(true);
    txb.checkInternalVertexExistence(false);
    txb.dirtyVertexSize(0);
    txb.vertexCacheSize(0);
    return (StandardTitanTx) txb.start();
}
Also used : StandardTitanTx(com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx) StandardTransactionBuilder(com.thinkaurelius.titan.graphdb.transaction.StandardTransactionBuilder)

Example 3 with StandardTransactionBuilder

use of com.thinkaurelius.titan.graphdb.transaction.StandardTransactionBuilder in project titan by thinkaurelius.

the class IndexUpdateJob method workerIterationStart.

public void workerIterationStart(TitanGraph graph, Configuration config, ScanMetrics metrics) {
    this.graph = (StandardTitanGraph) 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.mgmt = (ManagementSystem) graph.openManagement();
        if (isGlobalGraphIndex()) {
            index = mgmt.getGraphIndex(indexName);
        } else {
            indexRelationType = mgmt.getRelationType(indexRelationTypeName);
            Preconditions.checkArgument(indexRelationType != null, "Could not find relation type: %s", indexRelationTypeName);
            index = mgmt.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 = (StandardTitanTx) txb.start();
    } catch (final Exception e) {
        if (null != mgmt && mgmt.isOpen())
            mgmt.rollback();
        if (writeTx != null && writeTx.isOpen())
            writeTx.rollback();
        metrics.incrementCustom(FAILED_TX);
        throw new TitanException(e.getMessage(), e);
    }
}
Also used : TitanException(com.thinkaurelius.titan.core.TitanException) TitanException(com.thinkaurelius.titan.core.TitanException) StandardTransactionBuilder(com.thinkaurelius.titan.graphdb.transaction.StandardTransactionBuilder)

Aggregations

StandardTransactionBuilder (com.thinkaurelius.titan.graphdb.transaction.StandardTransactionBuilder)3 TitanException (com.thinkaurelius.titan.core.TitanException)1 StandardTitanTx (com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx)1