Java Code Examples for com.alipay.sofa.rpc.client.ProviderInfo#setHost()
The following examples show how to use
com.alipay.sofa.rpc.client.ProviderInfo#setHost() .
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: MulticastRegistryHelper.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * 转为服务端提供者对象 * * @param config 服务提供者配置 * @param server 服务端 * @return 本地服务提供者对象 */ public static ProviderInfo convertProviderToProviderInfo(ProviderConfig config, ServerConfig server) { ProviderInfo providerInfo = new ProviderInfo() .setPort(server.getPort()) .setWeight(config.getWeight()) .setSerializationType(config.getSerialization()) .setProtocolType(server.getProtocol()) .setPath(server.getContextPath()) .setStaticAttrs(config.getParameters()); String host = server.getHost(); if (NetUtils.isLocalHost(host) || NetUtils.isAnyHost(host)) { host = SystemInfo.getLocalHost(); } providerInfo.setHost(host); return providerInfo; }
Example 2
Source File: LocalRegistryHelper.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * 转为服务端提供者对象 * * @param config 服务提供者配置 * @param server 服务端 * @return 本地服务提供者对象 */ public static ProviderInfo convertProviderToProviderInfo(ProviderConfig config, ServerConfig server) { ProviderInfo providerInfo = new ProviderInfo() .setPort(server.getPort()) .setWeight(config.getWeight()) .setSerializationType(config.getSerialization()) .setProtocolType(server.getProtocol()) .setPath(server.getContextPath()) .setStaticAttrs(config.getParameters()); String host = server.getHost(); if (NetUtils.isLocalHost(host) || NetUtils.isAnyHost(host)) { host = SystemInfo.getLocalHost(); } providerInfo.setHost(host); return providerInfo; }
Example 3
Source File: MeshRegistryHelper.java From sofa-rpc with Apache License 2.0 | 6 votes |
/** * 转为服务端提供者对象 * * @param config 服务提供者配置 * @param server 服务端 * @return 本地服务提供者对象 */ public static ProviderInfo convertProviderToProviderInfo(ProviderConfig config, ServerConfig server) { ProviderInfo providerInfo = new ProviderInfo() .setPort(server.getPort()) .setWeight(config.getWeight()) .setSerializationType(config.getSerialization()) .setProtocolType(server.getProtocol()) .setPath(server.getContextPath()) .setStaticAttrs(config.getParameters()); String host = server.getHost(); if (NetUtils.isLocalHost(host) || NetUtils.isAnyHost(host)) { host = SystemInfo.getLocalHost(); } providerInfo.setHost(host); return providerInfo; }
Example 4
Source File: SofaRpcProviderInterceptorTest.java From skywalking with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { sofaRpcProviderInterceptor = new SofaRpcProviderInterceptor(); PowerMockito.mockStatic(RpcInternalContext.class); when(sofaRequest.getMethodName()).thenReturn("test"); when(sofaRequest.getMethodArgSigs()).thenReturn(new String[] {"String"}); when(sofaRequest.getMethodArgs()).thenReturn(new Object[] {"abc"}); when(sofaRequest.getInterfaceName()).thenReturn("org.apache.skywalking.apm.test.TestSofaRpcService"); PowerMockito.when(RpcInternalContext.getContext()).thenReturn(rpcContext); when(rpcContext.isConsumerSide()).thenReturn(false); final ProviderInfo providerInfo = new ProviderInfo(); providerInfo.setHost("127.0.0.1"); providerInfo.setPort(12200); when(rpcContext.getProviderInfo()).thenReturn(providerInfo); allArguments = new Object[] {sofaRequest}; argumentTypes = new Class[] {sofaRequest.getClass()}; Config.Agent.SERVICE_NAME = "SOFARPC-TestCases-APP"; }
Example 5
Source File: SofaRpcConsumerInterceptorTest.java From skywalking with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { sofaRpcConsumerInterceptor = new SofaRpcConsumerInterceptor(); PowerMockito.mockStatic(RpcInternalContext.class); when(sofaRequest.getMethodName()).thenReturn("test"); when(sofaRequest.getMethodArgSigs()).thenReturn(new String[] {"String"}); when(sofaRequest.getMethodArgs()).thenReturn(new Object[] {"abc"}); when(sofaRequest.getInterfaceName()).thenReturn("org.apache.skywalking.apm.test.TestSofaRpcService"); PowerMockito.when(RpcInternalContext.getContext()).thenReturn(rpcContext); when(rpcContext.isConsumerSide()).thenReturn(true); final ProviderInfo providerInfo = new ProviderInfo(); providerInfo.setHost("127.0.0.1"); providerInfo.setPort(12200); when(rpcContext.getProviderInfo()).thenReturn(providerInfo); allArguments = new Object[] {sofaRequest}; argumentTypes = new Class[] {sofaRequest.getClass()}; Config.Agent.SERVICE_NAME = "SOFARPC-TestCases-APP"; }
Example 6
Source File: BaseLoadBalancerTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
protected List<ProviderInfo> buildSameWeightProviderList(int size) { List<ProviderInfo> aliveConnections = new ArrayList<ProviderInfo>(); for (int i = 0; i < size; i++) { ProviderInfo provider = new ProviderInfo(); provider.setHost("127.0.0.2"); provider.setPort(9000 + i); aliveConnections.add(provider); } return aliveConnections; }
Example 7
Source File: BaseLoadBalancerTest.java From sofa-rpc with Apache License 2.0 | 5 votes |
protected List<ProviderInfo> buildDiffWeightProviderList(int size) { List<ProviderInfo> aliveConnections = new ArrayList<ProviderInfo>(); for (int i = 0; i < size; i++) { ProviderInfo provider = new ProviderInfo(); provider.setHost("127.0.0.2"); provider.setPort(9000 + i); provider.setWeight(i * 100); // 权重异常乘以100 aliveConnections.add(provider); } return aliveConnections; }