use of info.xiancloud.core.distribution.service_discovery.UnitInstance in project xian by happyyangyuan.
the class CachedGlobalHttpSessionCountMonitor method execute0.
@Override
public Object execute0() {
int totalSessionCount = 0;
try {
for (UnitInstance clientInfo : UnitRouter.singleton.allInstances(Unit.fullName("httpServer", "cachedLocalHttpSessionMonitor"))) {
int localSessionCount;
UnitRequest request = UnitRequest.create("httpServer", "cachedLocalHttpSessionMonitor");
request.getContext().setDestinationNodeId(clientInfo.getNodeId());
List<Integer> counts = SyncXian.call(request, 5 * 1000).dataToTypedList(Integer.class);
totalSessionCount = MathUtil.sum(counts);
}
} catch (UnitOfflineException | UnitUndefinedException e) {
LOG.error(e);
totalSessionCount = -1;
}
LOG.info("当前缓存的session总数量为:" + totalSessionCount);
return UnitResponse.success(totalSessionCount);
}
use of info.xiancloud.core.distribution.service_discovery.UnitInstance in project xian by happyyangyuan.
the class UnitUnregistrationBridge method execute.
@Override
public UnitResponse execute(UnitRequest msg) {
UnitProxy unitProxy = msg.get("unit", UnitProxy.class);
NodeStatus nodeStatus = msg.get("nodeStatus", NodeStatus.class);
UnitInstance unitInstance = UnitRegistrationBridge.unitInstance(unitProxy, nodeStatus);
try {
UnitDiscovery.singleton.unregister(unitInstance);
return UnitResponse.success();
} catch (Exception e) {
LOG.error(e);
return UnitResponse.failure(e, "unit un registration failure.");
}
}
Aggregations