Search in sources :

Example 6 with DynamicStringProperty

use of com.netflix.config.DynamicStringProperty in project zuul by Netflix.

the class StartServer method initNIWS.

private void initNIWS() throws ClientException {
    String stack = ConfigurationManager.getDeploymentContext().getDeploymentStack();
    if (stack != null && !stack.trim().isEmpty() && RibbonConfig.isAutodetectingBackendVips()) {
        RibbonConfig.setupDefaultRibbonConfig();
        ZuulApplicationInfo.setApplicationName(RibbonConfig.getApplicationName());
    } else {
        DynamicStringProperty DEFAULT_CLIENT = DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_NIWS_DEFAULTCLIENT, null);
        if (DEFAULT_CLIENT.get() != null) {
            ZuulApplicationInfo.setApplicationName(DEFAULT_CLIENT.get());
        } else {
            ZuulApplicationInfo.setApplicationName(stack);
        }
    }
    String clientPropertyList = DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_NIWS_CLIENTLIST, "").get();
    String[] aClientList = clientPropertyList.split("\\|");
    String namespace = DynamicPropertyFactory.getInstance().getStringProperty(ZUUL_RIBBON_NAMESPACE, "ribbon").get();
    for (String client : aClientList) {
        DefaultClientConfigImpl clientConfig = DefaultClientConfigImpl.getClientConfigWithDefaultValues(client, namespace);
        ClientFactory.registerClientFromProperties(client, clientConfig);
    }
}
Also used : DynamicStringProperty(com.netflix.config.DynamicStringProperty) DefaultClientConfigImpl(com.netflix.client.config.DefaultClientConfigImpl)

Example 7 with DynamicStringProperty

use of com.netflix.config.DynamicStringProperty in project java-chassis by ServiceComb.

the class ConsumerProviderManager method getReferenceConfig.

public ReferenceConfig getReferenceConfig(String microserviceName) {
    ReferenceConfig config = referenceConfigMap.get(microserviceName);
    if (config == null) {
        synchronized (this) {
            config = referenceConfigMap.get(microserviceName);
            if (config == null) {
                String key = "cse.references." + microserviceName;
                DynamicStringProperty versionRule = DynamicPropertyFactory.getInstance().getStringProperty(key + ".version-rule", Const.VERSION_RULE_LATEST);
                DynamicStringProperty transport = DynamicPropertyFactory.getInstance().getStringProperty(key + ".transport", Const.ANY_TRANSPORT);
                config = new ReferenceConfig(microserviceName, versionRule.getValue(), transport.getValue());
                referenceConfigMap.put(microserviceName, config);
            }
        }
    }
    return config;
}
Also used : DynamicStringProperty(com.netflix.config.DynamicStringProperty)

Example 8 with DynamicStringProperty

use of com.netflix.config.DynamicStringProperty in project archaius by Netflix.

the class ValidationTest method testValidation.

@Test
public void testValidation() {
    DynamicStringProperty prop = new DynamicStringProperty("abc", "default") {

        public void validate(String newValue) {
            throw new ValidationException("failed");
        }
    };
    try {
        ConfigurationManager.getConfigInstance().setProperty("abc", "new");
        fail("ValidationException expected");
    } catch (ValidationException e) {
        assertNotNull(e);
    }
    assertEquals("default", prop.get());
    assertNull(ConfigurationManager.getConfigInstance().getProperty("abc"));
    try {
        ConfigurationManager.getConfigInstance().addProperty("abc", "new");
        fail("ValidationException expected");
    } catch (ValidationException e) {
        assertNotNull(e);
    }
    assertEquals("default", prop.get());
    assertNull(ConfigurationManager.getConfigInstance().getProperty("abc"));
}
Also used : ValidationException(com.netflix.config.validation.ValidationException) DynamicStringProperty(com.netflix.config.DynamicStringProperty) Test(org.junit.Test)

Example 9 with DynamicStringProperty

use of com.netflix.config.DynamicStringProperty in project eureka by Netflix.

the class Archaius1Utils method initConfig.

public static DynamicPropertyFactory initConfig(String configName) {
    DynamicPropertyFactory configInstance = DynamicPropertyFactory.getInstance();
    DynamicStringProperty EUREKA_PROPS_FILE = configInstance.getStringProperty("eureka.client.props", configName);
    String env = ConfigurationManager.getConfigInstance().getString(EUREKA_ENVIRONMENT, "test");
    ConfigurationManager.getConfigInstance().setProperty(ARCHAIUS_DEPLOYMENT_ENVIRONMENT, env);
    String eurekaPropsFile = EUREKA_PROPS_FILE.get();
    try {
        ConfigurationManager.loadCascadedPropertiesFromResources(eurekaPropsFile);
    } catch (IOException e) {
        logger.warn("Cannot find the properties specified : {}. This may be okay if there are other environment " + "specific properties or the configuration is installed with a different mechanism.", eurekaPropsFile);
    }
    return configInstance;
}
Also used : DynamicStringProperty(com.netflix.config.DynamicStringProperty) DynamicPropertyFactory(com.netflix.config.DynamicPropertyFactory) IOException(java.io.IOException)

Example 10 with DynamicStringProperty

use of com.netflix.config.DynamicStringProperty in project java-chassis by ServiceComb.

the class ServiceRegistryConfig method getIpPort.

public ArrayList<IpPort> getIpPort() {
    DynamicStringProperty property = DynamicPropertyFactory.getInstance().getStringProperty("cse.service.registry.address", "https://127.0.0.1:30100");
    List<String> uriLsit = Arrays.asList(property.get().split(","));
    ArrayList<IpPort> ipPortList = new ArrayList<IpPort>();
    for (int i = 0; i < uriLsit.size(); i++) {
        try {
            URI uri = new URI(uriLsit.get(i));
            StringBuilder sb = new StringBuilder(uri.getHost());
            sb.append(':').append(uri.getPort() < 0 ? PROTOCOL_HTTP_PORT : uri.getPort());
            this.ssl = uri.getScheme().startsWith("https");
            ipPortList.add(NetUtils.parseIpPort(sb.toString()));
        } catch (Exception e) {
            LOGGER.error("cse.service.registry.address invalid : {}", uriLsit.get(i), e);
        }
    }
    return ipPortList;
}
Also used : DynamicStringProperty(com.netflix.config.DynamicStringProperty) ArrayList(java.util.ArrayList) IpPort(io.servicecomb.foundation.common.net.IpPort) URI(java.net.URI)

Aggregations

DynamicStringProperty (com.netflix.config.DynamicStringProperty)10 Test (org.junit.Test)3 DynamicConfiguration (com.netflix.config.DynamicConfiguration)2 FixedDelayPollingScheduler (com.netflix.config.FixedDelayPollingScheduler)2 DefaultClientConfigImpl (com.netflix.client.config.DefaultClientConfigImpl)1 DynamicPropertyFactory (com.netflix.config.DynamicPropertyFactory)1 JDBCConfigurationSource (com.netflix.config.sources.JDBCConfigurationSource)1 ValidationException (com.netflix.config.validation.ValidationException)1 IpPort (io.servicecomb.foundation.common.net.IpPort)1 File (java.io.File)1 IOException (java.io.IOException)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Nullable (javax.annotation.Nullable)1 DataSource (javax.sql.DataSource)1