use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class PropertyIndexService method checkConflict.
public ConflictStatus checkConflict(PropertyIndex entity, int connId) {
HugeClient client = this.client(connId);
String name = entity.getName();
IndexLabel newIndexLabel = convert(entity, client);
IndexLabel oldIndexLabel = convert(this.get(name, connId), client);
if (oldIndexLabel == null) {
return ConflictStatus.PASSED;
} else if (isEqual(newIndexLabel, oldIndexLabel)) {
return ConflictStatus.EXISTED;
} else {
return ConflictStatus.DUPNAME;
}
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class PropertyIndexService method list.
public List<PropertyIndex> list(Collection<String> names, int connId, boolean emptyAsAll) {
HugeClient client = this.client(connId);
List<IndexLabel> indexLabels;
if (CollectionUtils.isEmpty(names)) {
if (emptyAsAll) {
indexLabels = client.schema().getIndexLabels();
} else {
indexLabels = new ArrayList<>();
}
} else {
indexLabels = client.schema().getIndexLabels(new ArrayList<>(names));
}
List<PropertyIndex> results = new ArrayList<>(indexLabels.size());
indexLabels.forEach(indexLabel -> {
results.add(convert(indexLabel));
});
return results;
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class HugeClientPoolService method getOrCreate.
public synchronized HugeClient getOrCreate(Integer id) {
HugeClient client = super.get(id);
if (client != null) {
return client;
}
GraphConnection connection = this.connService.get(id);
if (connection == null) {
throw new ExternalException("graph-connection.get.failed", id);
}
if (connection.getTimeout() == null) {
int timeout = this.config.get(HubbleOptions.CLIENT_REQUEST_TIMEOUT);
connection.setTimeout(timeout);
}
this.sslService.configSSL(this.config, connection);
client = HugeClientUtil.tryConnect(connection);
this.put(id, client);
return client;
}
use of com.baidu.hugegraph.driver.HugeClient in project incubator-hugegraph-toolchain by apache.
the class LicenseService method updateGraphStatus.
private void updateGraphStatus(GraphConnection conn) {
HugeClient client;
try {
client = this.poolService.getOrCreate(conn.getId());
} catch (Exception e) {
String msg = this.getMessage("graph-connection.client.unavailable", conn.getName());
conn.setEnabled(false);
conn.setDisableReason(msg);
this.connService.update(conn);
return;
}
conn.setEnabled(true);
conn.setDisableReason("");
this.connService.update(conn);
}
use of com.baidu.hugegraph.driver.HugeClient in project hugegraph-computer by hugegraph.
the class RingsDetectionWithFilterTest method setup.
@BeforeClass
public static void setup() {
clearAll();
HugeClient client = client();
SchemaManager schema = client.schema();
schema.propertyKey("weight").asInt().ifNotExist().create();
schema.vertexLabel("user").properties("weight").useCustomizeStringId().ifNotExist().create();
schema.edgeLabel("know").sourceLabel("user").targetLabel("user").properties("weight").ifNotExist().create();
GraphManager graph = client.graph();
Vertex vA = graph.addVertex(T.label, "user", T.id, "A", "weight", 1);
Vertex vB = graph.addVertex(T.label, "user", T.id, "B", "weight", 1);
Vertex vC = graph.addVertex(T.label, "user", T.id, "C", "weight", 1);
Vertex vD = graph.addVertex(T.label, "user", T.id, "D", "weight", 1);
Vertex vE = graph.addVertex(T.label, "user", T.id, "E", "weight", 3);
vA.addEdge("know", vB, "weight", 1);
vA.addEdge("know", vC, "weight", 1);
vA.addEdge("know", vD, "weight", 1);
vB.addEdge("know", vA, "weight", 2);
vB.addEdge("know", vC, "weight", 1);
vB.addEdge("know", vE, "weight", 1);
vC.addEdge("know", vA, "weight", 1);
vC.addEdge("know", vB, "weight", 1);
vC.addEdge("know", vD, "weight", 1);
vD.addEdge("know", vC, "weight", 1);
vD.addEdge("know", vE, "weight", 1);
vE.addEdge("know", vC, "weight", 1);
RingsDetectionTestOutput.EXPECT_RINGS = EXPECT_RINGS;
}
Aggregations