Skip to content

Commit b3d44a6

Browse files
khanimteyazbeiwei30
authored andcommitted
Documentation/2935#dubbo rpc api (#2967)
* added dubbo-rpc-api filter documentation for issue no #2935 * wrong @see java.io.File was added, removed this version of checkins * Close all ports after tests finish (#2906) * fix testCustomExecutor (#2904) * Graceful shutdown enhancement in Spring (#2901) * Simplify the code logic of the method AbstractClusterInvoker#reselect. (#2826) * Simplify the code logic of the method AbstractClusterInvoker#reselect. * Minor modification for code style. * create AbstractRouter (#2909) * create AbstractRouter * router default method * router default method * router default method * mockinvoker * Added javadoc for dubbo-filter module dubbo github issue 2884 (#2921) * Enhance unit test (#2920) * Change Readme dubbo-sample hyperlink (#2927) * Simply TagRouter (#2924) * make telnet config work again (#2925) * Remove the log to putRandomPort when one protocol use random port (#2931) * optimize findConfigedPorts method of ServiceConfig to log only one time when userandom port * move the log to method putRandomPort * Fix DubboShutdownHook Memory Leak (#2922) * Improve UT grammar and remove unnecessary braces. (#2930) * Improve UT grammer, fix compiler warnings. * Remove unnecessary braces. * re-enable testCustomExecutor (#2917) * fix testCustomExecutor * fix ci * Fixing test-order dependency for FstObjectInputTest (#2815) * re-enable testCustomExecutor (#2913) * Resetting ExtensionLoader to remove test order dependencies in StickyTest (#2807) * optimize the RondRobinLoadBalance and MockClusterInvoker (#2932) delete unused logic and take the logger out. * [Dubbo-2864] Fix build failed with -Prelease (#2923) fixes #2864 * Fix telnet can not find method with enum type (#2803) * [dubbo-2766] fix the bug of isMatch method of InvokeTelnetHandler (#2787) * enhance org.apache.dubbo.rpc.protocol.dubbo.telnet.InvokeTelnetHandler#isMatch (#2941) * enhance isMatch * remove useless imports * [Dubbo-2766]Fix 2766 and enhance the invoke command (#2801) * add getter and setter for ServiceConfig's interfaceName property#2353 * add interfaceName to ignoreAttributeNames and change the unit test * delete the demo source code and update the unit test * unchange ServiceConfig * update unit test * update unit test * fix #2798 and enhance invoke command * Delete useless assignments (#2939) * Replace anonymous class with method reference (#2929) * Replace anonymous class with method reference * Revert changes as per @beiwei30 code review * Optimize retry for FailbackRegistry. (#2763) * Abstract retry task * Task for retry. * Fix sth. * Finish Optimize. fix ci failed. * Optimize retry for FailbackRegistry. The retry operation splits into specific operations, such as subscriptions and registrations. This approach allows for very precise retry control. * Optimize retry for FailbackRegistry. The retry operation splits into specific operations, such as subscriptions and registrations. This approach allows for very precise retry control. * Optimize logger warn's msg. * Optimize FailedNotifiedTask's run method. Optimize addXXXTask, directly return if we already have a retry task. * Optimize notify logic, just notify when the urls is not empty. * Optimize notify logic, just notify when the urls is not empty. * Optimize timer that use daemon thread. * standardize semantics of all mergers,enhance mergeFactory and testcase (#2936) * Modified to lower camel case (#2945) * Improve several map iteration (#2938) * added dubbo-rpc-api filter documentation for issue no #2935 * wrong @see java.io.File was added, removed this version of checkins
1 parent 0648887 commit b3d44a6

File tree

14 files changed

+92
-11
lines changed

14 files changed

+92
-11
lines changed

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/Filter.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,26 @@
1919
import org.apache.dubbo.common.extension.SPI;
2020

2121
/**
22+
* Extension for intercepting the invocation for both service provider and consumer, furthermore, most of
23+
* functions in dubbo are implemented base on the same mechanism. Since every time when remote method is
24+
* invoked, the filter extensions will be executed too, the corresponding penalty should be considered before
25+
* more filters are added.
26+
* <pre>
27+
* They way filter work from sequence point of view is
28+
* <b>
29+
* ...code before filter ...
30+
* invoker.invoke(invocation) //filter work in a filter implementation class
31+
* ...code after filter ...
32+
* </b>
33+
* Caching is implemented in dubbo using filter approach. If cache is configured for invocation then before
34+
* remote call configured caching type's (e.g. Thread Local, JCache etc) implementation invoke method gets called.
35+
* </pre>
2236
* Filter. (SPI, Singleton, ThreadSafe)
37+
*
38+
* @see org.apache.dubbo.rpc.filter.GenericFilter
39+
* @see org.apache.dubbo.rpc.filter.EchoFilter
40+
* @see org.apache.dubbo.rpc.filter.TokenFilter
41+
* @see org.apache.dubbo.rpc.filter.TpsLimitFilter
2342
*/
2443
@SPI
2544
public interface Filter {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ActiveLimitFilter.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,16 @@
3030
import java.util.concurrent.TimeUnit;
3131

3232
/**
33-
* LimitInvokerFilter
33+
* ActiveLimitFilter restrict the concurrent client invocation for a service or service's method from client side.
34+
* To use active limit filter, configured url with <b>actives</b> and provide valid >0 integer value.
35+
* <pre>
36+
* e.g. <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.demo.DemoService" "actives"="2"/>
37+
* In the above example maximum 2 concurrent invocation is allowed.
38+
* If there are more than configured (in this example 2) is trying to invoke remote method, then rest of invocation
39+
* will wait for configured timeout(default is 0 second) before invocation gets kill by dubbo.
40+
* </pre>
41+
*
42+
* @see Filter
3443
*/
3544
@Activate(group = Constants.CONSUMER, value = Constants.ACTIVES_KEY)
3645
public class ActiveLimitFilter implements Filter {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ClassLoaderFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.apache.dubbo.rpc.RpcException;
2626

2727
/**
28-
* ClassLoaderInvokerFilter
28+
* Set the current execution thread class loader to service interface's class loader.
2929
*/
3030
@Activate(group = Constants.PROVIDER, order = -30000)
3131
public class ClassLoaderFilter implements Filter {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/CompatibleFilter.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,18 @@
3232
import java.lang.reflect.Type;
3333

3434
/**
35-
* CompatibleFilter
35+
* CompatibleFilter make the remote method's return value compatible to invoker's version of object.
36+
* To make return object compatible it does
37+
* <pre>
38+
* 1)If the url contain serialization key of type <b>json</b> or <b>fastjson</b> then transform
39+
* the return value to instance of {@link java.util.Map}
40+
* 2)If the return value is not a instance of invoked method's return type available at
41+
* local jvm then POJO conversion.
42+
* 3)If return value is other than above return value as it is.
43+
* </pre>
44+
*
45+
* @see Filter
46+
*
3647
*/
3748
public class CompatibleFilter implements Filter {
3849

@@ -51,9 +62,11 @@ public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcExcept
5162
String serialization = invoker.getUrl().getParameter(Constants.SERIALIZATION_KEY);
5263
if ("json".equals(serialization)
5364
|| "fastjson".equals(serialization)) {
65+
// If the serialization key is json or fastjson
5466
Type gtype = method.getGenericReturnType();
5567
newValue = PojoUtils.realize(value, type, gtype);
5668
} else if (!type.isInstance(value)) {
69+
//if local service interface's method's return type is not instance of return value
5770
newValue = PojoUtils.isPojo(type)
5871
? PojoUtils.realize(value, type)
5972
: CompatibleTypeUtils.compatibleTypeConvert(value, type);

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ConsumerContextFilter.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,12 @@
2828
import org.apache.dubbo.rpc.RpcInvocation;
2929

3030
/**
31-
* ConsumerContextInvokerFilter
31+
* ConsumerContextFilter set current RpcContext with invoker,invocation, local host, remote host and port
32+
* for consumer invoker.It does it to make the requires info available to execution thread's RpcContext.
33+
*
34+
* @see org.apache.dubbo.rpc.Filter
35+
* @see org.apache.dubbo.rpc.PostProcessFilter
36+
* @see RpcContext
3237
*/
3338
@Activate(group = Constants.CONSUMER, order = -10000)
3439
public class ConsumerContextFilter extends AbstractPostProcessFilter {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ContextFilter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@
3030
import java.util.Map;
3131

3232
/**
33-
* ContextInvokerFilter
33+
* ContextFilter set the provider RpcContext with invoker, invocation, local port it is using and host for
34+
* current execution thread.
35+
*
36+
* @see RpcContext
37+
* @see org.apache.dubbo.rpc.PostProcessFilter
3438
*/
3539
@Activate(group = Constants.PROVIDER, order = -10000)
3640
public class ContextFilter extends AbstractPostProcessFilter {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/DeprecatedFilter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
import java.util.Set;
3131

3232
/**
33-
* DeprecatedInvokerFilter
33+
* DeprecatedFilter logs error message if a invoked method has been marked as deprecated. To check whether a method
34+
* is deprecated or not it looks for <b>deprecated</b> attribute value and consider it is deprecated it value is <b>true</b>
35+
*
36+
* @see Filter
3437
*/
3538
@Activate(group = Constants.CONSUMER, value = Constants.DEPRECATED_KEY)
3639
public class DeprecatedFilter implements Filter {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/EchoFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.apache.dubbo.rpc.RpcResult;
2727

2828
/**
29-
* EchoInvokerFilter
29+
* Dubbo provided default Echo echo service, which is available for all dubbo provider service interface.
3030
*/
3131
@Activate(group = Constants.PROVIDER, order = -110000)
3232
public class EchoFilter implements Filter {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/ExecuteLimitFilter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
import java.util.concurrent.Semaphore;
3030

3131
/**
32-
* ThreadLimitInvokerFilter
32+
* The maximum parallel execution request count per method per service for the provider.If the max configured
33+
* <b>executes</b> is set to 10 and if invoke request where it is already 10 then it will throws exception. It
34+
* continue the same behaviour un till it is <10.
35+
*
3336
*/
3437
@Activate(group = Constants.PROVIDER, value = Constants.EXECUTES_KEY)
3538
public class ExecuteLimitFilter implements Filter {

dubbo-rpc/dubbo-rpc-api/src/main/java/org/apache/dubbo/rpc/filter/TokenFilter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
import java.util.Map;
3030

3131
/**
32-
* TokenInvokerFilter
32+
* Perform check whether given provider token is matching with remote token or not. If it does not match
33+
* it will not allow to invoke remote method.
34+
*
35+
* @see Filter
3336
*/
3437
@Activate(group = Constants.PROVIDER, value = Constants.TOKEN_KEY)
3538
public class TokenFilter implements Filter {

0 commit comments

Comments
 (0)