当前位置: 首页>>代码示例>>Java>>正文


Java ClientFactory.instantiateInstanceWithClientConfig方法代码示例

本文整理汇总了Java中com.netflix.client.ClientFactory.instantiateInstanceWithClientConfig方法的典型用法代码示例。如果您正苦于以下问题:Java ClientFactory.instantiateInstanceWithClientConfig方法的具体用法?Java ClientFactory.instantiateInstanceWithClientConfig怎么用?Java ClientFactory.instantiateInstanceWithClientConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.netflix.client.ClientFactory的用法示例。


在下文中一共展示了ClientFactory.instantiateInstanceWithClientConfig方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFilterImpl

import com.netflix.client.ClientFactory; //导入方法依赖的package包/类
/**
 * Get a ServerListFilter instance. It uses {@link ClientFactory#instantiateInstanceWithClientConfig(String, IClientConfig)}
 * which in turn uses reflection to initialize the filter instance. 
 * The filter class name is determined by the value of {@link CommonClientConfigKey#NIWSServerListFilterClassName}
 * in the {@link IClientConfig}. The default implementation is {@link ZoneAffinityServerListFilter}.
 */
public AbstractServerListFilter<T> getFilterImpl(IClientConfig niwsClientConfig) throws ClientException{
    try {
        String niwsServerListFilterClassName = niwsClientConfig
                .getProperty(
                        CommonClientConfigKey.NIWSServerListFilterClassName,
                        ZoneAffinityServerListFilter.class.getName())
                .toString();

        AbstractServerListFilter<T> abstractNIWSServerListFilter = 
                (AbstractServerListFilter<T>) ClientFactory.instantiateInstanceWithClientConfig(niwsServerListFilterClassName, niwsClientConfig);
        return abstractNIWSServerListFilter;
    } catch (Throwable e) {
        throw new ClientException(
                ClientException.ErrorType.CONFIGURATION,
                "Unable to get an instance of CommonClientConfigKey.NIWSServerListFilterClassName. Configured class:"
                        + niwsClientConfig
                                .getProperty(CommonClientConfigKey.NIWSServerListFilterClassName), e);
    }
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:26,代码来源:AbstractServerList.java

示例2: initWithNiwsConfig

import com.netflix.client.ClientFactory; //导入方法依赖的package包/类
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
    String ruleClassName = (String) clientConfig
            .getProperty(CommonClientConfigKey.NFLoadBalancerRuleClassName);
    String pingClassName = (String) clientConfig
            .getProperty(CommonClientConfigKey.NFLoadBalancerPingClassName);

    IRule rule;
    IPing ping;
    try {
        rule = (IRule) ClientFactory.instantiateInstanceWithClientConfig(
                ruleClassName, clientConfig);
        ping = (IPing) ClientFactory.instantiateInstanceWithClientConfig(
                pingClassName, clientConfig);
    } catch (Exception e) {
        throw new RuntimeException("Error initializing load balancer", e);
    }
    initWithConfig(clientConfig, rule, ping);
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:20,代码来源:BaseLoadBalancer.java

示例3: cloneRule

import com.netflix.client.ClientFactory; //导入方法依赖的package包/类
private IRule cloneRule(IRule toClone) {
 	IRule rule;
 	if (toClone == null) {
 		rule = new AvailabilityFilteringRule();
 	} else {
 		String ruleClass = toClone.getClass().getName();        		
 		try {
	rule = (IRule) ClientFactory.instantiateInstanceWithClientConfig(ruleClass, this.getClientConfig());
} catch (Exception e) {
	throw new RuntimeException("Unexpected exception creating rule for ZoneAwareLoadBalancer", e);
}
 	}
 	return rule;
 }
 
开发者ID:Netflix,项目名称:ribbon,代码行数:15,代码来源:ZoneAwareLoadBalancer.java

示例4: initWithNiwsConfig

import com.netflix.client.ClientFactory; //导入方法依赖的package包/类
@Override
public void initWithNiwsConfig(IClientConfig clientConfig) {
    try {
        super.initWithNiwsConfig(clientConfig);
        String niwsServerListClassName = clientConfig.getPropertyAsString(
                CommonClientConfigKey.NIWSServerListClassName,
                DefaultClientConfigImpl.DEFAULT_SEVER_LIST_CLASS);

        ServerList<T> niwsServerListImpl = (ServerList<T>) ClientFactory
                .instantiateInstanceWithClientConfig(niwsServerListClassName, clientConfig);
        this.serverListImpl = niwsServerListImpl;

        if (niwsServerListImpl instanceof AbstractServerList) {
            AbstractServerListFilter<T> niwsFilter = ((AbstractServerList) niwsServerListImpl)
                    .getFilterImpl(clientConfig);
            niwsFilter.setLoadBalancerStats(getLoadBalancerStats());
            this.filter = niwsFilter;
        }

        String serverListUpdaterClassName = clientConfig.getPropertyAsString(
                CommonClientConfigKey.ServerListUpdaterClassName,
                DefaultClientConfigImpl.DEFAULT_SERVER_LIST_UPDATER_CLASS
        );

        this.serverListUpdater = (ServerListUpdater) ClientFactory
                .instantiateInstanceWithClientConfig(serverListUpdaterClassName, clientConfig);

        restOfInit(clientConfig);
    } catch (Exception e) {
        throw new RuntimeException(
                "Exception while initializing NIWSDiscoveryLoadBalancer:"
                        + clientConfig.getClientName()
                        + ", niwsClientConfig:" + clientConfig, e);
    }
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:36,代码来源:DynamicServerListLoadBalancer.java

示例5: createRuleFromConfig

import com.netflix.client.ClientFactory; //导入方法依赖的package包/类
private static IRule createRuleFromConfig(IClientConfig config) {
    String ruleClassName = config.get(IClientConfigKey.Keys.NFLoadBalancerRuleClassName);
    if (ruleClassName == null) {
        throw new IllegalArgumentException("NFLoadBalancerRuleClassName is not specified in the config");
    }
    IRule rule;
    try {
        rule = (IRule) ClientFactory.instantiateInstanceWithClientConfig(ruleClassName, config);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return rule;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:14,代码来源:LoadBalancerBuilder.java

示例6: createServerListUpdaterFromConfig

import com.netflix.client.ClientFactory; //导入方法依赖的package包/类
private static ServerListUpdater createServerListUpdaterFromConfig(IClientConfig config) {
    String serverListUpdaterClassName = config.get(IClientConfigKey.Keys.ServerListUpdaterClassName);
    if (serverListUpdaterClassName == null) {
        throw new IllegalArgumentException("NIWSServerListClassName is not specified in the config");
    }
    ServerListUpdater updater;
    try {
        updater = (ServerListUpdater) ClientFactory.instantiateInstanceWithClientConfig(serverListUpdaterClassName, config);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return updater;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:14,代码来源:LoadBalancerBuilder.java

示例7: createServerListFromConfig

import com.netflix.client.ClientFactory; //导入方法依赖的package包/类
private static ServerList<Server> createServerListFromConfig(IClientConfig config) {
    String serverListClassName = config.get(IClientConfigKey.Keys.NIWSServerListClassName);
    if (serverListClassName == null) {
        throw new IllegalArgumentException("NIWSServerListClassName is not specified in the config");
    }
    ServerList<Server> list;
    try {
        list = (ServerList<Server>) ClientFactory.instantiateInstanceWithClientConfig(serverListClassName, config);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return list;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:14,代码来源:LoadBalancerBuilder.java

示例8: buildLoadBalancerFromConfigWithReflection

import com.netflix.client.ClientFactory; //导入方法依赖的package包/类
/**
 * Build a load balancer using the configuration from the {@link IClientConfig} only. It uses reflection to initialize necessary load balancer
 * components. 
 */
public ILoadBalancer buildLoadBalancerFromConfigWithReflection() {
    String loadBalancerClassName = config.get(CommonClientConfigKey.NFLoadBalancerClassName);
    if (loadBalancerClassName == null) {
        throw new IllegalArgumentException("NFLoadBalancerClassName is not specified in the IClientConfig");
    }
    ILoadBalancer lb;
    try {
        lb = (ILoadBalancer) ClientFactory.instantiateInstanceWithClientConfig(loadBalancerClassName, config);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return lb;
}
 
开发者ID:Netflix,项目名称:ribbon,代码行数:18,代码来源:LoadBalancerBuilder.java


注:本文中的com.netflix.client.ClientFactory.instantiateInstanceWithClientConfig方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。