Search in sources :

Example 46 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class AbstractTransaction method commitOrRollback.

@Watched(prefix = "tx")
public void commitOrRollback() {
    LOG.debug("Transaction commitOrRollback()");
    this.checkOwnerThread();
    /*
         * The mutation will be reset after commit, in order to log the
         * mutation after failure, let's save it to a local variable.
         */
    BackendMutation mutation = this.mutation();
    try {
        // Do commit
        this.commit();
    } catch (Throwable e1) {
        LOG.error("Failed to commit changes:", e1);
        // Do rollback
        try {
            this.rollback();
        } catch (Throwable e2) {
            LOG.error("Failed to rollback changes:\n {}", mutation, e2);
        }
        /*
             * Rethrow the commit exception
             * The e.getMessage maybe too long to see key information,
             */
        throw new BackendException("Failed to commit changes: %s(%s)", StringUtils.abbreviateMiddle(e1.getMessage(), ".", 256), HugeException.rootCause(e1));
    }
}
Also used : BackendMutation(com.baidu.hugegraph.backend.store.BackendMutation) BackendException(com.baidu.hugegraph.backend.BackendException) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 47 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class AbstractTransaction method queryNumber.

@Watched(prefix = "tx")
public Number queryNumber(Query query) {
    LOG.debug("Transaction queryNumber: {}", query);
    E.checkArgument(query.aggregate() != null, "The aggregate must be set for number query: %s", query);
    Query squery = this.serializer.writeQuery(query);
    this.beforeRead();
    try {
        return this.store.queryNumber(squery);
    } finally {
        this.afterRead();
    }
}
Also used : Query(com.baidu.hugegraph.backend.query.Query) IdQuery(com.baidu.hugegraph.backend.query.IdQuery) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 48 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class RamTable method matched.

@Watched
public boolean matched(Query query) {
    if (this.edgesSize() == 0L || this.loading) {
        return false;
    }
    if (!query.resultType().isEdge() || !(query instanceof ConditionQuery)) {
        return false;
    }
    ConditionQuery cq = (ConditionQuery) query;
    int conditionsSize = cq.conditionsSize();
    Object owner = cq.condition(HugeKeys.OWNER_VERTEX);
    Directions direction = cq.condition(HugeKeys.DIRECTION);
    Id label = cq.condition(HugeKeys.LABEL);
    if (direction == null && conditionsSize > 1) {
        for (Condition cond : cq.conditions()) {
            if (cond.equals(BOTH_COND)) {
                direction = Directions.BOTH;
                break;
            }
        }
    }
    int matchedConds = 0;
    if (owner != null) {
        matchedConds++;
    } else {
        return false;
    }
    if (direction != null) {
        matchedConds++;
    }
    if (label != null) {
        matchedConds++;
    }
    return matchedConds == cq.conditionsSize();
}
Also used : Condition(com.baidu.hugegraph.backend.query.Condition) ConditionQuery(com.baidu.hugegraph.backend.query.ConditionQuery) Directions(com.baidu.hugegraph.type.define.Directions) Id(com.baidu.hugegraph.backend.id.Id) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 49 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class SchemaTransaction method rebuildIndex.

@Watched(prefix = "schema")
public Id rebuildIndex(SchemaElement schema, Set<Id> dependencies) {
    LOG.debug("SchemaTransaction rebuild index for {} with id '{}'", schema.type(), schema.id());
    SchemaJob callable = new IndexLabelRebuildJob();
    return asyncRun(this.graph(), schema, callable, dependencies);
}
Also used : IndexLabelRebuildJob(com.baidu.hugegraph.job.schema.IndexLabelRebuildJob) SchemaJob(com.baidu.hugegraph.job.schema.SchemaJob) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Example 50 with Watched

use of com.baidu.hugegraph.perf.PerfUtil.Watched in project incubator-hugegraph by apache.

the class SchemaTransaction method removeIndexLabel.

@Watched(prefix = "schema")
public Id removeIndexLabel(Id id) {
    LOG.debug("SchemaTransaction remove index label '{}'", id);
    SchemaJob callable = new IndexLabelRemoveJob();
    IndexLabel schema = this.getIndexLabel(id);
    return asyncRun(this.graph(), schema, callable);
}
Also used : IndexLabel(com.baidu.hugegraph.schema.IndexLabel) IndexLabelRemoveJob(com.baidu.hugegraph.job.schema.IndexLabelRemoveJob) SchemaJob(com.baidu.hugegraph.job.schema.SchemaJob) Watched(com.baidu.hugegraph.perf.PerfUtil.Watched)

Aggregations

Watched (com.baidu.hugegraph.perf.PerfUtil.Watched)65 Id (com.baidu.hugegraph.backend.id.Id)30 ConditionQuery (com.baidu.hugegraph.backend.query.ConditionQuery)9 EdgeId (com.baidu.hugegraph.backend.id.EdgeId)8 IndexLabel (com.baidu.hugegraph.schema.IndexLabel)8 SchemaManager (com.baidu.hugegraph.schema.SchemaManager)7 ArrayList (java.util.ArrayList)7 PropertyKey (com.baidu.hugegraph.schema.PropertyKey)6 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)6 BatchIdHolder (com.baidu.hugegraph.backend.page.IdHolder.BatchIdHolder)5 HugeIndex (com.baidu.hugegraph.structure.HugeIndex)5 IdHolder (com.baidu.hugegraph.backend.page.IdHolder)4 FixedIdHolder (com.baidu.hugegraph.backend.page.IdHolder.FixedIdHolder)4 PagingIdHolder (com.baidu.hugegraph.backend.page.IdHolder.PagingIdHolder)4 IdQuery (com.baidu.hugegraph.backend.query.IdQuery)4 Query (com.baidu.hugegraph.backend.query.Query)4 SchemaJob (com.baidu.hugegraph.job.schema.SchemaJob)4 SchemaLabel (com.baidu.hugegraph.schema.SchemaLabel)4 VertexLabel (com.baidu.hugegraph.schema.VertexLabel)4 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)4