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


Java StaticDirectory类代码示例

本文整理汇总了Java中com.alibaba.dubbo.rpc.cluster.directory.StaticDirectory的典型用法代码示例。如果您正苦于以下问题:Java StaticDirectory类的具体用法?Java StaticDirectory怎么用?Java StaticDirectory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


StaticDirectory类属于com.alibaba.dubbo.rpc.cluster.directory包,在下文中一共展示了StaticDirectory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createTracingCollector

import com.alibaba.dubbo.rpc.cluster.directory.StaticDirectory; //导入依赖的package包/类
@Override
protected TracingCollector createTracingCollector(List<URL> urls) {

    Invoker<TracingCollector> invoker;
    if(urls.size()==1){
        invoker = protocol.refer(TracingCollector.class,urls.get(0));
    }else{
        List<Invoker<TracingCollector>> invokers = new ArrayList<Invoker<TracingCollector>>();
        URL registryURL = null;
        for (URL url : urls) {
            invokers.add(protocol.refer(TracingCollector.class, url));
            if (Constants.REGISTRY_PROTOCOL.equals(url.getProtocol())) {
                registryURL = url; // 用了最后一个registry url
            }
        }
        if (registryURL != null) { // 有 注册中心协议的URL
            // 对有注册中心的Cluster 只用 AvailableCluster
            URL u = registryURL.addParameter(Constants.CLUSTER_KEY, AvailableCluster.NAME);
            invoker = cluster.join(new StaticDirectory(u, invokers));
        }  else { // 不是 注册中心的URL
            invoker = cluster.join(new StaticDirectory(invokers));
        }
    }
    TracingCollector tracingCollector = proxyFactory.getProxy(invoker);
    return tracingCollector;
}
 
开发者ID:dubboclub,项目名称:dubbo-plus,代码行数:27,代码来源:DefaultTracingCollectorFactory.java

示例2: setUp

import com.alibaba.dubbo.rpc.cluster.directory.StaticDirectory; //导入依赖的package包/类
@SuppressWarnings({ "unchecked" })
@Before
public void setUp() throws Exception {
	invocation.setMethodName("sayHello");
    
    invoker1 = EasyMock.createMock(Invoker.class);
    invoker2 = EasyMock.createMock(Invoker.class);
    invoker3 = EasyMock.createMock(Invoker.class);
    invoker4 = EasyMock.createMock(Invoker.class);
    invoker5 = EasyMock.createMock(Invoker.class);
    mockedInvoker1 = EasyMock.createMock(Invoker.class);
    
    URL turl = URL.valueOf("test://test:11/test");
    
    EasyMock.expect(invoker1.isAvailable()).andReturn(false).anyTimes();
    EasyMock.expect(invoker1.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker1.getUrl()).andReturn(turl.addParameter("name", "invoker1")).anyTimes();
    
    EasyMock.expect(invoker2.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker2.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker2.getUrl()).andReturn(turl.addParameter("name", "invoker2")).anyTimes();
    
    EasyMock.expect(invoker3.isAvailable()).andReturn(false).anyTimes();
    EasyMock.expect(invoker3.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker3.getUrl()).andReturn(turl.addParameter("name", "invoker3")).anyTimes();
    
    EasyMock.expect(invoker4.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker4.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker4.getUrl()).andReturn(turl.addParameter("name", "invoker4")).anyTimes();
    
    EasyMock.expect(invoker5.isAvailable()).andReturn(false).anyTimes();
    EasyMock.expect(invoker5.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker5.getUrl()).andReturn(turl.addParameter("name", "invoker5")).anyTimes();
    
    EasyMock.expect(mockedInvoker1.isAvailable()).andReturn(false).anyTimes();
    EasyMock.expect(mockedInvoker1.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(mockedInvoker1.getUrl()).andReturn(turl.setProtocol("mock")).anyTimes();
    
    EasyMock.replay(invoker1,invoker2,invoker3,invoker4,invoker5,mockedInvoker1);
    
    invokers.add(invoker1);
    dic = new StaticDirectory<IHelloService>(url, invokers, null);
    cluster = new AbstractClusterInvoker(dic) {
        @Override
        protected Result doInvoke(Invocation invocation, List invokers, LoadBalance loadbalance)
                throws RpcException {
            return null;
        }
    };
    
    cluster_nocheck = new AbstractClusterInvoker(dic,url.addParameterIfAbsent(Constants.CLUSTER_AVAILABLE_CHECK_KEY, Boolean.FALSE.toString())) {
        @Override
        protected Result doInvoke(Invocation invocation, List invokers, LoadBalance loadbalance)
                throws RpcException {
            return null;
        }
    };
    
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:60,代码来源:AbstractClusterInvokerTest.java

示例3: initDic

import com.alibaba.dubbo.rpc.cluster.directory.StaticDirectory; //导入依赖的package包/类
private void initDic(URL url) {
    dic = new StaticDirectory<FileRouterEngineTest>(url, invokers, Arrays.asList(routerFactory.getRouter(url)));
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:4,代码来源:FileRouterEngineTest.java

示例4: setUp

import com.alibaba.dubbo.rpc.cluster.directory.StaticDirectory; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
@Before
public void setUp() throws Exception {
    invocation.setMethodName("sayHello");

    invoker1 = EasyMock.createMock(Invoker.class);
    invoker2 = EasyMock.createMock(Invoker.class);
    invoker3 = EasyMock.createMock(Invoker.class);
    invoker4 = EasyMock.createMock(Invoker.class);
    invoker5 = EasyMock.createMock(Invoker.class);
    mockedInvoker1 = EasyMock.createMock(Invoker.class);

    URL turl = URL.valueOf("test://test:11/test");

    EasyMock.expect(invoker1.isAvailable()).andReturn(false).anyTimes();
    EasyMock.expect(invoker1.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker1.getUrl()).andReturn(turl.addParameter("name", "invoker1")).anyTimes();

    EasyMock.expect(invoker2.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker2.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker2.getUrl()).andReturn(turl.addParameter("name", "invoker2")).anyTimes();

    EasyMock.expect(invoker3.isAvailable()).andReturn(false).anyTimes();
    EasyMock.expect(invoker3.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker3.getUrl()).andReturn(turl.addParameter("name", "invoker3")).anyTimes();

    EasyMock.expect(invoker4.isAvailable()).andReturn(true).anyTimes();
    EasyMock.expect(invoker4.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker4.getUrl()).andReturn(turl.addParameter("name", "invoker4")).anyTimes();

    EasyMock.expect(invoker5.isAvailable()).andReturn(false).anyTimes();
    EasyMock.expect(invoker5.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(invoker5.getUrl()).andReturn(turl.addParameter("name", "invoker5")).anyTimes();

    EasyMock.expect(mockedInvoker1.isAvailable()).andReturn(false).anyTimes();
    EasyMock.expect(mockedInvoker1.getInterface()).andReturn(IHelloService.class).anyTimes();
    EasyMock.expect(mockedInvoker1.getUrl()).andReturn(turl.setProtocol("mock")).anyTimes();

    EasyMock.replay(invoker1, invoker2, invoker3, invoker4, invoker5, mockedInvoker1);

    invokers.add(invoker1);
    dic = new StaticDirectory<IHelloService>(url, invokers, null);
    cluster = new AbstractClusterInvoker(dic) {
        @Override
        protected Result doInvoke(Invocation invocation, List invokers, LoadBalance loadbalance)
                throws RpcException {
            return null;
        }
    };

    cluster_nocheck = new AbstractClusterInvoker(dic, url.addParameterIfAbsent(Constants.CLUSTER_AVAILABLE_CHECK_KEY, Boolean.FALSE.toString())) {
        @Override
        protected Result doInvoke(Invocation invocation, List invokers, LoadBalance loadbalance)
                throws RpcException {
            return null;
        }
    };

}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:60,代码来源:AbstractClusterInvokerTest.java


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