Search in sources :

Example 1 with DashboardLeaderTreeCache

use of com.vip.saturn.job.console.service.helper.DashboardLeaderTreeCache 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);
            DashboardLeaderTreeCache oldDashboardLeaderTreeCache = dashboardLeaderTreeCacheMap.remove(zkClusterKey);
            if (oldDashboardLeaderTreeCache != null) {
                oldDashboardLeaderTreeCache.shutdown();
            }
        }
    }
}
Also used : DashboardLeaderTreeCache(com.vip.saturn.job.console.service.helper.DashboardLeaderTreeCache)

Example 2 with DashboardLeaderTreeCache

use of com.vip.saturn.job.console.service.helper.DashboardLeaderTreeCache in project Saturn by vipshop.

the class RegistryCenterServiceImpl method closeZkCluster.

/**
 * Close dashboardLeaderTreeCache, registryCenterClient, namespaceShardingListenerManager with this zkCluster
 */
private void closeZkCluster(ZkCluster zkCluster) {
    try {
        try {
            DashboardLeaderTreeCache dashboardLeaderTreeCache = dashboardLeaderTreeCacheMap.remove(zkCluster.getZkClusterKey());
            if (dashboardLeaderTreeCache != null) {
                dashboardLeaderTreeCache.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.getCuratorFramework() != null) {
            zkCluster.getCuratorFramework().close();
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : RegistryCenterConfiguration(com.vip.saturn.job.console.domain.RegistryCenterConfiguration) DashboardLeaderTreeCache(com.vip.saturn.job.console.service.helper.DashboardLeaderTreeCache) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) IOException(java.io.IOException)

Example 3 with DashboardLeaderTreeCache

use of com.vip.saturn.job.console.service.helper.DashboardLeaderTreeCache 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)) {
            DashboardLeaderTreeCache dashboardLeaderTreeCache = null;
            try {
                dashboardLeaderTreeCache = new DashboardLeaderTreeCache(zkCluster.getZkAlias(), zkCluster.getCuratorFramework());
                dashboardLeaderTreeCache.start();
                dashboardLeaderTreeCacheMap.put(zkClusterKey, dashboardLeaderTreeCache);
            } catch (Exception e) {
                log.error(e.getMessage(), e);
                if (dashboardLeaderTreeCache != null) {
                    dashboardLeaderTreeCache.shutdown();
                }
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster) DashboardLeaderTreeCache(com.vip.saturn.job.console.service.helper.DashboardLeaderTreeCache) SaturnJobConsoleException(com.vip.saturn.job.console.exception.SaturnJobConsoleException) IOException(java.io.IOException)

Aggregations

DashboardLeaderTreeCache (com.vip.saturn.job.console.service.helper.DashboardLeaderTreeCache)3 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)2 IOException (java.io.IOException)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