Java Code Examples for com.alipay.sofa.rpc.client.ProviderInfo#setPort()

The following examples show how to use com.alipay.sofa.rpc.client.ProviderInfo#setPort() . 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: SofaRpcProviderInterceptorTest.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: SofaRpcConsumerInterceptorTest.java    From skywalking with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: BaseLoadBalancerTest.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
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 4
Source File: BaseLoadBalancerTest.java    From sofa-rpc with Apache License 2.0 5 votes vote down vote up
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;
}