use of com.alipay.sofa.jraft.rhea.options.BatchingOptions in project sofa-jraft by sofastack.
the class ChaosTestCluster method addPeer.
public synchronized void addPeer(final PeerId peerId) {
if (this.peerIds.contains(peerId)) {
throw new RuntimeException("peerId is exist: " + peerId);
}
this.peerIds.add(peerId);
final Configuration conf = new Configuration(this.peerIds);
final String initialServerList = conf.toString();
final PlacementDriverOptions pdOpts = // use a fake pd
PlacementDriverOptionsConfigured.newConfigured().withFake(true).config();
final StoreEngineOptions storeOpts = //
StoreEngineOptionsConfigured.newConfigured().withStorageType(//
this.storageType).withRocksDBOptions(//
RocksDBOptionsConfigured.newConfigured().withDbPath(DB_PATH).config()).withRaftDataPath(//
RAFT_DATA_PATH).withServerAddress(//
peerId.getEndpoint()).config();
final RheaKVStoreOptions opts = //
RheaKVStoreOptionsConfigured.newConfigured().withClusterName(//
"chaos_test").withInitialServerList(initialServerList).withStoreEngineOptions(//
storeOpts).withPlacementDriverOptions(//
pdOpts).config();
BatchingOptions batchingOptions = opts.getBatchingOptions();
if (batchingOptions == null) {
batchingOptions = new BatchingOptions();
}
batchingOptions.setAllowBatching(this.allowBatching);
opts.setBatchingOptions(batchingOptions);
final RheaKVStore store = new DefaultRheaKVStore();
if (!store.init(opts)) {
throw new IllegalStateException("fail to init store with options: " + opts);
}
final RheaKVStore leader = getLeaderStore();
final PlacementDriverClient pdClient = leader.getPlacementDriverClient();
if (!pdClient.addReplica(Constants.DEFAULT_REGION_ID, JRaftHelper.toPeer(peerId), true)) {
throw new RuntimeException("fail to add peer: " + peerId);
}
this.stores.add(store);
awaitLeader();
}
use of com.alipay.sofa.jraft.rhea.options.BatchingOptions in project sofa-jraft by sofastack.
the class ChaosTestCluster method start.
public synchronized void start() {
deleteFiles();
final Configuration conf = new Configuration(this.peerIds);
final String initialServerList = conf.toString();
for (final PeerId p : conf.listPeers()) {
final PlacementDriverOptions pdOpts = // use a fake pd
PlacementDriverOptionsConfigured.newConfigured().withFake(true).config();
final StoreEngineOptions storeOpts = //
StoreEngineOptionsConfigured.newConfigured().withStorageType(//
this.storageType).withRocksDBOptions(//
RocksDBOptionsConfigured.newConfigured().withDbPath(DB_PATH).config()).withRaftDataPath(//
RAFT_DATA_PATH).withServerAddress(//
p.getEndpoint()).withLeastKeysOnSplit(//
10).config();
final RheaKVStoreOptions opts = //
RheaKVStoreOptionsConfigured.newConfigured().withClusterName(//
CLUSTER_NAME).withInitialServerList(initialServerList).withOnlyLeaderRead(//
this.onlyLeaderRead).withStoreEngineOptions(//
storeOpts).withPlacementDriverOptions(//
pdOpts).withFailoverRetries(//
30).withFutureTimeoutMillis(//
TimeUnit.SECONDS.toMillis(60)).config();
BatchingOptions batchingOptions = opts.getBatchingOptions();
if (batchingOptions == null) {
batchingOptions = new BatchingOptions();
}
batchingOptions.setAllowBatching(this.allowBatching);
opts.setBatchingOptions(batchingOptions);
final RheaKVStore store = new DefaultRheaKVStore();
if (!store.init(opts)) {
throw new IllegalStateException("fail to init store with options: " + opts);
}
this.stores.add(store);
}
awaitLeader();
}
Aggregations