In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "what are the Dubbo Invoker interface groups". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what the Dubbo Invoker interface groups are.
Invoker, load network invocation component, underlying lazy and network communication, Invoker is mainly responsible for service invocation, which is naturally closely related to routing (such as cluster) and other functions. This section first controls the Dubbo service invocation system as a whole, service discovery, clustering, load balancing, routing mechanism and other entire knowledge system.
There are mainly the following interface groups
Invocation (invocation context)
Invocation:
1. String getMethodName () gets the name of the calling method.
2 、 Class
< ? >[] getParameterTypes () gets the parameter list (parameter type) of the called method
3. Object [] getArguments () gets the array of parameter values of the called method.
4 、 Map
< String, String>GetAttachments () gets the additional attributes.
5. String getAttachment (String key) acquires additional attribute values according to key.
6. String getAttachment (String key, String defaultValue) gets additional attributes according to key. If it does not exist, it takes the default value.
7 、 Invoker
< ?>GetInvoker () gets the current invoker.
RpcInvocation rpc service invocation implementation class
The Invocation execution invocation context, which uses a Bean to store the parameters of the current calling method, is essentially a normal Bean.
MockInvocation
Used for mock unit testing.
DecodeableRpcInvocation rpc invocation context with decoding function
This implementation can mainly parse the binary flow (binary package) to get the RPC service invocation context (method invocation metadata) from the RPC service invocation request.
Invoker service caller, the abstraction of invoking services in Dubbo.
The abstract interface of Invoer, inherited from the com.alibaba.dubbo.common.Node interface
Node:
1. URL getUrl (); get the URL. In dubbo, registries, service providers, service consumers, monitoring centers, and so on, all use URL descriptions.
2. Boolean isAvailable (): determine whether it is available.
3. Void destroy (): resource destruction.
Invoker:
1. Class getInterface (): gets the interface of the service provider.
Result invoke (Invocation invocation) throws RpcException: invokes the service and returns the result of the call.
AbstractInvoker Invoker default implementation (template class)
This method mainly implements public Result invoke (Invocation inv) throws RpcException, defines the basic process (template) for executing invoker, and then executes individual execution tasks according to different implementation subclasses (different protocols). Its abstract method: protected abstract Result doInvoke (Invocation invocation) throws Throwable, the concrete implementation will be analyzed later.
The concrete implementation of the DubboInvoker dubbo protocol caller.
InjvmInvoker injvm protocol calls its implementation (native protocol)
AbstractClusterInvoker cluster mode invokes template classes
This class is the invocation template class of the Dubbo cluster pattern, and the topic solves how to select a specific service provider when invoking a service when there are multiple service providers in a service. This class needs to organize multiple service providers and select one service provider for invocation according to the specified algorithm.
AvailableClusterInvoker
Pass through
< dubbo:service cluster = "available" …/>Or
< dubbo:reference cluster="available" …/>Clustering strategy: always choose the first available service provider.
BroadcastClusterInvoker
Pass through
< dubbo:service cluster = "broadcast" …/>Or
< dubbo:reference cluster="broadcast" …/>Cluster policy: broadcast mode, where requests are sent to all service providers, and any call that fails is considered a failure.
FailbackClusterInvoker
Pass through
< dubbo:service cluster = "failback" …/>Or
< dubbo:reference cluster="failback" …/>Cluster strategy: after the failure of the service call, retry regularly, the number of retries is wireless, and the retry frequency is 5s. Does not switch service providers.
FailfastClusterInvoker
Pass through
< dubbo:service cluster = "failfast" …/>Or
< dubbo:reference cluster="failfast" …/>Cluster strategy: after a service call, it fails quickly and throws an exception directly without retrying or being restricted by retries parameters, so it is suitable for adding or modifying class operations.
FailoverClusterInvoker
Pass through
< dubbo:service cluster = "failover" …/>Or
< dubbo:reference cluster="failover" …/>Cluster policy: if a failure occurs after the service call, retry other service providers. By default, retry 2 times for a total of 3 times. The number of retries is configured by retries. Dubbo cluster defaults.
FailsafeClusterInvoker
Pass through
< dubbo:service cluster = "failsafe" …/>Or
< dubbo:reference cluster="failsafe" …/>Cluster policy: after the service is invoked, only the error log is printed and returned directly.
ForkingClusterInvoker
Pass through
< dubbo:service cluster = "forking" …/>Or
< dubbo:reference cluster="forking" …/>Cluster strategy: multiple service providers are called concurrently, taking the result returned by the first. You can set the number of service desk providers for concurrent calls through forks.
LoadBalance cluster load algorithm
When a service has multiple service providers, the consumer chooses the load balancing algorithm of the service provider when invoking the service.
The interfaces defined by LoadBalance are:
< T>Invoker select (List
< Invoker>Invokers, URL url, Invocation invocation) throws RpcException
ConsistentHashLoadBalance
Can be passed through
< dubbo:service loadbalance="consistenthash" …/>Or
< dubbo:provider loadbalance = "consistenthash" …/>Load balancing algorithm: consistent Hash algorithm, which is invoked when a service provider is selected from multiple service providers in AbstractClusterInvoker.
LeastActiveLoadBalance
Can be passed through
< dubbo:service loadbalance="leastactive" …/>Or
< dubbo:provider loadbalance = "leastactive" …/>Load balancing algorithm: minimum active calls.
RandomLoadBalance
Can be passed through
< dubbo:service loadbalance="random" …/>Or
< dubbo:service loadbalance = "random" …/>Load balancing algorithm: random, if weight (the greater the weight, the higher the chance)
RoundRobinLoadBalance
Can be passed through
< dubbo:service loadbalance="roundrobin" …/>Or
< dubbo:provider loadbalance = "roundrobin" …/>Load balancing algorithm: weighted polling algorithm.
Directory (directory service, Invoker's directory service)
The main function of this interface is the directory service of the service provider, managing multiple service providers.
Directory
1 、 Class
< T>GetInterface () gets the service interface category.
2 、 List
< Invoker< T>> list (Invocation invocation) throws RpcException gets all the current service providers for the service based on the invocation context.
4.2 abstract columns of AbstractDirectory directory service implementations (template classes)
4.3 StaticDirectory static directory service
The so-called static directory service is to specify a collection of service providers when the StaticDirectory is created, then the directory service instance will only return these service providers during its life cycle.
RegistryDirectory dynamic directory service (registry-based),
To dynamically obtain the discovery service provision from the registry, the default message consumer will not specify a specific service provider URL, so it will subscribe to the registry service provider (listening to the registry providers directory) and use RegistryDirectory to automatically obtain the list of registry servers.
Router routing function
According to the message consumer URL, combined with the routing expression or JS engine, select the Invoker that conforms to the routing rules from the Directory, and then execute the load balancing algorithm.
Router
1. URL getUrl (); get the message consumer URL.
2 、
< T>List
< Invoker< T>> route (List
< Invoker< T>> invokers, URL url, Invocation invocation) throws RpcException filters the appropriate Invokers from the invokers based on the message consumer URL.
ConditionRouter routing implementation based on conditional expressions.
ScriptRouter is based on the routing implementation of JS engine.
Thank you for your reading, the above is the content of "what is the Dubbo Invoker interface group?" after the study of this article, I believe you have a deeper understanding of what the Dubbo Invoker interface group has, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.