use of io.dingodb.store.row.metadata.Store in project dingo by dingodb.
the class RowStoreMetaAdaptorImpl method cluster.
@Override
public Cluster cluster() {
List<Store> stores = scheduleMetaAdaptor.namespaceView().resourceViews().values().stream().filter(ExecutorView.class::isInstance).map(ExecutorView.class::cast).map(this::mapping).collect(Collectors.toList());
Cluster cluster = new Cluster(0, stores);
log.debug("Get cluster, cluster: {}", cluster);
return cluster;
}
use of io.dingodb.store.row.metadata.Store in project dingo by dingodb.
the class MetadataRpcClient method internalGetStoreInfo.
private void internalGetStoreInfo(final long clusterId, final Endpoint selfEndpoint, final CompletableFuture<Store> future, final int retriesLeft, final Errors lastCause) {
final RetryRunner retryRunner = retryCause -> internalGetStoreInfo(clusterId, selfEndpoint, future, retriesLeft - 1, retryCause);
final FailoverClosure<Store> closure = new FailoverClosureImpl<>(future, retriesLeft, retryRunner);
final GetStoreInfoRequest request = new GetStoreInfoRequest();
request.setClusterId(clusterId);
request.setEndpoint(selfEndpoint);
this.pdRpcService.callPdServerWithRpc(request, closure, lastCause);
}
use of io.dingodb.store.row.metadata.Store 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