JGroups的協議棧

來源:互聯網
上載者:User

在組通訊領域,JGroups作為可靠的多播通訊工具集享有盛名。JGroups的一大特點就是其靈活的協議棧 Protocol stack, 靈活固然好,有時不明就裡,胡亂搭配,反而不妙。

 

所以,要搞清楚協議的應用情境和參數配置意義,舉例如下

 

<config>

     <UDP

         mcast_port="${jgroups.udp.mcast_port:45588}"

         tos="8"

         ucast_recv_buf_size="20M"

         ucast_send_buf_size="640K"

         mcast_recv_buf_size="25M"

         mcast_send_buf_size="640K"

         loopback="true"

         discard_incompatible_packets="true"

         max_bundle_size="64K"

         max_bundle_timeout="30"

         ip_ttl="${jgroups.udp.ip_ttl:2}"

         enable_bundling="true"

         enable_diagnostics="true"

         thread_naming_pattern="cl"

         timer.num_threads="4"

         thread_pool.enabled="true"

         thread_pool.min_threads="2"

         thread_pool.max_threads="8"

         thread_pool.keep_alive_time="5000"

         thread_pool.queue_enabled="true"

         thread_pool.queue_max_size="10000"

         thread_pool.rejection_policy="discard"

         oob_thread_pool.enabled="true"

         oob_thread_pool.min_threads="1"

         oob_thread_pool.max_threads="8"

         oob_thread_pool.keep_alive_time="5000"

         oob_thread_pool.queue_enabled="false"

         oob_thread_pool.queue_max_size="100"

         oob_thread_pool.rejection_policy="Run"/>

    <PING timeout="2000"

            num_initial_members="3"/>

    <MERGE2 max_interval="30000"

            min_interval="10000"/>

    <FD_SOCK/>

    <FD_ALL/>

    <VERIFY_SUSPECT timeout="1500"  />

    <BARRIER />

    <pbcast.NAKACK use_stats_for_retransmission="false"

                   exponential_backoff="0"

                   use_mcast_xmit="true" gc_lag="0"

                   retransmit_timeout="300,600,1200"

                   discard_delivered_msgs="true"/>

    <UNICAST timeout="300,600,1200"/>

    <pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"

                   max_bytes="1M"/>

    <pbcast.GMS print_local_addr="false" join_timeout="3000"

                view_bundling="true"/>

    <FC max_credits="500K"

                    min_threshold="0.20"/>

    <FRAG2 frag_size="60K"  />

    <pbcast.STREAMING_STATE_TRANSFER />

    <!--pbcast.STATE_TRANSFER  /-->

    <!-- pbcast.FLUSH  /-->

</config>

 

1. UDP 協議,學過電腦網路的人都知道UDP是傳輸層的基本協議,特點就是快但不一定可靠, 這裡是用基於UDP的多播multicast協議來發送訊息的, 也可以改成其他傳輸協議,如 tcp, tcp_nio, tunnel

This is the transport protocol. It uses IP multicasting to send messages to the entire cluster, or
individual nodes. Other transports include TCP, TCP_NIO and TUNNEL.

 

2. PING協議, 用預設的IP多播來發現最初的成員, 類似於作業系統的 ping 命令,一旦ping通,則一個單播join請求將被發送至它以加入當前的 group 或者叫做cluster

Uses IP multicast (by default) to find initial members. Once
found, the current coordinator can be determined and a unicast JOIN
request will be sent to it in order to join the cluster.

 

 

3. MERGE2, 用來合并子組,或在一個子組分離時去除子組

Will merge subgroups back into one group, kicks in after a cluster partition.

4. FD_SOCK 基於socket 的錯誤偵測協議 (在成員之間形成的一個環),當某個成員失敗時會組建通知

Failure detection based on sockets (in a ring form between
members). Generates notification if a member fails

5. FD 基於心跳 heartbeat 和 你還活著 are-you-live 訊息的錯誤偵測協議

(在成員之間形成的一個環),當某個成員失敗時會組建通知

Failure detection based on heartbeats and are-you-alive messages (in a ring  form between
members). Generates notification if a member fails

6. VERIFY_SUSPECT 重複資料偵測一個掛起的成員

是否

已經死掉了, 否則以下協議產生的訊息將被丟棄

Double-checks whether a suspected member is really dead,
otherwise the suspicion generated from protocol below is discarded

 

7. pbcast.NAKACK 確保訊息的可靠和 FIFO

順序

, 訊息可靠性保證了一個訊息會被收到,否則接收者會要求重傳,FIFO保證了從寄件者發過來的所有訊息會以相同順序到達接收方

Ensures (a) message reliability and (b) FIFO. Message
reliability guarantees that a message will be received. If not,
the receiver(s) will request retransmission. FIFO guarantees that all
messages from sender P will be received in the order P sent them

8. UNICAST 與NAKACK差不多,只不過它不是多播,而是單播的

Same as NAKACK for unicast messages: messages from sender P
will not be lost (retransmission if necessary) and will be in FIFO
order (conceptually the same as TCP in TCP/IP)

9. pbcast.STABLE 將已被所有成員收到的訊息刪除,即分布式記憶體回收

Deletes messages that have been seen by all members (distributed message garbage collection)

10. pbcast.GMS 成員協議,負責成員的 加入/離開 並更新新的成員視圖

Membership protocol. Responsible for joining/leaving members and installing new views.

11. FRAG2 將巨大的訊息打碎分割成若干個小的發送,並在接收端重新組裝回去,適用於多播和單播協議

Fragments large messages into smaller ones and reassembles
them back at the receiver side. For both multicast and unicast messages


12. STATE_TRANSFER 狀態傳輸,確保狀態可以正確地從一個成員傳輸到其他的成員

Ensures that state is correctly transferred from an existing member (usually the coordinator) to a
new member

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.