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