Java Code Examples for com.netflix.config.ConfigurationManager#loadPropertiesFromResources()

The following examples show how to use com.netflix.config.ConfigurationManager#loadPropertiesFromResources() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChassisHystrixTestConfiguration.java    From chassis with Apache License 2.0 6 votes vote down vote up
@Bean
static public PropertyPlaceholderConfigurer archaiusPropertyPlaceholderConfigurer() throws IOException, ConfigurationException {

    ConfigurationManager.loadPropertiesFromResources("chassis-test.properties");
    ConfigurationManager.loadPropertiesFromResources("chassis-default.properties");

    // force disable eureka
    ConfigurationManager.getConfigInstance().setProperty("chassis.eureka.disable", true);

    return new PropertyPlaceholderConfigurer() {
        @Override
        protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) {
            return DynamicPropertyFactory.getInstance().getStringProperty(placeholder, "null").get();
        }
    };
}
 
Example 2
Source File: ChassisConfigTestConfiguration.java    From chassis with Apache License 2.0 6 votes vote down vote up
@Bean
static public PropertyPlaceholderConfigurer archaiusPropertyPlaceholderConfigurer() throws IOException, ConfigurationException {
	
    ConfigurationManager.loadPropertiesFromResources("chassis-test.properties");
    ConfigurationManager.loadPropertiesFromResources("chassis-default.properties");
    
    // force disable eureka
    ConfigurationManager.getConfigInstance().setProperty("chassis.eureka.disable", true);
    
    return new PropertyPlaceholderConfigurer() {
        @Override
        protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) {
            return DynamicPropertyFactory.getInstance().getStringProperty(placeholder, "null").get();
        }
    };
}
 
Example 3
Source File: ChassisEurekaTestConfiguration.java    From chassis with Apache License 2.0 5 votes vote down vote up
@Bean
static public PropertyPlaceholderConfigurer archaiusPropertyPlaceholderConfigurer() throws IOException, ConfigurationException {
	
    ConfigurationManager.loadPropertiesFromResources("chassis-test.properties");
    ConfigurationManager.loadPropertiesFromResources("chassis-default.properties");
    
    return new PropertyPlaceholderConfigurer() {
        @Override
        protected String resolvePlaceholder(String placeholder, Properties props, int systemPropertiesMode) {
            return DynamicPropertyFactory.getInstance().getStringProperty(placeholder, "null").get();
        }
    };
}
 
Example 4
Source File: ResponseTimeWeightedRuleTest.java    From ribbon with Apache License 2.0 5 votes vote down vote up
@Test
public void testServerWeights(){
    try{
        ConfigurationManager.loadPropertiesFromResources("sample-client.properties"); 

        ConfigurationManager.getConfigInstance().setProperty(
                "sample-client.ribbon.NFLoadBalancerClassName", "com.netflix.loadbalancer.DynamicServerListLoadBalancer");
        ConfigurationManager.getConfigInstance().setProperty(
                "sample-client.ribbon.NFLoadBalancerRuleClassName", "com.netflix.loadbalancer.WeightedResponseTimeRule");
        // shorter weight adjusting interval
        ConfigurationManager.getConfigInstance().setProperty(
                "sample-client.ribbon." + WeightedResponseTimeRule.WEIGHT_TASK_TIMER_INTERVAL_CONFIG_KEY, "5000");
        ConfigurationManager.getConfigInstance().setProperty(
                "sample-client.ribbon.InitializeNFLoadBalancer", "true");       

        RestClient client = (RestClient) ClientFactory.getNamedClient("sample-client"); 

        HttpRequest request = HttpRequest.newBuilder().uri(new URI("/")).build(); 

        for (int i = 0; i < 20; i++) {
            client.executeWithLoadBalancer(request);
        }
        System.out.println(((AbstractLoadBalancer) client.getLoadBalancer()).getLoadBalancerStats());
        // wait for the weights to be adjusted
        Thread.sleep(5000);
        for (int i = 0; i < 50; i++) {
            client.executeWithLoadBalancer(request);
        }
        System.out.println(((AbstractLoadBalancer) client.getLoadBalancer()).getLoadBalancerStats());
    }
    catch (Exception e){
        e.printStackTrace();
    }
}