use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class CassandraTest method testParseReplicaWithSimpleStrategyAndEmptyReplica.
@Test
public void testParseReplicaWithSimpleStrategyAndEmptyReplica() {
String strategy = CassandraOptions.CASSANDRA_STRATEGY.name();
String replica = CassandraOptions.CASSANDRA_REPLICATION.name();
Configuration conf = new PropertiesConfiguration();
conf.setProperty(strategy, "SimpleStrategy");
conf.setProperty(replica, ImmutableList.of(""));
HugeConfig config = new HugeConfig(conf);
Assert.assertThrows(RuntimeException.class, () -> {
Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config);
});
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class SerializerFactory method serializer.
public static AbstractSerializer serializer(HugeConfig config, String name) {
name = name.toLowerCase();
switch(name) {
case "binary":
return new BinarySerializer(config);
case "binaryscatter":
return new BinaryScatterSerializer(config);
case "text":
return new TextSerializer(config);
default:
}
Class<? extends AbstractSerializer> clazz = serializers.get(name);
if (clazz == null) {
throw new BackendException("Not exists serializer: '%s'", name);
}
assert AbstractSerializer.class.isAssignableFrom(clazz);
try {
return clazz.getConstructor(HugeConfig.class).newInstance(config);
} catch (Exception e) {
throw new BackendException(e);
}
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class RaftSharedContext method nodeOptions.
public NodeOptions nodeOptions() throws IOException {
HugeConfig config = this.config();
PeerId selfId = new PeerId();
selfId.parse(config.get(CoreOptions.RAFT_ENDPOINT));
NodeOptions nodeOptions = new NodeOptions();
nodeOptions.setEnableMetrics(false);
nodeOptions.setRpcProcessorThreadPoolSize(config.get(CoreOptions.RAFT_RPC_THREADS));
nodeOptions.setRpcConnectTimeoutMs(config.get(CoreOptions.RAFT_RPC_CONNECT_TIMEOUT));
nodeOptions.setRpcDefaultTimeout(config.get(CoreOptions.RAFT_RPC_TIMEOUT));
int electionTimeout = config.get(CoreOptions.RAFT_ELECTION_TIMEOUT);
nodeOptions.setElectionTimeoutMs(electionTimeout);
nodeOptions.setDisableCli(false);
int snapshotInterval = config.get(CoreOptions.RAFT_SNAPSHOT_INTERVAL);
nodeOptions.setSnapshotIntervalSecs(snapshotInterval);
Configuration groupPeers = new Configuration();
String groupPeersStr = config.get(CoreOptions.RAFT_GROUP_PEERS);
if (!groupPeers.parse(groupPeersStr)) {
throw new HugeException("Failed to parse group peers %s", groupPeersStr);
}
nodeOptions.setInitialConf(groupPeers);
String raftPath = config.get(CoreOptions.RAFT_PATH);
String logUri = Paths.get(raftPath, "log").toString();
FileUtils.forceMkdir(new File(logUri));
nodeOptions.setLogUri(logUri);
String metaUri = Paths.get(raftPath, "meta").toString();
FileUtils.forceMkdir(new File(metaUri));
nodeOptions.setRaftMetaUri(metaUri);
if (config.get(CoreOptions.RAFT_USE_SNAPSHOT)) {
String snapshotUri = Paths.get(raftPath, "snapshot").toString();
FileUtils.forceMkdir(new File(snapshotUri));
nodeOptions.setSnapshotUri(snapshotUri);
}
RaftOptions raftOptions = nodeOptions.getRaftOptions();
/*
* NOTE: if buffer size is too small(<=1024), will throw exception
* "LogManager is busy, disk queue overload"
*/
raftOptions.setApplyBatch(config.get(CoreOptions.RAFT_APPLY_BATCH));
raftOptions.setDisruptorBufferSize(config.get(CoreOptions.RAFT_QUEUE_SIZE));
raftOptions.setDisruptorPublishEventWaitTimeoutSecs(config.get(CoreOptions.RAFT_QUEUE_PUBLISH_TIMEOUT));
raftOptions.setReplicatorPipeline(config.get(CoreOptions.RAFT_REPLICATOR_PIPELINE));
raftOptions.setOpenStatistics(false);
raftOptions.setReadOnlyOptions(ReadOnlyOption.valueOf(config.get(CoreOptions.RAFT_READ_STRATEGY)));
return nodeOptions;
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class GremlinQueryAPI method client.
public GremlinClient client() {
if (this.client != null) {
return this.client;
}
HugeConfig config = this.configProvider.get();
String url = config.get(ServerOptions.GREMLIN_SERVER_URL);
int timeout = config.get(ServerOptions.GREMLIN_SERVER_TIMEOUT) * 1000;
int maxRoutes = config.get(ServerOptions.GREMLIN_SERVER_MAX_ROUTE);
this.client = new GremlinClient(url, timeout, maxRoutes, maxRoutes);
return this.client;
}
use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.
the class GraphsAPI method getConf.
@GET
@Timed
@Path("{name}/conf")
@Produces(APPLICATION_JSON_WITH_CHARSET)
@RolesAllowed("admin")
public File getConf(@Context GraphManager manager, @PathParam("name") String name) {
LOG.debug("Get graph configuration by name '{}'", name);
HugeGraph g = graph4admin(manager, name);
HugeConfig config = (HugeConfig) g.configuration();
File file = config.file();
if (file == null) {
throw new NotSupportedException("Can't access the api in " + "a node which started with non local file config.");
}
return file;
}
Aggregations