use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.
the class RegisterUtil method registerBackends.
public static void registerBackends() {
String confFile = "/backend.properties";
URL input = RegisterUtil.class.getResource(confFile);
E.checkState(input != null, "Can't read file '%s' as stream", confFile);
PropertiesConfiguration props = null;
try {
props = new Configurations().properties(input);
} catch (ConfigurationException e) {
throw new HugeException("Can't load config file: %s", e, confFile);
}
HugeConfig config = new HugeConfig(props);
List<String> backends = config.get(DistOptions.BACKENDS);
for (String backend : backends) {
registerBackend(backend);
}
}
use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.
the class ExampleUtil method waitAllTaskDone.
public static void waitAllTaskDone(HugeGraph graph) {
TaskScheduler scheduler = graph.taskScheduler();
Iterator<HugeTask<Object>> tasks = scheduler.tasks(null, -1L, null);
while (tasks.hasNext()) {
try {
scheduler.waitUntilTaskCompleted(tasks.next().id(), 20L);
} catch (TimeoutException e) {
throw new HugeException("Failed to wait task done", e);
}
}
}
use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.
the class Reflection method registerFieldsToFilter.
public static void registerFieldsToFilter(Class<?> containingClass, String... fieldNames) {
if (REGISTER_FILEDS_TO_FILTER_METHOD == null) {
throw new NotSupportException("Reflection.registerFieldsToFilter()");
}
try {
REGISTER_FILEDS_TO_FILTER_METHOD.setAccessible(true);
REGISTER_FILEDS_TO_FILTER_METHOD.invoke(REFLECTION_CLAZZ, containingClass, fieldNames);
} catch (IllegalAccessException | InvocationTargetException e) {
throw new HugeException("Failed to register class '%s' fields to filter: %s", containingClass, Arrays.toString(fieldNames));
}
}
use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.
the class SecurityManagerTest method runGremlinJob.
private static String runGremlinJob(String gremlin) {
JobBuilder<Object> builder = JobBuilder.of(graph);
Map<String, Object> input = new HashMap<>();
input.put("gremlin", gremlin);
input.put("bindings", ImmutableMap.of());
input.put("language", "gremlin-groovy");
input.put("aliases", ImmutableMap.of());
builder.name("test-gremlin-job").input(JsonUtil.toJson(input)).job(new GremlinJob());
HugeTask<?> task = builder.schedule();
try {
task = graph.taskScheduler().waitUntilTaskCompleted(task.id(), 10);
} catch (TimeoutException e) {
throw new HugeException("Wait for task timeout: %s", e, task);
}
return task.result();
}
use of com.baidu.hugegraph.HugeException in project incubator-hugegraph by apache.
the class GraphTransaction method removeEdges.
public void removeEdges(EdgeLabel edgeLabel) {
if (this.hasUpdate()) {
throw new HugeException("There are still changes to commit");
}
boolean autoCommit = this.autoCommit();
this.autoCommit(false);
// Commit data already in tx firstly
this.commit();
try {
if (this.store().features().supportsDeleteEdgeByLabel()) {
// TODO: Need to change to writeQuery!
this.doRemove(this.serializer.writeId(HugeType.EDGE_OUT, edgeLabel.id()));
this.doRemove(this.serializer.writeId(HugeType.EDGE_IN, edgeLabel.id()));
} else {
this.traverseEdgesByLabel(edgeLabel, edge -> {
this.removeEdge((HugeEdge) edge);
this.commitIfGtSize(COMMIT_BATCH);
}, true);
}
this.commit();
} catch (Exception e) {
LOG.error("Failed to remove edges", e);
throw new HugeException("Failed to remove edges", e);
} finally {
this.autoCommit(autoCommit);
}
}
Aggregations