Search in sources :

Example 46 with HugeConfig

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

the class StandardHugeGraph method cloneConfig.

@Override
public HugeConfig cloneConfig(String newGraph) {
    HugeConfig config = (HugeConfig) this.configuration().clone();
    this.storeProvider.onCloneConfig(config, newGraph);
    return config;
}
Also used : HugeConfig(com.baidu.hugegraph.config.HugeConfig)

Example 47 with HugeConfig

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

the class SnowflakeIdGenerator method init.

public static SnowflakeIdGenerator init(HugeGraphParams graph) {
    String graphName = graph.name();
    SnowflakeIdGenerator generator = INSTANCES.get(graphName);
    if (generator == null) {
        synchronized (INSTANCES) {
            if (!INSTANCES.containsKey(graphName)) {
                HugeConfig conf = graph.configuration();
                INSTANCES.put(graphName, new SnowflakeIdGenerator(conf));
            }
            generator = INSTANCES.get(graphName);
            assert generator != null;
        }
    }
    return generator;
}
Also used : HugeConfig(com.baidu.hugegraph.config.HugeConfig)

Example 48 with HugeConfig

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

the class BackendProviderFactory method open.

public static BackendStoreProvider open(HugeGraphParams params) {
    HugeConfig config = params.configuration();
    String backend = config.get(CoreOptions.BACKEND).toLowerCase();
    String graph = config.get(CoreOptions.STORE);
    boolean raftMode = config.get(CoreOptions.RAFT_MODE);
    BackendStoreProvider provider = newProvider(config);
    if (raftMode) {
        LOG.info("Opening backend store '{}' in raft mode for graph '{}'", backend, graph);
        provider = new RaftBackendStoreProvider(provider, params);
    }
    provider.open(graph);
    return provider;
}
Also used : RaftBackendStoreProvider(com.baidu.hugegraph.backend.store.raft.RaftBackendStoreProvider) RaftBackendStoreProvider(com.baidu.hugegraph.backend.store.raft.RaftBackendStoreProvider) HugeConfig(com.baidu.hugegraph.config.HugeConfig)

Example 49 with HugeConfig

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

the class ConfDumper method main.

public static void main(String[] args) throws ConfigurationException, IOException {
    E.checkArgument(args.length == 1, "ConfDumper need a config file.");
    String input = args[0];
    File output = new File(input + ".default");
    LOG.info("Input config: {}", input);
    LOG.info("Output config: {}", output.getPath());
    RegisterUtil.registerBackends();
    RegisterUtil.registerServer();
    HugeConfig config = new HugeConfig(input);
    for (String name : new TreeSet<>(OptionSpace.keys())) {
        TypedOption<?, ?> option = OptionSpace.get(name);
        writeOption(output, option, config.get(option));
    }
}
Also used : TreeSet(java.util.TreeSet) HugeConfig(com.baidu.hugegraph.config.HugeConfig) File(java.io.File)

Example 50 with HugeConfig

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

the class InitStore method initGraph.

private static void initGraph(String configPath) throws Exception {
    LOG.info("Init graph with config file: {}", configPath);
    HugeConfig config = new HugeConfig(configPath);
    // Forced set RAFT_MODE to false when initializing backend
    config.setProperty(CoreOptions.RAFT_MODE.name(), "false");
    HugeGraph graph = (HugeGraph) GraphFactory.open(config);
    BackendStoreSystemInfo sysInfo = graph.backendStoreSystemInfo();
    try {
        if (sysInfo.exists()) {
            LOG.info("Skip init-store due to the backend store of '{}' " + "had been initialized", graph.name());
            sysInfo.checkVersion();
        } else {
            initBackend(graph);
        }
    } finally {
        graph.close();
    }
}
Also used : HugeGraph(com.baidu.hugegraph.HugeGraph) BackendStoreSystemInfo(com.baidu.hugegraph.backend.store.BackendStoreSystemInfo) HugeConfig(com.baidu.hugegraph.config.HugeConfig)

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