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);
}
}
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();
}
}
}
}
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();
}
}
}
}
}
Aggregations