Search in sources :

Example 21 with RegistryCenterConfiguration

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

the class InitRegistryCenterService method initTreeJson.

public static void initTreeJson(ArrayList<RegistryCenterConfiguration> registryCenterConfiguration, String zkBsk) {
    TreeNode treeData = new TreeNode();
    for (RegistryCenterConfiguration conf : registryCenterConfiguration) {
        String nameAndnameSpace = conf.getNameAndNamespace();
        if (nameAndnameSpace.startsWith("/")) {
            nameAndnameSpace = nameAndnameSpace.substring(1);
        }
        treeData = parseDirectory2Tree(nameAndnameSpace, treeData, conf.getNameAndNamespace(), conf.getDegree());
    }
    ZKBSKEY_TO_TREENODE_MAP.put(zkBsk, treeData);
    log.info("init {} tree data: {}", zkBsk, treeData);
}
Also used : RegistryCenterConfiguration(com.vip.saturn.job.console.domain.RegistryCenterConfiguration) TreeNode(com.vip.saturn.job.console.domain.TreeNode)

Example 22 with RegistryCenterConfiguration

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

the class AbstractController method getNamespace.

public String getNamespace() {
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
    RegistryCenterConfiguration configuration = (RegistryCenterConfiguration) request.getSession().getAttribute(SessionAttributeKeys.ACTIVATED_CONFIG_SESSION_KEY);
    if (configuration != null) {
        return configuration.getNamespace();
    }
    return null;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) RegistryCenterConfiguration(com.vip.saturn.job.console.domain.RegistryCenterConfiguration) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes)

Example 23 with RegistryCenterConfiguration

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

the class JobConfigController method load.

@RequestMapping(value = "jobconfig/getExportRegList", method = RequestMethod.GET)
@ResponseBody
public RequestResult load(HttpServletRequest request) {
    RequestResult requestResult = new RequestResult();
    try {
        List<RegistryCenterConfiguration> regCenterConfList = jobConfigInitializationService.getRegistryCenterConfigurations();
        requestResult.setSuccess(true);
        requestResult.setObj(regCenterConfList);
    } catch (Throwable t) {
        LOGGER.error(t.getMessage(), t);
        requestResult.setSuccess(false);
        requestResult.setMessage(t.toString());
    }
    return requestResult;
}
Also used : RequestResult(com.vip.saturn.job.console.domain.RequestResult) RegistryCenterConfiguration(com.vip.saturn.job.console.domain.RegistryCenterConfiguration) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 24 with RegistryCenterConfiguration

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

the class CuratorSessionClientInterceptor method preHandle.

@Override
public boolean preHandle(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws Exception {
    String nns = request.getParameter(AbstractController.REQUEST_NAMESPACE_PARAM);
    if (!Strings.isNullOrEmpty(nns)) {
        RegistryCenterClient client = registryCenterService.connect(nns);
        ThreadLocalCuratorClient.setCuratorClient(client.getCuratorClient());
        RegistryCenterConfiguration conf = registryCenterService.findConfig(client.getNameAndNamespace());
        if (conf == null) {
            response.sendRedirect(request.getContextPath() + "/registry_center_page");
            return false;
        }
        request.getSession().setAttribute(SessionAttributeKeys.ACTIVATED_CONFIG_SESSION_KEY, conf);
        request.getSession().setAttribute(SessionAttributeKeys.CURRENT_ZK_CLUSTER_KEY, conf.getZkClusterKey());
        return true;
    }
    RegistryCenterConfiguration reg = (RegistryCenterConfiguration) request.getSession().getAttribute(SessionAttributeKeys.ACTIVATED_CONFIG_SESSION_KEY);
    if (reg == null) {
        response.sendRedirect(request.getContextPath() + "/registry_center_page");
        return false;
    }
    RegistryCenterClient client = registryCenterService.getCuratorByNameAndNamespace(reg.getNameAndNamespace());
    if (null == client || !client.isConnected()) {
        response.sendRedirect(request.getContextPath() + "/registry_center_page");
        return false;
    }
    ThreadLocalCuratorClient.setCuratorClient(client.getCuratorClient());
    return true;
}
Also used : RegistryCenterConfiguration(com.vip.saturn.job.console.domain.RegistryCenterConfiguration) RegistryCenterClient(com.vip.saturn.job.console.domain.RegistryCenterClient)

Example 25 with RegistryCenterConfiguration

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

the class RestApiServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    when(registryCenterService.findConfigByNamespace(anyString())).thenReturn(new RegistryCenterConfiguration());
    RegistryCenterClient registryCenterClient = new RegistryCenterClient();
    registryCenterClient.setCuratorClient(curatorFramework);
    registryCenterClient.setConnected(true);
    when(registryCenterService.connectByNamespace(anyString())).thenReturn(registryCenterClient);
    when(curatorRepository.newCuratorFrameworkOp(any(CuratorFramework.class))).thenReturn(curatorFrameworkOp);
    when(curatorFrameworkOp.checkExists(JobNodePath.getJobNodePath(anyString()))).thenReturn(true);
}
Also used : RegistryCenterConfiguration(com.vip.saturn.job.console.domain.RegistryCenterConfiguration) CuratorFramework(org.apache.curator.framework.CuratorFramework) RegistryCenterClient(com.vip.saturn.job.console.domain.RegistryCenterClient) Before(org.junit.Before)

Aggregations

RegistryCenterConfiguration (com.vip.saturn.job.console.domain.RegistryCenterConfiguration)31 RegistryCenterClient (com.vip.saturn.job.console.domain.RegistryCenterClient)9 SaturnJobConsoleException (com.vip.saturn.job.console.exception.SaturnJobConsoleException)9 ZkCluster (com.vip.saturn.job.console.domain.ZkCluster)7 CuratorFramework (org.apache.curator.framework.CuratorFramework)7 SaturnJobConsoleHttpException (com.vip.saturn.job.console.exception.SaturnJobConsoleHttpException)4 NamespaceZkClusterMapping (com.vip.saturn.job.console.mybatis.entity.NamespaceZkClusterMapping)4 CuratorRepository (com.vip.saturn.job.console.repository.zookeeper.CuratorRepository)4 ArrayList (java.util.ArrayList)3 TreeNode (com.vip.saturn.job.console.domain.TreeNode)2 NamespaceInfo (com.vip.saturn.job.console.mybatis.entity.NamespaceInfo)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 JobSettings (com.vip.saturn.job.console.domain.JobSettings)1 RequestResult (com.vip.saturn.job.console.domain.RequestResult)1 CurrentJobConfig (com.vip.saturn.job.console.mybatis.entity.CurrentJobConfig)1 DashboardLeaderHandler (com.vip.saturn.job.console.service.cache.DashboardLeaderHandler)1 NamespaceShardingManager (com.vip.saturn.job.sharding.NamespaceShardingManager)1 File (java.io.File)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1