Jgroups [3]-tcpping Layer

Source: Internet
Author: User

Tcpping layer attributes

Boolean return_entire_cache = false;
Int max_rank = 0;
Int Rank = 0;
Boolean is_server = false;
Int num_initial_srv_members = 0;
Long timeout = 3000;
Int num_ping_requests = 2;
Int num_initial_members = 2;
Boolean break_on_coord_rsp = true;
Int max_found_members = 0;
Timescheduler timer = NULL;
View view;
Vector <address> members = new vector <address> (11 );
Address local_addr = NULL;
String group_addr = NULL;
Set <responses> ping_responses = new hashset <responses> ();
Pingsendertask sender = new pingsendertask ();
List <IPaddress> initial_hosts = NULL;
Boundedlist <physicaladdress> dynamic_hosts = new boundedlist <physicaladdress> (max );
-------------------------------
Boolean return_entire_cache
Int max_rank
Int rank
These three values are related to how the local response is obtained after the ping request data is sent. return_entire_cache indicates whether the local TP layer is required after the request is sent.
The cached logical_addr_cache is sent to the requester, and then the other condition for determining whether to send the cache is that there is a parameter in the request.
Return_view_only. If this parameter is set to true, the request end only needs the local local_addr-> physical_addr, that is, the condition.
Return_entire_cache &! When the return_view_only parameter is met, the local logical_addr_cache will be sent to the request end. Before processing the previous Logic
There is a judgment, that is, where max_rank and rank work. For example, a group contains five members, each of which is based on the first
In the subsequent order, an index is set to rank, and the value of a size center is set to max_rank. Because the request is sent to all members, only
The rank <= max_rank member can process the ping request.
These three values are set when the tcpping layer processes the event. tmp_view and event. view_change events. When the two events are received
The local local_addr goes to view. member to find rank, and sets max_rank and return_entire_cache according to view. Size,
The logic is that if view. Size <= 10, max_rank = 0 & return_entire_cache = false indicates that when size <= 10, all received ping requests
All requests must be processed. At that time, only the local local_addr-> physical_addr is returned. If view. Size <= 20, max_rank = size/5
& Return_entire_cache = true; other values of the same view. Size <= 20 are max_rank, and the maximum value is 10.
The logic of return_entire_cache described above comes from the tcpping parent class discovery, which is used to process event. tmp_view and
When event. view_change is enabled, return_entire_cache = true will be set in tcpping by default.
-------------------------------
Boolean is_server = false;
Int num_initial_srv_members = 0;
This attribute indicates whether the local server is the identity of the server, whether the local server is set by the logic of the GMS layer, will tell the request when sending the ping response
Whether the local device is the server identity is caused by the request being blocked after the request is sent, and the logic for exiting the blocking includes:
One is to exit when the response from the server exceeds num_initial_srv_members.
-------------------------------
Long timeout = 3000;
Int num_ping_requests = 2;
Local hosts may need to map local_addr-> physical_addr in the group. There are two request sources:
The event. get_physical_address of layer up is mentioned in the TP layer. The other is the event. find_initial_mbrs from the down of the upper layer.
And event. find_all_mbrs, when the two events are received, it means that the upper layer needs the tcpping layer to send a ping request to obtain the address of the machine in the group,
The first case has nothing to do with these two parameters, and is related to the second case. The upper layer needs to send network data when triggering these two events. In order to control the network, Do not overdo
Frequently, a future will be returned after a request sending task is successfully scheduled in a delayed manner so that you can check whether the previous future has been
After the execution is complete, if the execution is not complete, the execution of this task is abandoned, and timeout/num_ping_requests is used to specify the delay
-------------------------------
Timescheduler timer = NULL; this time task scheduling comes from the TP Layer
-------------------------------
Int num_initial_members = 2;
Boolean break_on_coord_rsp = true;
The two parameters serve the same purpose as num_initial_srv_members, and are the condition for blocking after sending ping requests.
Num_initial_members indicates that after a request is sent, if the received response exceeds this value, blocking will be enabled and exit.
Break_on_coord_rsp indicates that after a request is sent, if the identity is received by the coordinator of the entire group, the system can exit after blocking the response.
-------------------------------
Int max_found_members = 0;
This attribute is used to specify the number of expected responses for blocking after the ping request is sent. When this number is reached, the blocking will exit, and the request will have
In both cases, event. find_initial_mbrs and event. find_all_mbrs are matched respectively. The former number is num_initial_members.
It is the maximum value in num_initial_members, max_found_members, and view. Size.
-------------------------------
View view;
Vector <address> members = new vector <address> (11 );
Address local_addr = NULL;
String group_addr = NULL;
These four attributes are very familiar. view indicates the view of group members, and Members indicates the group member list. When event. tmp_view and
Event. view_change changes these two values, and sends the view to the system in response to the ping request.
Local_addr indicates the local logical address. It is set in event. set_local_address, which is down at the jchannel layer.
Group_addr indicates the group name, which is set in the connect series events that are down at the jchannel layer.
-------------------------------
Pingsendertask sender = new pingsendertask ();
This class is used to send ping request buffering. When tcpping receives event. find_initial_mbrs and event. find_all_mbrs from GMS
The Ping request logic is executed. To control the network data volume, the send logic is synchronized by the sender.
All are delayed tasks. When a new task comes, if the previous task has not been executed or has not been completed, it will give up
-------------------------------
Set <responses> ping_responses = new hashset <responses> ();
Class responses is a SYN for sending ping requests-> blocking-> Removing Blocking. Each Ping request is instantiated as a responses class.
Then, the sender is called to send data, and then enters the blocking logic of the responses class. The unblocking reason is that you need to notify these
How to notify responses requires a data structure to maintain all responses. After ping the response, iteration ping_responses one by one notification,
As to whether the data and exit conditions can be separated from blocking, check whether the data and exit conditions are met.
-------------------------------
List <IPaddress> initial_hosts = NULL;
This attribute is where the tcpping layer and even the entire TCP. xml protocol stack can run. The local machine mentioned above may need machines in the group.
The two request sources mapped by local_addr-> physical_addr both need to send the ping request to the machine in the group, and then send the request to the machine in the group to make the group shape
Yes. initial_hosts is used to send all ping requests to these machines when the group is still formed.
-------------------------------
Boundedlist <physicaladdress> dynamic_hosts = new boundedlist <physicaladdress> (max );
Because the group will be dynamically expanded, the newly added machine linked list is dynamic_hosts, which is a restricted-length linked list. Its data source is mainly the tcpping layer.
When receiving the ping request, the other party will send its local_addr & physical_addr, indicating that it is a new machine in the group. If initial_hosts
If it does not exist, it is added to dynamic_hosts. Each time the ping request is sent, it is combined with initial_hosts, and dynamic_hosts sends the ping request.
Bytes ---------------------------------------------------------------------------------------------------------------------
Tcpping layer events

Event. msg
When processing MSG from the TP layer, the MSG. header (tcpping. ID) is obtained. If the header is obtained, the data is interactive information of the tcpping layer.
Otherwise, the MSG will be up. There are four useful data fields in the pingheader.
-Byte type-only get_mbrs_req and get_mbrs_rsp are supported. The former indicates Ping request and the latter indicates Ping response.
-Pingdata-raw data exchanged at the tcpping layer [intra-group machine UUID-sender view-sender. isserver-intra-group machine local_name-intra-group machine physical_addr]
-String cluster_name-jchannel. cluster_name, Which is meaningful for ping requests but meaningless for ping responses
-Boolean return_view_only-whether it is only necessary. It is meaningful for ping requests and meaningless for ping responses.
MSG is divided into two types: get_mbrs_req and get_mbrs_rsp, which are determined by pingheader. type.
1. get_mbrs_req
First, determine whether the ping request needs to be processed. The processing logic is to compare max_rank> 0 with rank. If rank> max_rank, it indicates
The local machine does not need to process the ping request because it is too late to be added. It is handed over to the machine in the [0, max_rank] segment for processing.
In addition, pingheader. cluster_name is taken out for the sake of insurance and compared with the local group_addr.
Information not processed
Ping request data from machine assembly is composed of the following information: [local local_addr, null, false, local logic name, local physical_addrs ].
When reading this information, read the local_addr and physical_addr. If neither of them is null, an event. set_physical_address event will be down.
Add the TP layer to the address cache, and put the uuid-> logic name ing into the cache of the local UUID, and then determine whether the local_addr is initialized.
In the address or dynamic address. If not, add it to the Dynamic Address to indicate a new member.
Finally, based on the logic of sending the response, the data to be sent is determined based on the Local return_entire_cache and pingheader. return_view_only.
If return_entire_cache &! Pingheader. return_view_only extracts all the address cache from the TP layer and iterates the data assembly.
The pingheader is sent and assembled into a response pingheader. The data is organized in the form of [UUID, local. View, local. isserver,
UUID. Logical name, physical address]. If the condition is not true, only the local address is sent. The data organization form is [local_addr, local. View, local. isserver,
Local_name, local. physical_addr]. After pingdata is encapsulated, pingdata is encapsulated into pingheadr [tcpping. ID, pingdata],
Send data through the TP layer.
2. get_mbrs_rsp
Here, the logic processing corresponds to get_mbrs_req, and the data it processes is the data sent by get_mbrs_req, first from pingdata
Read UUID, physical_addr, and UUID. local_name, and add the event. set_physical_address to the TP layer.
Address cache, And the uuid-> logical name ing is put in the cache of the local UUID
Another logic is related to ping_responses, because a responses is generated for all the events that are down in GMS/merge2 to synchronize the down thread.
And the threads in the OOB thread pool of the TP layer that accept data. The pingdata from OOB satisfies the data required by the down thread and then wakes up the down thread,
The wake-up synchronization is done by responses. The OOB thread only needs to put the received pingdata iteration ping_responses into every responses,
Responses determines whether the OOB thread wakes up the down thread based on the currently accepted pingdata. After the down thread is awakened
To determine the data they need. If not, continue to sleep.
-------------------------------
Event. get_physical_address
3. event. get_physical_address from the TP layer. If TP finds that a machine in a group does not have a physical address during network I/O, it will uo this event,
After receiving this time, tcpping sends a ping request. The assembled data format is [local local_addr, null, false, local logic name,
Local physical_addrs]. If the value of pingheader. return_view_only is false, the machine that receives the request sends the request to the cache,
The iteration initialization address and dynamic address send this request one by one. Then, when tcpping receives the get_mbrs_rsp or get_mbrs_req request
The downevent. set_physical_address event is sent to the TP layer, so that the TP layer obtains the desired data.
-------------------------------
Event. tmp_view
Event. view_change
The view and members attributes are maintained in the tcpping layer. When the two events are received, these attributes are reset.
The index in the group is set to max_rank and return_entire_cache Based on view. size. The details are as follows:
This event is handled by the TP layer.
-------------------------------
Event. set_local_address
When tcpping holds the property local_addr, it sets the local local_addr when it receives the event, and then goes down to the TP layer for processing.
-------------------------------
Event. Connect
Event. connect_with_state_transfer
Event. connect_use_flush
Event. connect_with_state_transfer_use_flush
When the tcpping layer receives a connection event, it sets the local group_addr attribute. Its value is cluster_name, which is used to read the data when processing the ping response.
The cluster_name in the pingheader is the same as that in the local database. After processing, it is down and processed by the TP layer.
-------------------------------
Event. Disconnect
Down for TP layer Processing
-------------------------------
Event. become_server
This event is down from the GMS layer. When the tcpping layer receives this event, is_server = true indicates that the local server identity is used.
Protocols of interest include
Nakack-its processing logic is the same as that at the tcpping layer, and it also has an is_server attribute.
-------------------------------
Event. find_initial_mbrs
This event is triggered by the GMS layer. The tcpping layer must send ping request data to all machines in the group and receive num_initial_members data,
Specify return_views_only = false in the pingheader sent to the machine in each group.
-------------------------------
Event. find_all_mbrs
This event is triggered by merge2 layer. The tcpping layer must send ping request data to all machines in the group. When receiving the data in MAX [num_initial_members,
Max_found_members, view. Size] data. Specify return_views_only = true in the pingheader sent to the machine in each group.
That is, the machine in the group can send its own address back.
The operation of the sending logic is the same as that of event. find_initial_mbrs. The difference is that the initialization of the synchronizator responses is different.
Event. find_initial_mbrs [num_initial_members, break_on_coord_rsp, false]
Event. find_all_mbrs [Max, false, true]
The parameters are in turn: How many PING-RSP appears, get the Coordinator response to exit, whether the processor returns only its local address, not the cache
1. According to the preceding condition + num_initial_srv_members, encapsulate a SYN responses and add the SYN responses to ping_responses.
2. Submit the sending request task to the task cache sender.
3. Time-limited timeout blocking waits for the response from the machine in the group. After exiting the blocking operation, remove the responses from ping_responses.
4. Responses synchronization Logic
There is a linked list used to keep so PING-RSP data, when the number of lines exceeds its expectation blocking exit, when the received identity is the number of data lines of the server
When num_initial_srv_members is exceeded, it is blocked and exited when the response from the Coordinator is received, and the PING-RSP linked list is returned.
For so in the PING-RSP also to do a filter, if a uuid has not come in before, then add to the linked list, wake up blocking, if the forward to see if it is
Change the uuid-> physical address sent by the UUID. If it is a wake-up block, otherwise check whether the uuid is the coordinator. If yes and it is not the coordinator, wake up the blocking.
Bytes ---------------------------------------------------------------------------------------------------------------------
Tcpping layer Logic

1. Each layer interacts with the information of its own layer. The information is sent from the top down to the bottom-layer TCP. Add a header-ID in MSG as its own layer during sending.
The header is then sent over TCP to the specified Machine and the data is up to the corresponding layer. The format of the sent data MSG is MSG <list When processing the MSG on the TP layer up, it is determined that this layer needs to be processed. The logic is to find the header from list Processing. Otherwise, the MSG is added.
2. The tcpping layer is also responsible for finding the machine list in the group. There are three locations that drive the machine to obtain information, from the event. find_initial_mbrs,
And the event. find_all_mbrs that is down at the merge2 layer, and the event. get_physical_address that is up at the TP layer. When the tcpping layer accepts the three
When events occur, Ping request packets are sent to the machines in the maintained group. The initialization address configured in XML is first sent.
Request to expand the range of the next Ping request

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.