Search in sources :

Example 6 with RheaKVStoreOptions

use of com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions in project sofa-jraft by sofastack.

the class BenchmarkServer method main.

public static void main(final String[] args) {
    if (args.length < 3) {
        LOG.error("[initialServerList], [configPath] are needed.");
    }
    final String initialServerList = args[1];
    final String configPath = args[2];
    final RheaKVStoreOptions opts = Yaml.readConfig(configPath);
    opts.setInitialServerList(initialServerList);
    final Node node = new Node(opts);
    node.start();
    // 
    ConsoleReporter.forRegistry(KVMetrics.metricRegistry()).build().start(30, TimeUnit.SECONDS);
    Runtime.getRuntime().addShutdownHook(new Thread(node::stop));
    LOG.info("BenchmarkServer start OK, options: {}", opts);
}
Also used : RheaKVStoreOptions(com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions) Node(com.alipay.sofa.jraft.example.rheakv.Node)

Example 7 with RheaKVStoreOptions

use of com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions in project sofa-jraft by sofastack.

the class Server2 method main.

public static void main(final String[] args) throws Exception {
    final PlacementDriverOptions pdOpts = PlacementDriverOptionsConfigured.newConfigured().withFake(// use a fake pd
    true).config();
    final StoreEngineOptions storeOpts = // 
    StoreEngineOptionsConfigured.newConfigured().withStorageType(StorageType.RocksDB).withRocksDBOptions(RocksDBOptionsConfigured.newConfigured().withDbPath(Configs.DB_PATH).config()).withRaftDataPath(Configs.RAFT_DATA_PATH).withServerAddress(new Endpoint("127.0.0.1", 8182)).config();
    final RheaKVStoreOptions opts = // 
    RheaKVStoreOptionsConfigured.newConfigured().withClusterName(// 
    Configs.CLUSTER_NAME).withUseParallelCompress(// 
    true).withInitialServerList(Configs.ALL_NODE_ADDRESSES).withStoreEngineOptions(// 
    storeOpts).withPlacementDriverOptions(// 
    pdOpts).config();
    System.out.println(opts);
    final Node node = new Node(opts);
    node.start();
    Runtime.getRuntime().addShutdownHook(new Thread(node::stop));
    System.out.println("server2 start OK");
}
Also used : RheaKVStoreOptions(com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions) PlacementDriverOptions(com.alipay.sofa.jraft.rhea.options.PlacementDriverOptions) Endpoint(com.alipay.sofa.jraft.util.Endpoint) StoreEngineOptions(com.alipay.sofa.jraft.rhea.options.StoreEngineOptions)

Example 8 with RheaKVStoreOptions

use of com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions in project sofa-jraft by sofastack.

the class Server3 method main.

public static void main(final String[] args) throws Exception {
    final PlacementDriverOptions pdOpts = PlacementDriverOptionsConfigured.newConfigured().withFake(// use a fake pd
    true).config();
    final StoreEngineOptions storeOpts = // 
    StoreEngineOptionsConfigured.newConfigured().withStorageType(StorageType.RocksDB).withRocksDBOptions(RocksDBOptionsConfigured.newConfigured().withDbPath(Configs.DB_PATH).config()).withRaftDataPath(Configs.RAFT_DATA_PATH).withServerAddress(new Endpoint("127.0.0.1", 8183)).config();
    final RheaKVStoreOptions opts = // 
    RheaKVStoreOptionsConfigured.newConfigured().withClusterName(// 
    Configs.CLUSTER_NAME).withUseParallelCompress(// 
    true).withInitialServerList(Configs.ALL_NODE_ADDRESSES).withStoreEngineOptions(// 
    storeOpts).withPlacementDriverOptions(// 
    pdOpts).config();
    System.out.println(opts);
    final Node node = new Node(opts);
    node.start();
    Runtime.getRuntime().addShutdownHook(new Thread(node::stop));
    System.out.println("server3 start OK");
}
Also used : RheaKVStoreOptions(com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions) PlacementDriverOptions(com.alipay.sofa.jraft.rhea.options.PlacementDriverOptions) Endpoint(com.alipay.sofa.jraft.util.Endpoint) StoreEngineOptions(com.alipay.sofa.jraft.rhea.options.StoreEngineOptions)

Example 9 with RheaKVStoreOptions

use of com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions in project sofa-jraft by sofastack.

the class ZipStrategyManagerTest method testInit.

@Test
public void testInit() {
    RheaKVStoreOptions opts = new RheaKVStoreOptions();
    opts.setUseParallelCompress(true);
    ZipStrategyManager.init(opts);
    ZipStrategy zipStrategy = ZipStrategyManager.getZipStrategy(ZipStrategyManager.PARALLEL_STRATEGY);
    assertNotNull(zipStrategy);
    assertTrue(zipStrategy instanceof ParallelZipStrategy);
}
Also used : RheaKVStoreOptions(com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions) Test(org.junit.Test)

Example 10 with RheaKVStoreOptions

use of com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions in project sofa-jraft by sofastack.

the class RheaKVTestCluster method start.

protected void start() throws IOException, InterruptedException {
    System.out.println("RheaKVTestCluster init ...");
    File file = new File("rhea_pd_db");
    if (file.exists()) {
        FileUtils.forceDelete(file);
    }
    file = new File("rhea_pd_db");
    if (file.mkdir()) {
        this.tempDbPath = file.getAbsolutePath();
        System.out.println("make dir: " + this.tempDbPath);
    }
    file = new File("rhea_pd_raft");
    if (file.exists()) {
        FileUtils.forceDelete(file);
    }
    file = new File("rhea_pd_raft");
    if (file.mkdir()) {
        this.tempRaftPath = file.getAbsolutePath();
        System.out.println("make dir: " + this.tempRaftPath);
    }
    final Set<Long> regionIds = new HashSet<>();
    for (final String c : CONF) {
        final ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
        final InputStream in = RheaKVTestCluster.class.getResourceAsStream(c);
        final RheaKVStoreOptions opts = mapper.readValue(in, RheaKVStoreOptions.class);
        for (final RegionEngineOptions rOpts : opts.getStoreEngineOptions().getRegionEngineOptionsList()) {
            regionIds.add(rOpts.getRegionId());
        }
        final RheaKVStore rheaKVStore = new DefaultRheaKVStore();
        if (rheaKVStore.init(opts)) {
            stores.add(rheaKVStore);
        } else {
            System.err.println("Fail to init rhea kv store witch conf: " + c);
        }
    }
    final PlacementDriverClient pdClient = stores.get(0).getPlacementDriverClient();
    for (final Long regionId : regionIds) {
        final Endpoint leader = pdClient.getLeader(regionId, true, 10000);
        System.out.println("The region " + regionId + " leader is: " + leader);
    }
}
Also used : DefaultRheaKVStore(com.alipay.sofa.jraft.rhea.client.DefaultRheaKVStore) RheaKVStore(com.alipay.sofa.jraft.rhea.client.RheaKVStore) InputStream(java.io.InputStream) PlacementDriverClient(com.alipay.sofa.jraft.rhea.client.pd.PlacementDriverClient) RegionEngineOptions(com.alipay.sofa.jraft.rhea.options.RegionEngineOptions) DefaultRheaKVStore(com.alipay.sofa.jraft.rhea.client.DefaultRheaKVStore) RheaKVStoreOptions(com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions) Endpoint(com.alipay.sofa.jraft.util.Endpoint) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) File(java.io.File) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet)

Aggregations

RheaKVStoreOptions (com.alipay.sofa.jraft.rhea.options.RheaKVStoreOptions)15 DefaultRheaKVStore (com.alipay.sofa.jraft.rhea.client.DefaultRheaKVStore)7 RheaKVStore (com.alipay.sofa.jraft.rhea.client.RheaKVStore)6 PlacementDriverOptions (com.alipay.sofa.jraft.rhea.options.PlacementDriverOptions)6 Endpoint (com.alipay.sofa.jraft.util.Endpoint)6 StoreEngineOptions (com.alipay.sofa.jraft.rhea.options.StoreEngineOptions)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)4 PlacementDriverClient (com.alipay.sofa.jraft.rhea.client.pd.PlacementDriverClient)3 File (java.io.File)3 Configuration (com.alipay.sofa.jraft.conf.Configuration)2 BatchingOptions (com.alipay.sofa.jraft.rhea.options.BatchingOptions)2 RegionRouteTableOptions (com.alipay.sofa.jraft.rhea.options.RegionRouteTableOptions)2 InputStream (java.io.InputStream)2 Test (org.junit.Test)2 PeerId (com.alipay.sofa.jraft.entity.PeerId)1 Node (com.alipay.sofa.jraft.example.rheakv.Node)1 RegionEngineOptions (com.alipay.sofa.jraft.rhea.options.RegionEngineOptions)1 IOException (java.io.IOException)1 Date (java.util.Date)1