pull/107/head
Oliver 3 years ago
parent 5d7c2990ce
commit ed5f7719d9

@ -650,38 +650,39 @@ public Instance getInstance(String namespaceId, String serviceName, String clust
@PutMapping("/beat") @PutMapping("/beat")
@Secured(action = ActionTypes.WRITE) @Secured(action = ActionTypes.WRITE)
public ObjectNode beat(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId, public ObjectNode beat(@RequestParam(defaultValue = Constants.DEFAULT_NAMESPACE_ID) String namespaceId,
@RequestParam String serviceName, @RequestParam(defaultValue = StringUtils.EMPTY) String ip, @RequestParam String serviceName,
@RequestParam(defaultValue = UtilsAndCommons.DEFAULT_CLUSTER_NAME) String clusterName, @RequestParam(defaultValue = StringUtils.EMPTY) String ip,
@RequestParam(defaultValue = "0") Integer port, @RequestParam(defaultValue = StringUtils.EMPTY) String beat) @RequestParam(defaultValue = UtilsAndCommons.DEFAULT_CLUSTER_NAME) String clusterName,
throws Exception { @RequestParam(defaultValue = "0") Integer port,
@RequestParam(defaultValue = StringUtils.EMPTY) String beat)throws Exception {
ObjectNode result = JacksonUtils.createEmptyJsonNode();
result.put(SwitchEntry.CLIENT_BEAT_INTERVAL, switchDomain.getClientBeatInterval()); ObjectNode result = JacksonUtils.createEmptyJsonNode();
RsInfo clientBeat = null; result.put(SwitchEntry.CLIENT_BEAT_INTERVAL, switchDomain.getClientBeatInterval());
if (StringUtils.isNotBlank(beat)) { RsInfo clientBeat = null;
clientBeat = JacksonUtils.toObj(beat, RsInfo.class); if (StringUtils.isNotBlank(beat)) {
} clientBeat = JacksonUtils.toObj(beat, RsInfo.class);
if (clientBeat != null) { }
if (StringUtils.isNotBlank(clientBeat.getCluster())) { if (clientBeat != null) {
clusterName = clientBeat.getCluster(); if (StringUtils.isNotBlank(clientBeat.getCluster())) {
} else { clusterName = clientBeat.getCluster();
// fix #2533 } else {
clientBeat.setCluster(clusterName); // fix #2533
} clientBeat.setCluster(clusterName);
ip = clientBeat.getIp(); }
port = clientBeat.getPort(); ip = clientBeat.getIp();
} port = clientBeat.getPort();
}
NamingUtils.checkServiceNameFormat(serviceName);
Loggers.SRV_LOG.debug("[CLIENT-BEAT] full arguments: beat: {}, serviceName: {}, namespaceId: {}", clientBeat, NamingUtils.checkServiceNameFormat(serviceName);
serviceName, namespaceId); Loggers.SRV_LOG.debug("[CLIENT-BEAT] full arguments: beat: {}, serviceName: {}, namespaceId: {}", clientBeat,
BeatInfoInstanceBuilder builder = BeatInfoInstanceBuilder.newBuilder(); serviceName, namespaceId);
int resultCode = instanceServiceV2 BeatInfoInstanceBuilder builder = BeatInfoInstanceBuilder.newBuilder();
.handleBeat(namespaceId, serviceName, ip, port, clusterName, clientBeat, builder); int resultCode = instanceServiceV2
result.put(CommonParams.CODE, resultCode); .handleBeat(namespaceId, serviceName, ip, port, clusterName, clientBeat, builder);
result.put(SwitchEntry.CLIENT_BEAT_INTERVAL, result.put(CommonParams.CODE, resultCode);
instanceServiceV2.getHeartBeatInterval(namespaceId, serviceName, ip, port, clusterName)); result.put(SwitchEntry.CLIENT_BEAT_INTERVAL,
result.put(SwitchEntry.LIGHT_BEAT_ENABLED, switchDomain.isLightBeatEnabled()); instanceServiceV2.getHeartBeatInterval(namespaceId, serviceName, ip, port, clusterName));
return result; result.put(SwitchEntry.LIGHT_BEAT_ENABLED, switchDomain.isLightBeatEnabled());
return result;
} }
``` ```

Loading…
Cancel
Save