Search in sources :

Example 1 with DashboardLeaderHandler

use of com.vip.saturn.job.console.service.cache.DashboardLeaderHandler in project Saturn by vipshop.

the class RegistryCenterServiceImpl method closeZkCluster.

/**
 * Close dashboardLeaderTreeCache, registryCenterClient, namespaceShardingListenerManager with this zkCluster
 */
private void closeZkCluster(ZkCluster zkCluster) {
    try {
        try {
            DashboardLeaderHandler dashboardLeaderHandler = dashboardLeaderTreeCacheMap.remove(zkCluster.getZkClusterKey());
            if (dashboardLeaderHandler != null) {
                dashboardLeaderHandler.shutdown();
            }
        } catch (Exception e) {
            log.error(e.getMessage(), e);
        }
        ArrayList<RegistryCenterConfiguration> regCenterConfList = zkCluster.getRegCenterConfList();
        if (regCenterConfList != null) {
            for (RegistryCenterConfiguration conf : regCenterConfList) {
                String nns = conf.getNameAndNamespace();
                synchronized (getNnsLock(nns)) {
                    closeNamespace(nns);
                }
            }
        }
        if (zkCluster.getConnectionListener() != null) {
            zkCluster.getConnectionListener().shutdownNowUntilTerminated();
            zkCluster.setConnectionListener(null);
        }
        if (zkCluster.getCuratorFrameworkOp() != null && zkCluster.getCuratorFrameworkOp().getCuratorFramework() != null) {
            zkCluster.getCuratorFrameworkOp().getCuratorFramework().close();
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : RegistryCenterConfiguration(com.vip.saturn.job.console.domain.RegistryCenterConfiguration) DashboardLeaderHandler(com.vip.saturn.job.console.service.cache.DashboardLeaderHandler) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)

Example 2 with DashboardLeaderHandler

use of com.vip.saturn.job.console.service.cache.DashboardLeaderHandler in project Saturn by vipshop.

the class RegistryCenterServiceImpl method closeDeprecatedDashboardLeaderTreeCache.

/**
 * 将不在本console服务器中进行Dashboard计算的DashboardLeaderTreeCache关闭
 */
private void closeDeprecatedDashboardLeaderTreeCache() {
    if (dashboardLeaderTreeCacheMap == null || dashboardLeaderTreeCacheMap.isEmpty()) {
        return;
    }
    for (String zkClusterKey : dashboardLeaderTreeCacheMap.keySet()) {
        if (!isZKClusterCanBeComputed(zkClusterKey) || !isCurrentConsoleInTheSameIdc(zkClusterKey)) {
            log.info("close the deprecated dashboard leader tree Cache, {}", zkClusterKey);
            DashboardLeaderHandler oldDashboardLeaderHandler = dashboardLeaderTreeCacheMap.remove(zkClusterKey);
            if (oldDashboardLeaderHandler != null) {
                oldDashboardLeaderHandler.shutdown();
            }
        }
    }
}
Also used : DashboardLeaderHandler(com.vip.saturn.job.console.service.cache.DashboardLeaderHandler)

Example 3 with DashboardLeaderHandler

use of com.vip.saturn.job.console.service.cache.DashboardLeaderHandler in project Saturn by vipshop.

the class RegistryCenterServiceImpl method refreshDashboardLeaderTreeCache.

private void refreshDashboardLeaderTreeCache() {
    closeDeprecatedDashboardLeaderTreeCache();
    Iterator<Entry<String, ZkCluster>> iterator = zkClusterMap.entrySet().iterator();
    while (iterator.hasNext()) {
        Entry<String, ZkCluster> next = iterator.next();
        String zkClusterKey = next.getKey();
        ZkCluster zkCluster = next.getValue();
        if (needToRefreshDashboardTreeCache(zkCluster, zkClusterKey)) {
            DashboardLeaderHandler dashboardLeaderHandler = null;
            try {
                dashboardLeaderHandler = new DashboardLeaderHandler(zkCluster.getZkAlias(), zkCluster.getCuratorFrameworkOp().getCuratorFramework());
                dashboardLeaderHandler.start();
                dashboardLeaderTreeCacheMap.put(zkClusterKey, dashboardLeaderHandler);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                if (dashboardLeaderHandler != null) {
                    dashboardLeaderHandler.shutdown();
                }
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster) DashboardLeaderHandler(com.vip.saturn.job.console.service.cache.DashboardLeaderHandler) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) SaturnJobConsoleHttpException(com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)

Aggregations

DashboardLeaderHandler (com.vip.saturn.job.console.service.cache.DashboardLeaderHandler)3 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)2 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)2 RegistryCenterConfiguration (com.vip.saturn.job.console.domain.RegistryCenterConfiguration)1 ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)1 Entry (java.util.Map.Entry)1