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);
}
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");
}
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");
}
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);
}
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);
}
}
Aggregations