Search in sources :

Example 51 with HugeConfig

use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.

the class InitStore method main.

public static void main(String[] args) throws Exception {
    E.checkArgument(args.length == 1, "HugeGraph init-store need to pass the config file " + "of RestServer, like: conf/rest-server.properties");
    E.checkArgument(args[0].endsWith(".properties"), "Expect the parameter is properties config file.");
    String restConf = args[0];
    RegisterUtil.registerBackends();
    RegisterUtil.registerPlugins();
    RegisterUtil.registerServer();
    HugeConfig restServerConfig = new HugeConfig(restConf);
    String graphsDir = restServerConfig.get(ServerOptions.GRAPHS);
    Map<String, String> graphs = ConfigUtil.scanGraphsDir(graphsDir);
    for (Map.Entry<String, String> entry : graphs.entrySet()) {
        initGraph(entry.getValue());
    }
    StandardAuthenticator.initAdminUserIfNeeded(restConf);
    HugeFactory.shutdown(30L);
}
Also used : HugeConfig(com.baidu.hugegraph.config.HugeConfig) MultiValueMap(org.apache.commons.collections.map.MultiValueMap) Map(java.util.Map)

Example 52 with HugeConfig

use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.

the class CassandraTest method testParseReplicaWithNetworkTopologyStrategyWithoutDatacenter.

@Test
public void testParseReplicaWithNetworkTopologyStrategyWithoutDatacenter() {
    String strategy = CassandraOptions.CASSANDRA_STRATEGY.name();
    String replica = CassandraOptions.CASSANDRA_REPLICATION.name();
    Configuration conf = new PropertiesConfiguration();
    conf.setProperty(strategy, "NetworkTopologyStrategy");
    conf.setProperty(replica, ImmutableList.of(":2", "dc2:1"));
    HugeConfig config = new HugeConfig(conf);
    Assert.assertThrows(RuntimeException.class, () -> {
        Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config);
    });
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) HugeConfig(com.baidu.hugegraph.config.HugeConfig) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) Test(org.junit.Test)

Example 53 with HugeConfig

use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.

the class CassandraTest method testParseReplicaWithNetworkTopologyStrategyAndStringReplica.

@Test
public void testParseReplicaWithNetworkTopologyStrategyAndStringReplica() {
    String strategy = CassandraOptions.CASSANDRA_STRATEGY.name();
    String replica = CassandraOptions.CASSANDRA_REPLICATION.name();
    Configuration conf = new PropertiesConfiguration();
    conf.setProperty(strategy, "NetworkTopologyStrategy");
    conf.setProperty(replica, ImmutableList.of("dc1:2", "dc2:string"));
    HugeConfig config = new HugeConfig(conf);
    Assert.assertThrows(RuntimeException.class, () -> {
        Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config);
    });
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) HugeConfig(com.baidu.hugegraph.config.HugeConfig) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) Test(org.junit.Test)

Example 54 with HugeConfig

use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.

the class CassandraTest method testParseReplicaWithSimpleStrategyAndStringReplica.

@Test
public void testParseReplicaWithSimpleStrategyAndStringReplica() {
    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("string"));
    HugeConfig config = new HugeConfig(conf);
    Assert.assertThrows(RuntimeException.class, () -> {
        Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config);
    });
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) HugeConfig(com.baidu.hugegraph.config.HugeConfig) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) Test(org.junit.Test)

Example 55 with HugeConfig

use of com.baidu.hugegraph.config.HugeConfig in project incubator-hugegraph by apache.

the class CassandraTest method testParseReplicaWithNetworkTopologyStrategyAndDoubleReplica.

@Test
public void testParseReplicaWithNetworkTopologyStrategyAndDoubleReplica() {
    String strategy = CassandraOptions.CASSANDRA_STRATEGY.name();
    String replica = CassandraOptions.CASSANDRA_REPLICATION.name();
    Configuration conf = new PropertiesConfiguration();
    conf.setProperty(strategy, "NetworkTopologyStrategy");
    conf.setProperty(replica, ImmutableList.of("dc1:3.5", "dc2:1"));
    HugeConfig config = new HugeConfig(conf);
    Assert.assertThrows(RuntimeException.class, () -> {
        Whitebox.invokeStatic(CassandraStore.class, "parseReplica", config);
    });
}
Also used : Configuration(org.apache.commons.configuration2.Configuration) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) HugeConfig(com.baidu.hugegraph.config.HugeConfig) PropertiesConfiguration(org.apache.commons.configuration2.PropertiesConfiguration) Test(org.junit.Test)

Aggregations

HugeConfig (com.baidu.hugegraph.config.HugeConfig)63 Test (org.junit.Test)33 PropertiesConfiguration (org.apache.commons.configuration2.PropertiesConfiguration)15 BaseUnitTest (com.baidu.hugegraph.unit.BaseUnitTest)12 Configuration (org.apache.commons.configuration2.Configuration)11 RpcClientProvider (com.baidu.hugegraph.rpc.RpcClientProvider)7 RpcServer (com.baidu.hugegraph.rpc.RpcServer)7 HugeGraph (com.baidu.hugegraph.HugeGraph)5 File (java.io.File)5 BackendEntry (com.baidu.hugegraph.backend.store.BackendEntry)4 HashMap (java.util.HashMap)4 RocksDBSessions (com.baidu.hugegraph.backend.store.rocksdb.RocksDBSessions)3 HugeEdge (com.baidu.hugegraph.structure.HugeEdge)3 HugeVertex (com.baidu.hugegraph.structure.HugeVertex)3 FakeObjects (com.baidu.hugegraph.unit.FakeObjects)3 MapConfiguration (org.apache.commons.configuration.MapConfiguration)3 HugeException (com.baidu.hugegraph.HugeException)2 BackendException (com.baidu.hugegraph.backend.BackendException)2 BinaryBackendEntry (com.baidu.hugegraph.backend.serializer.BinaryBackendEntry)2 BinaryScatterSerializer (com.baidu.hugegraph.backend.serializer.BinaryScatterSerializer)2