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));
}
}
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();
}
}
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();
}
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);
}
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);
}
Aggregations