@Test(expected = RpcException.class) public void testFail() throws Exception { URL url = URL.valueOf("test: url = url.addParameter(Constants.INTERFACE_KEY, "com.alibaba.dubbo.rpc.file.TpsService"); url = url.addParameter(Constants.TPS_LIMIT_RATE_KEY, 5); Invoker<TpsLimitFilterTest> invoker = new MyInvoker<TpsLimitFilterTest>(url); Invocation invocation = new MockInvocation(); for (int i = 0; i < 10; i++) { try { filter.invoke(invoker, invocation); } catch (Exception e) { assertTrue(i >= 5); throw e; } } }
public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { throw new RpcException( "Failed to invoke service " + invoker.getInterface().getName() + "." + invocation.getMethodName() + " because exceed max service tps."); } return invoker.invoke(invocation); }
TpsLimitFilter implements Filter { public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { throw new RpcException( "Failed to invoke service " + invoker.getInterface().getName() + "." + invocation.getMethodName() + " because exceed max service tps."); } return invoker.invoke(invocation); } }
TpsLimitFilter implements Filter { public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { throw new RpcException( "Failed to invoke service " + invoker.getInterface().getName() + "." + invocation.getMethodName() + " because exceed max service tps."); } return invoker.invoke(invocation); }  }
TpsLimitFilter implements Filter { public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { throw new RpcException( "Failed to invoke service " + invoker.getInterface().getName() + "." + invocation.getMethodName() + " because exceed max service tps."); } return invoker.invoke(invocation); }  Result invoke(Invoker<?> invoker, Invocation invocation); }
TpsLimitFilter implements Filter { public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException { if (!tpsLimiter.isAllowable(invoker.getUrl(), invocation)) { throw new RpcException( "Failed to invoke service " + invoker.getInterface().getName() + "." + invocation.getMethodName() + " because exceed max service tps."); } return invoker.invoke(invocation); }  Result invoke(Invoker<?> invoker, Invocation invocation);  }