Search in sources :

Example 1 with DubboInvoker

use of org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker in project pinpoint by naver.

the class ApacheDubboProviderInterceptorTest method createTrace.

@Test
public void createTrace() {
    doReturn(true).when(trace).canSampled();
    doReturn(spanRecorder).when(trace).getSpanRecorder();
    doReturn(trace).when(traceContext).newTraceObject();
    Invoker invoker = new DubboInvoker(Object.class, new URL("http", "127.0.0.1", 8080), null);
    ApacheDubboProviderInterceptor interceptor = new ApacheDubboProviderInterceptor(traceContext, descriptor);
    RpcInvocation rpcInvocation = new RpcInvocation();
    rpcInvocation.setInvoker(invoker);
    rpcInvocation.setMethodName("test");
    rpcInvocation.setAttachment(ApacheDubboConstants.META_PARENT_APPLICATION_NAME, UUID.randomUUID().toString());
    Object[] args = new Object[] { rpcInvocation };
    interceptor.createTrace(invoker, args);
}
Also used : RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) Invoker(org.apache.dubbo.rpc.Invoker) DubboInvoker(org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker) DubboInvoker(org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker) URL(org.apache.dubbo.common.URL) Test(org.junit.Test)

Example 2 with DubboInvoker

use of org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker in project pinpoint by naver.

the class ApacheDubboConsumerInterceptorTest method before.

@Test
public void before() {
    doReturn(trace).when(traceContext).currentRawTraceObject();
    doReturn(true).when(trace).canSampled();
    doReturn(traceId).when(trace).getTraceId();
    doReturn(nextId).when(traceId).getNextTraceId();
    doReturn(spanRecorder).when(trace).traceBlockBegin();
    ApacheDubboConsumerInterceptor interceptor = new ApacheDubboConsumerInterceptor(traceContext, descriptor);
    RpcInvocation rpcInvocation = new RpcInvocation();
    rpcInvocation.setInvoker(new DubboInvoker(Object.class, new URL("http", "127.0.0.1", 8080), null));
    rpcInvocation.setMethodName("test");
    Object[] args = new Object[] { rpcInvocation };
    interceptor.before(obj, args);
}
Also used : RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) DubboInvoker(org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker) URL(org.apache.dubbo.common.URL) Test(org.junit.Test)

Example 3 with DubboInvoker

use of org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker in project dubbo by alibaba.

the class RegistryProtocolTest method testExportUrlNull.

@Test
public void testExportUrlNull() {
    Assertions.assertThrows(IllegalArgumentException.class, () -> {
        RegistryProtocol registryProtocol = getRegistryProtocol();
        // registryProtocol.setCluster(new FailfastCluster());
        Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
        registryProtocol.setProtocol(dubboProtocol);
        Invoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, registryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) });
        registryProtocol.export(invoker);
    });
}
Also used : RegistryProtocol(org.apache.dubbo.registry.integration.RegistryProtocol) DubboInvoker(org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker) RegistryProtocol(org.apache.dubbo.registry.integration.RegistryProtocol) Protocol(org.apache.dubbo.rpc.Protocol) DubboProtocol(org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol) Test(org.junit.jupiter.api.Test)

Example 4 with DubboInvoker

use of org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker in project pinpoint by naver.

the class ApacheDubboProviderInterceptorTest method doInBeforeTrace.

@Test
public void doInBeforeTrace() {
    ApacheDubboProviderInterceptor interceptor = new ApacheDubboProviderInterceptor(traceContext, descriptor);
    RpcInvocation rpcInvocation = new RpcInvocation();
    rpcInvocation.setInvoker(new DubboInvoker(Object.class, new URL("http", "127.0.0.1", 8080), null));
    rpcInvocation.setMethodName("test");
    Object[] args = new Object[] { rpcInvocation };
    interceptor.doInBeforeTrace(recorder, obj, args);
}
Also used : RpcInvocation(org.apache.dubbo.rpc.RpcInvocation) DubboInvoker(org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker) URL(org.apache.dubbo.common.URL) Test(org.junit.Test)

Example 5 with DubboInvoker

use of org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker in project dubbo by alibaba.

the class RegistryProtocolTest method testExport.

@Test
public void testExport() {
    RegistryProtocol registryProtocol = getRegistryProtocol();
    // registryProtocol.setCluster(new FailfastCluster());
    registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension());
    ServiceDescriptor descriptor = ApplicationModel.getServiceRepository().registerService(DemoService.class);
    ApplicationModel.getServiceRepository().registerProvider(service, new DemoServiceImpl(), descriptor, null, null);
    Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
    registryProtocol.setProtocol(dubboProtocol);
    URL newRegistryUrl = registryUrl.addParameter(EXPORT_KEY, serviceUrl);
    DubboInvoker<DemoService> invoker = new DubboInvoker<DemoService>(DemoService.class, newRegistryUrl, new ExchangeClient[] { new MockedClient("10.20.20.20", 2222, true) });
    Exporter<DemoService> exporter = registryProtocol.export(invoker);
    Exporter<DemoService> exporter2 = registryProtocol.export(invoker);
    // The same invoker, exporter that multiple exported are different
    Assertions.assertNotSame(exporter, exporter2);
    exporter.unexport();
    exporter2.unexport();
}
Also used : ServiceDescriptor(org.apache.dubbo.rpc.model.ServiceDescriptor) RegistryProtocol(org.apache.dubbo.registry.integration.RegistryProtocol) DubboInvoker(org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker) RegistryProtocol(org.apache.dubbo.registry.integration.RegistryProtocol) Protocol(org.apache.dubbo.rpc.Protocol) DubboProtocol(org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol) URL(org.apache.dubbo.common.URL) Test(org.junit.jupiter.api.Test)

Aggregations

DubboInvoker (org.apache.dubbo.rpc.protocol.dubbo.DubboInvoker)5 URL (org.apache.dubbo.common.URL)4 RpcInvocation (org.apache.dubbo.rpc.RpcInvocation)3 Test (org.junit.Test)3 RegistryProtocol (org.apache.dubbo.registry.integration.RegistryProtocol)2 Protocol (org.apache.dubbo.rpc.Protocol)2 DubboProtocol (org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol)2 Test (org.junit.jupiter.api.Test)2 Invoker (org.apache.dubbo.rpc.Invoker)1 ServiceDescriptor (org.apache.dubbo.rpc.model.ServiceDescriptor)1