use of info.xiancloud.core.distribution.exception.ApplicationUndefinedException in project xian by happyyangyuan.
the class GetNodeInfoUnit method execute.
@Override
public UnitResponse execute(UnitRequest msg) {
if (StringUtil.isEmpty(msg.get("application"))) {
JSONArray nodeInfoArray = new JSONArray();
for (String application : ApplicationDiscovery.singleton.queryForNames()) {
JSONObject nodeInfo;
try {
nodeInfo = nodeInfo(ApplicationRouter.singleton.newestDefinition(application));
} catch (ApplicationUndefinedException e) {
LOG.info("忽略未定义的application:" + application);
continue;
}
nodeInfoArray.add(nodeInfo);
}
return UnitResponse.success(nodeInfoArray);
} else
try {
JSONArray nodeInfoArray = new JSONArray();
List<ApplicationInstance> clients = ApplicationRouter.singleton.allInstances(msg.get("application"));
for (ApplicationInstance instance : clients) {
nodeInfoArray.add(nodeInfo(instance.getPayload()));
}
return UnitResponse.success(nodeInfoArray);
} catch (ApplicationOfflineException | ApplicationUndefinedException e) {
return e.toUnitResponse();
}
}
Aggregations