Search in sources :

Example 1 with Env

use of com.ctrip.framework.apollo.core.enums.Env in project apollo by ctripcorp.

the class AppController method loadEnvClusterInfo.

@RequestMapping(value = "/apps/{appId}/envclusters", method = RequestMethod.GET)
public List<OpenEnvClusterDTO> loadEnvClusterInfo(@PathVariable String appId) {
    List<OpenEnvClusterDTO> envClusters = new LinkedList<>();
    List<Env> envs = portalSettings.getActiveEnvs();
    for (Env env : envs) {
        OpenEnvClusterDTO envCluster = new OpenEnvClusterDTO();
        envCluster.setEnv(env.name());
        List<ClusterDTO> clusterDTOs = clusterService.findClusters(env, appId);
        envCluster.setClusters(BeanUtils.toPropertySet("name", clusterDTOs));
        envClusters.add(envCluster);
    }
    return envClusters;
}
Also used : OpenEnvClusterDTO(com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO) OpenEnvClusterDTO(com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO) ClusterDTO(com.ctrip.framework.apollo.common.dto.ClusterDTO) Env(com.ctrip.framework.apollo.core.enums.Env) LinkedList(java.util.LinkedList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Env

use of com.ctrip.framework.apollo.core.enums.Env in project apollo by ctripcorp.

the class ConfigUtil method getApolloEnv.

/**
 * Get the current environment.
 *
 * @return the env
 * @throws ApolloConfigException if env is set
 */
public Env getApolloEnv() {
    Env env = EnvUtils.transformEnv(Foundation.server().getEnvType());
    if (env == null) {
        String path = isOSWindows() ? "C:\\opt\\settings\\server.properties" : "/opt/settings/server.properties";
        String message = String.format("env is not set, please make sure it is set in %s!", path);
        logger.error(message);
        throw new ApolloConfigException(message);
    }
    return env;
}
Also used : Env(com.ctrip.framework.apollo.core.enums.Env) ApolloConfigException(com.ctrip.framework.apollo.exceptions.ApolloConfigException)

Example 3 with Env

use of com.ctrip.framework.apollo.core.enums.Env in project apollo by ctripcorp.

the class DefaultMetaServerProviderTest method testWithSystemProperty.

@Test
public void testWithSystemProperty() throws Exception {
    String someMetaAddress = "someMetaAddress";
    Env someEnv = Env.DEV;
    System.setProperty(ConfigConsts.APOLLO_META_KEY, " " + someMetaAddress + " ");
    DefaultMetaServerProvider defaultMetaServerProvider = new DefaultMetaServerProvider();
    assertEquals(someMetaAddress, defaultMetaServerProvider.getMetaServerAddress(someEnv));
}
Also used : Env(com.ctrip.framework.apollo.core.enums.Env) Test(org.junit.Test)

Aggregations

Env (com.ctrip.framework.apollo.core.enums.Env)3 ClusterDTO (com.ctrip.framework.apollo.common.dto.ClusterDTO)1 ApolloConfigException (com.ctrip.framework.apollo.exceptions.ApolloConfigException)1 OpenEnvClusterDTO (com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO)1 LinkedList (java.util.LinkedList)1 Test (org.junit.Test)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1