use of com.alibaba.nacos.config.server.model.SampleResult in project nacos by alibaba.
the class ConfigController method getListeners.
/**
* Subscribe to configured client information.
*/
@GetMapping("/listener")
@Secured(action = ActionTypes.READ, signType = SignType.CONFIG)
public GroupkeyListenserStatus getListeners(@RequestParam("dataId") String dataId, @RequestParam("group") String group, @RequestParam(value = "tenant", required = false) String tenant, @RequestParam(value = "sampleTime", required = false, defaultValue = "1") int sampleTime) throws Exception {
group = StringUtils.isBlank(group) ? Constants.DEFAULT_GROUP : group;
SampleResult collectSampleResult = configSubService.getCollectSampleResult(dataId, group, tenant, sampleTime);
GroupkeyListenserStatus gls = new GroupkeyListenserStatus();
gls.setCollectStatus(200);
if (collectSampleResult.getLisentersGroupkeyStatus() != null) {
gls.setLisentersGroupkeyStatus(collectSampleResult.getLisentersGroupkeyStatus());
}
return gls;
}
use of com.alibaba.nacos.config.server.model.SampleResult in project nacos by alibaba.
the class ListenerController method getAllSubClientConfigByIp.
/**
* Get subscribe information from client side.
*/
@GetMapping
public GroupkeyListenserStatus getAllSubClientConfigByIp(@RequestParam("ip") String ip, @RequestParam(value = "all", required = false) boolean all, @RequestParam(value = "tenant", required = false) String tenant, @RequestParam(value = "sampleTime", required = false, defaultValue = "1") int sampleTime, ModelMap modelMap) {
SampleResult collectSampleResult = configSubService.getCollectSampleResultByIp(ip, sampleTime);
GroupkeyListenserStatus gls = new GroupkeyListenserStatus();
gls.setCollectStatus(200);
Map<String, String> configMd5Status = new HashMap<>(100);
if (collectSampleResult.getLisentersGroupkeyStatus() == null) {
return gls;
}
Map<String, String> status = collectSampleResult.getLisentersGroupkeyStatus();
for (Map.Entry<String, String> config : status.entrySet()) {
if (!StringUtils.isBlank(tenant) && config.getKey().contains(tenant)) {
configMd5Status.put(config.getKey(), config.getValue());
continue;
}
// Get common config default value, if want to get all config, you need to add "all".
if (all) {
configMd5Status.put(config.getKey(), config.getValue());
} else {
String[] configKeys = GroupKey2.parseKey(config.getKey());
if (StringUtils.isBlank(configKeys[2])) {
configMd5Status.put(config.getKey(), config.getValue());
}
}
}
gls.setLisentersGroupkeyStatus(configMd5Status);
return gls;
}
Aggregations