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

The following examples show how to use com.netflix.client.config.IClientConfig#setProperty() . 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);
}