本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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();
}
示例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);
}
示例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) ;
}
示例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 );
}
示例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);
}
示例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);
}
示例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);
}
};
}
示例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);
}
};
}