use of info.xiancloud.core.distribution.exception.UnitOfflineException 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);
}
Aggregations