Java Code Examples for com.netflix.client.config.IClientConfig#loadProperties()

The following examples show how to use com.netflix.client.config.IClientConfig#loadProperties() . 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: StaticLoadBalancer.java    From suro with Apache License 2.0 6 votes vote down vote up
/**
   * @param config contains the server list, comma separated with the format
   *               hostname:port
   */
  @Inject
  public StaticLoadBalancer(ClientConfig config) {
      List<Server> serverList = new ArrayList<Server>();
      for (String s : config.getLoadBalancerServer().split(",")) {
          String[] host_port = s.split(":");
          serverList.add(new Server(host_port[0], Integer.parseInt(host_port[1])));
      }
      if (serverList.isEmpty()) {
          throw new IllegalArgumentException("empty server list");
      }

      IClientConfig loadBalancerConfig = new DefaultClientConfigImpl();
      loadBalancerConfig.loadProperties("suroClient");
loadBalancerConfig.setProperty(CommonClientConfigKey.NFLoadBalancerPingClassName, "com.netflix.suro.connection.SuroPing");
      super.initWithNiwsConfig(loadBalancerConfig);
      addServers(serverList);
  }
 
Example 2
Source File: EurekaLoadBalancer.java    From suro with Apache License 2.0 6 votes vote down vote up
/**
 * @param config contains vipAddress
 */
@Inject
public EurekaLoadBalancer(ClientConfig config) {
    String[] vipAddress_port = config.getLoadBalancerServer().split(":");
    if (vipAddress_port.length != 2) {
        throw new IllegalArgumentException(String.format(
                "EurekaLoadBalancer server should be formatted vipAddress:port ('%s')", 
                config.getLoadBalancerServer()));
    }

    this.port = Integer.parseInt(vipAddress_port[1]);
    IClientConfig loadBalancerConfig = new DefaultClientConfigImpl();
    loadBalancerConfig.loadProperties("suroClient");
    loadBalancerConfig.setProperty(CommonClientConfigKey.DeploymentContextBasedVipAddresses, vipAddress_port[0]);
    loadBalancerConfig.setProperty(CommonClientConfigKey.NIWSServerListClassName, DiscoveryEnabledNIWSServerList.class.getName());
    super.initWithNiwsConfig(loadBalancerConfig);
}
 
Example 3
Source File: BasicNettyOrigin.java    From zuul with Apache License 2.0 5 votes vote down vote up
protected IClientConfig setupClientConfig(String name) {
    // Get the NIWS properties for this Origin.
    IClientConfig niwsClientConfig = DefaultClientConfigImpl.getClientConfigWithDefaultValues(name);
    niwsClientConfig.set(CommonClientConfigKey.ClientClassName, name);
    niwsClientConfig.loadProperties(name);
    return niwsClientConfig;
}
 
Example 4
Source File: NFHttpClientFactory.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public static NFHttpClient getNamedNFHttpClient(String name) {
IClientConfig config = ClientConfigFactory.DEFAULT.newConfig();
config.loadProperties(name);
      return getNamedNFHttpClient(name, config, true);
  }
 
Example 5
Source File: NFHttpClientFactory.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public static NFHttpClient getNamedNFHttpClient(String name, boolean registerMonitor) {
IClientConfig config = ClientConfigFactory.DEFAULT.newConfig();
config.loadProperties(name);
      return getNamedNFHttpClient(name, config, registerMonitor);
  }
 
Example 6
Source File: NFHttpClient.java    From ribbon with Apache License 2.0 4 votes vote down vote up
private static IClientConfig createDefaultConfig() {
	IClientConfig config = ClientConfigFactory.DEFAULT.newConfig();
	config.loadProperties("default");
	return config;
}
 
Example 7
Source File: RibbonTransportFactory.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public final HttpClient<ByteBuf, ByteBuf> newHttpClient(String name) {
    IClientConfig config = clientConfigFactory.newConfig();
    config.loadProperties(name);
    return newHttpClient(config);
}
 
Example 8
Source File: RibbonTransportFactory.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public final RxClient<ByteBuf, ByteBuf> newTcpClient(String name) {
    IClientConfig config = clientConfigFactory.newConfig();
    config.loadProperties(name);
    return newTcpClient(config);
}
 
Example 9
Source File: RibbonTransportFactory.java    From ribbon with Apache License 2.0 4 votes vote down vote up
public RxClient<DatagramPacket, DatagramPacket> newUdpClient(String name) {
    IClientConfig config = clientConfigFactory.newConfig();
    config.loadProperties(name);
    return newUdpClient(config);
}