Search in sources :

Example 6 with UnitOfflineException

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);
}
Also used : UnitOfflineException(info.xiancloud.core.distribution.exception.UnitOfflineException) UnitRequest(info.xiancloud.core.message.UnitRequest) UnitInstance(info.xiancloud.core.distribution.service_discovery.UnitInstance) UnitUndefinedException(info.xiancloud.core.distribution.exception.UnitUndefinedException)

Aggregations

UnitOfflineException (info.xiancloud.core.distribution.exception.UnitOfflineException)6 UnitInstance (info.xiancloud.core.distribution.service_discovery.UnitInstance)6 UnitUndefinedException (info.xiancloud.core.distribution.exception.UnitUndefinedException)3 UnitRequest (info.xiancloud.core.message.UnitRequest)2 ArrayList (java.util.ArrayList)2 NotifyHandler (info.xiancloud.core.NotifyHandler)1 UnitResponse (info.xiancloud.core.message.UnitResponse)1 RoutedLocalAsyncSender (info.xiancloud.core.message.sender.local.RoutedLocalAsyncSender)1 CountDownLatch (java.util.concurrent.CountDownLatch)1