Search in sources :

Example 16 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class DashboardController method domainProcessCount.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@GetMapping(value = "/domainProcessCount")
public SuccessResponseEntity domainProcessCount(@RequestParam(required = false) String zkClusterKey) throws SaturnJobConsoleException {
    if (StringUtils.isNotBlank(zkClusterKey)) {
        ZkCluster zkCluster = checkAndGetZkCluster(zkClusterKey);
        SaturnStatistics ss = dashboardService.allProcessAndErrorCountOfTheDay(zkCluster.getZkAddr());
        return ss == null ? new SuccessResponseEntity() : new SuccessResponseEntity(ss.getResult());
    }
    return new SuccessResponseEntity(dashboardService.allProcessAndErrorCountOfTheDayByAllZkCluster());
}
Also used : SaturnStatistics(com.vip.saturn.job.console.mybatis.entity.SaturnStatistics) SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster) ApiResponses(io.swagger.annotations.ApiResponses)

Example 17 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class UtilsController method getZkClusterKeys.

@ApiResponses(value = { @ApiResponse(code = 200, message = "Success/Fail", response = RequestResult.class) })
@GetMapping(value = "/zkClusterKeys")
public SuccessResponseEntity getZkClusterKeys() {
    Collection<ZkCluster> zkClusters = registryCenterService.getZkClusterList();
    List<String> zkClusterKeys = Lists.newArrayList();
    for (ZkCluster zkCluster : zkClusters) {
        zkClusterKeys.add(zkCluster.getZkClusterKey());
    }
    return new SuccessResponseEntity(zkClusterKeys);
}
Also used : SuccessResponseEntity(com.vip.saturn.job.console.controller.SuccessResponseEntity) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster) GetMapping(org.springframework.web.bind.annotation.GetMapping) ApiResponses(io.swagger.annotations.ApiResponses)

Example 18 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class AbstractController method getCurrentZkAddr.

/**
 * @deprecated session do not store zk cluster information
 */
@Deprecated
public String getCurrentZkAddr(final HttpSession session) {
    String zkClusterKey = (String) session.getAttribute(SessionAttributeKeys.CURRENT_ZK_CLUSTER_KEY);
    if (zkClusterKey != null) {
        ZkCluster zkCluster = registryCenterService.getZkCluster(zkClusterKey);
        if (zkCluster != null) {
            return zkCluster.getZkAddr();
        }
    }
    // if zkClusterKey doesn't exist in map, use the first online one in map.
    Collection<ZkCluster> zks = registryCenterService.getZkClusterList();
    for (ZkCluster tmp : zks) {
        ZkCluster zkCluster = tmp;
        if (!zkCluster.isOffline()) {
            setCurrentZkClusterKey(zkCluster.getZkClusterKey(), session);
            return zkCluster.getZkClusterKey();
        }
    }
    return null;
}
Also used : ZkCluster(com.vip.saturn.job.console.domain.ZkCluster)

Example 19 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class RegistryCenterServiceImpl method closeInvalidZkClient.

private void closeInvalidZkClient(Map<String, ZkCluster> newClusterMap) {
    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 (!newClusterMap.containsKey(zkClusterKey)) {
            iterator.remove();
            closeZkCluster(zkCluster);
        } else {
            ZkCluster newZkCluster = newClusterMap.get(zkClusterKey);
            if (zkCluster.equals(newZkCluster)) {
                newClusterMap.put(zkClusterKey, zkCluster);
            } else if (zkCluster.equalsNoNeedReconnect(newZkCluster)) {
                zkCluster.setDescription(newZkCluster.getDescription());
                newClusterMap.put(zkClusterKey, zkCluster);
            } else {
                iterator.remove();
                closeZkCluster(zkCluster);
            }
        }
    }
}
Also used : Entry(java.util.Map.Entry) ZkCluster(com.vip.saturn.job.console.domain.ZkCluster)

Example 20 with ZkCluster

use of com.vip.saturn.job.console.domain.ZkCluster in project Saturn by vipshop.

the class RegistryCenterServiceImpl method getZkClusterKeys.

private List<String> getZkClusterKeys() {
    Collection<ZkCluster> zkClusters = getZkClusterList();
    List<String> zkClusterKeys = Lists.newArrayList();
    for (ZkCluster zkCluster : zkClusters) {
        zkClusterKeys.add(zkCluster.getZkClusterKey());
    }
    return zkClusterKeys;
}
Also used : ZkCluster(com.vip.saturn.job.console.domain.ZkCluster)

Aggregations

ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)37 SuccessResponseEntity (com.vip.saturn.job.console.controller.SuccessResponseEntity)11 ApiResponses (io.swagger.annotations.ApiResponses)11 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)9 SaturnStatistics (com.vip.saturn.job.console.mybatis.entity.SaturnStatistics)8 Entry (java.util.Map.Entry)8 RegistryCenterConfiguration (com.vip.saturn.job.console.domain.RegistryCenterConfiguration)7 HashMap (java.util.HashMap)5 Transactional (org.springframework.transaction.annotation.Transactional)5 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)4 ArrayList (java.util.ArrayList)4 CuratorRepository (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)3 CurrentJobConfig (com.vip.saturn.job.console.mybatis.entity.CurrentJobConfig)2 NamespaceInfo (com.vip.saturn.job.console.mybatis.entity.NamespaceInfo)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Audit (com.vip.saturn.job.console.aop.annotation.Audit)1 ExportJobConfigPageStatus (com.vip.saturn.job.console.domain.ExportJobConfigPageStatus)1 JobSettings (com.vip.saturn.job.console.domain.JobSettings)1 TreeNode (com.vip.saturn.job.console.domain.TreeNode)1