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


Java Directory类代码示例

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


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

示例1: testNoInvoke

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);
    
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(FailoverClusterInvokerTest.class).anyTimes();
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    invokers.add(invoker1);
    
    
    FailoverClusterInvoker<FailoverClusterInvokerTest> invoker = new FailoverClusterInvoker<FailoverClusterInvokerTest>(dic);
    try {
        invoker.invoke(invocation);
        fail();
    } catch (RpcException expected) {
        assertFalse(expected.getCause() instanceof RpcException);
    }
}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:22,代码来源:FailoverClusterInvokerTest.java

示例2: setUp

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
/**
 * @throws java.lang.Exception
 */

@Before
public void setUp() throws Exception {
    
    dic = EasyMock.createMock(Directory.class);
    
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(FailoverClusterInvokerTest.class).anyTimes();
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    invokers.add(invoker1);
    invokers.add(invoker2);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:19,代码来源:FailoverClusterInvokerTest.java

示例3: testNoInvoke

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);
    
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(FailfastClusterInvokerTest.class).anyTimes();
    
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    invokers.add(invoker1);
    
    resetInvoker1ToNoException();
    
    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    try {
        invoker.invoke(invocation);
        fail();
    } catch (RpcException expected) {
        assertFalse(expected.getCause() instanceof RpcException);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:24,代码来源:FailfastClusterInvokerTest.java

示例4: testNoInvoke

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);
    
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
    
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    resetInvokerToNoException();
    
    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    LogUtil.start();
    invoker.invoke(invocation);
    assertTrue(LogUtil.findMessage("No provider") > 0);
    LogUtil.stop();
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:20,代码来源:FailSafeClusterInvokerTest.java

示例5: setUp

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
/**
 * @throws java.lang.Exception
 */

@Before
public void setUp() throws Exception {

    dic = EasyMock.createMock(Directory.class);

    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(FailoverClusterInvokerTest.class).anyTimes();
    invocation.setMethodName("method1");
    EasyMock.replay(dic);

    invokers.add(invoker1);
    invokers.add(invoker2);
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:19,代码来源:FailoverClusterInvokerTest.java

示例6: testNoInvoke

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);

    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(FailoverClusterInvokerTest.class).anyTimes();
    invocation.setMethodName("method1");
    EasyMock.replay(dic);

    invokers.add(invoker1);


    FailoverClusterInvoker<FailoverClusterInvokerTest> invoker = new FailoverClusterInvoker<FailoverClusterInvokerTest>(dic);
    try {
        invoker.invoke(invocation);
        fail();
    } catch (RpcException expected) {
        assertFalse(expected.getCause() instanceof RpcException);
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:22,代码来源:FailoverClusterInvokerTest.java

示例7: testNoInvoke

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);

    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(FailfastClusterInvokerTest.class).anyTimes();

    invocation.setMethodName("method1");
    EasyMock.replay(dic);

    invokers.add(invoker1);

    resetInvoker1ToNoException();

    FailfastClusterInvoker<FailfastClusterInvokerTest> invoker = new FailfastClusterInvoker<FailfastClusterInvokerTest>(dic);
    try {
        invoker.invoke(invocation);
        fail();
    } catch (RpcException expected) {
        assertFalse(expected.getCause() instanceof RpcException);
    }
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:24,代码来源:FailfastClusterInvokerTest.java

示例8: testNoInvoke

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
@Test()
public void testNoInvoke() {
    dic = EasyMock.createMock(Directory.class);

    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(null).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();

    invocation.setMethodName("method1");
    EasyMock.replay(dic);

    resetInvokerToNoException();

    FailsafeClusterInvoker<DemoService> invoker = new FailsafeClusterInvoker<DemoService>(dic);
    LogUtil.start();
    invoker.invoke(invocation);
    assertTrue(LogUtil.findMessage("No provider") > 0);
    LogUtil.stop();
}
 
开发者ID:l1325169021,项目名称:github-test,代码行数:20,代码来源:FailSafeClusterInvokerTest.java

示例9: testInvokerDestoryAndReList

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
/**
   * 测试在调用重试过程中,directory列表变更,invoke重试时重新进行list选择 
   */
  @Test
  public void testInvokerDestoryAndReList(){
  	final URL url = URL.valueOf("test://localhost/"+ Demo.class.getName() + "?loadbalance=roundrobin&retries="+retries);
  	RpcException exception = new RpcException(RpcException.TIMEOUT_EXCEPTION);
  	MockInvoker<Demo> invoker1 = new MockInvoker<Demo>(Demo.class, url);
  	invoker1.setException(exception);
  	
  	MockInvoker<Demo> invoker2 = new MockInvoker<Demo>(Demo.class, url);
  	invoker2.setException(exception);
  	
      final List<Invoker<Demo>> invokers = new ArrayList<Invoker<Demo>>();
      invokers.add(invoker1);
      invokers.add(invoker2);
      
      Callable<Object> callable = new Callable<Object>() {
	public Object call() throws Exception {
		//模拟invoker全部被destroy掉
		for (Invoker<Demo> invoker:invokers){
			invoker.destroy();
		}
		invokers.clear();
		MockInvoker<Demo> invoker3  = new MockInvoker<Demo>(Demo.class, url);
		invokers.add(invoker3);
		return null;
	}
};
invoker1.setCallable(callable);
      invoker2.setCallable(callable);
      
      RpcInvocation inv = new RpcInvocation();
      inv.setMethodName("test");
      
      Directory<Demo> dic = new MockDirectory<Demo>(url, invokers);
      
      FailoverClusterInvoker<Demo> clusterinvoker = new FailoverClusterInvoker<Demo>(dic);
      clusterinvoker.invoke(inv);
  }
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:41,代码来源:FailoverClusterInvokerTest.java

示例10: AbstractClusterInvoker

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
public AbstractClusterInvoker(Directory<T> directory, URL url) {
    if (directory == null)
        throw new IllegalArgumentException("service directory == null");
    
    this.directory = directory ;
    //sticky 需要检测 avaliablecheck 
    this.availablecheck = url.getParameter(Constants.CLUSTER_AVAILABLE_CHECK_KEY, Constants.DEFAULT_CLUSTER_AVAILABLE_CHECK) ;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:9,代码来源:AbstractClusterInvoker.java

示例11: setUp

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
@Before
public void setUp() throws Exception {

    directory = EasyMock.createMock( Directory.class );
    firstInvoker = EasyMock.createMock( Invoker.class );
    secondInvoker = EasyMock.createMock( Invoker.class );
    invocation = EasyMock.createMock( Invocation.class );

}
 
开发者ID:yunhaibin,项目名称:dubbox-hystrix,代码行数:10,代码来源:MergeableClusterInvokerTest.java

示例12: setUp

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
/**
 * @throws java.lang.Exception
 */

@Before
public void setUp() throws Exception {

    dic = EasyMock.createMock(Directory.class);
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(FailbackClusterInvokerTest.class).anyTimes();

    invocation.setMethodName("method1");
    EasyMock.replay(dic);

    invokers.add(invoker);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:FailbackClusterInvokerTest.java

示例13: setUp

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
/**
 * @throws java.lang.Exception
 */

@Before
public void setUp() throws Exception {
    
    dic = EasyMock.createMock(Directory.class);
    
    EasyMock.expect(dic.getUrl()).andReturn(url).anyTimes();
    EasyMock.expect(dic.list(invocation)).andReturn(invokers).anyTimes();
    EasyMock.expect(dic.getInterface()).andReturn(DemoService.class).anyTimes();
    invocation.setMethodName("method1");
    EasyMock.replay(dic);
    
    invokers.add(invoker);
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:18,代码来源:FailSafeClusterInvokerTest.java

示例14: join

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
public <T> Invoker<T> join(Directory<T> directory) throws RpcException {
    
    return new AbstractClusterInvoker<T>(directory) {
        public Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
            for (Invoker<T> invoker : invokers) {
                if (invoker.isAvailable()) {
                    return invoker.invoke(invocation);
                }
            }
            throw new RpcException("No provider available in " + invokers);
        }
    };
    
}
 
开发者ID:zhuxiaolei,项目名称:dubbo2,代码行数:15,代码来源:AvailableCluster.java

示例15: join

import com.alibaba.dubbo.rpc.cluster.Directory; //导入依赖的package包/类
public <T> Invoker<T> join(Directory<T> directory) throws RpcException {

        return new AbstractClusterInvoker<T>(directory) {
            public Result doInvoke(Invocation invocation, List<Invoker<T>> invokers, LoadBalance loadbalance) throws RpcException {
                for (Invoker<T> invoker : invokers) {
                    if (invoker.isAvailable()) {
                        return invoker.invoke(invocation);
                    }
                }
                throw new RpcException("No provider available in " + invokers);
            }
        };

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


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