use of io.dingodb.store.row.options.RegionEngineOptions in project dingo by dingodb.
the class FakePlacementDriverClient method getStoreMetadata.
@Override
public Store getStoreMetadata(final StoreEngineOptions opts) {
final Store store = new Store();
final List<RegionEngineOptions> rOptsList = opts.getRegionEngineOptionsList();
final List<Region> regionList = Lists.newArrayListWithCapacity(rOptsList.size());
store.setId("-1");
store.setEndpoint(opts.getServerAddress());
for (final RegionEngineOptions rOpts : rOptsList) {
regionList.add(getLocalRegionMetadata(rOpts));
}
store.setRegions(regionList);
return store;
}
use of io.dingodb.store.row.options.RegionEngineOptions in project dingo by dingodb.
the class MultiRegionEngineOptionsConfigured method getOrCreateOptsById.
private RegionEngineOptions getOrCreateOptsById(final String regionId) {
Requires.requireNonNull(regionId, "regionId");
RegionEngineOptions opts = this.optsTable.get(regionId);
if (opts != null) {
return opts;
}
opts = new RegionEngineOptions();
opts.setRegionId(regionId);
this.optsTable.put(regionId, opts);
return opts;
}
use of io.dingodb.store.row.options.RegionEngineOptions in project dingo by dingodb.
the class RemotePlacementDriverClient method getStoreMetadata.
@Override
public Store getStoreMetadata(final StoreEngineOptions opts) {
final Endpoint selfEndpoint = opts.getServerAddress();
/**
* for debugger.
*/
for (RegionEngineOptions opt : opts.getRegionEngineOptionsList()) {
LOG.info("RegionEngineOptions-before: update from local conf. opt:{}", opt.toString());
}
// remote conf is the preferred
final Store remoteStore = this.metadataRpcClient.getStoreInfo(this.clusterId, selfEndpoint);
if (!remoteStore.isEmpty()) {
final List<Region> regions = remoteStore.getRegions();
Long metricsReportPeriodMs = opts.getMetricsReportPeriod();
if (opts.getRegionEngineOptionsList() != null && opts.getRegionEngineOptionsList().size() > 0) {
metricsReportPeriodMs = opts.getRegionEngineOptionsList().get(0).getMetricsReportPeriod();
}
opts.getRegionEngineOptionsList().clear();
for (final Region region : regions) {
super.regionRouteTable.addOrUpdateRegion(region);
RegionEngineOptions engineOptions = new RegionEngineOptions();
engineOptions.setRegionId(region.getId());
engineOptions.setStartKey(BytesUtil.readUtf8(region.getStartKey()));
engineOptions.setStartKeyBytes(region.getStartKey());
engineOptions.setEndKey(BytesUtil.readUtf8(region.getEndKey()));
engineOptions.setEndKeyBytes(region.getEndKey());
engineOptions.setNodeOptions(new NodeOptions());
engineOptions.setRaftGroupId(JRaftHelper.getJRaftGroupId(this.clusterName, region.getId()));
String raftDataPath = JRaftHelper.getRaftDataPath(opts.getRaftStoreOptions().getDataPath(), region.getId(), opts.getServerAddress().getPort());
engineOptions.setRaftDataPath(raftDataPath);
engineOptions.setServerAddress(opts.getServerAddress());
String initServerList = region.getPeers().stream().map(x -> x.getEndpoint().toString()).collect(Collectors.joining(","));
engineOptions.setInitialServerList(initServerList);
engineOptions.setMetricsReportPeriod(metricsReportPeriodMs);
opts.getRegionEngineOptionsList().add(engineOptions);
}
/**
* for debugger.
*/
for (RegionEngineOptions opt : opts.getRegionEngineOptionsList()) {
LOG.info("RegionEngineOptions-After: update from remote PD. opt:{}", opt.toString());
}
return remoteStore;
}
// local conf
final Store localStore = new Store();
final List<RegionEngineOptions> rOptsList = opts.getRegionEngineOptionsList();
final List<Region> regionList = Lists.newArrayListWithCapacity(rOptsList.size());
localStore.setId(remoteStore.getId());
localStore.setEndpoint(selfEndpoint);
for (final RegionEngineOptions rOpts : rOptsList) {
regionList.add(getLocalRegionMetadata(rOpts));
}
localStore.setRegions(regionList);
refreshStore(localStore);
return localStore;
}
Aggregations