2012-09-20 53 views
0

我正在嘗試使用FD_PING與jgroups,但它的失敗。 我已經在jg-protocol-id.xml的協議列表中添加了FD_PING,之後它已經開始識別FD_PING,但是當它調用FD_PING中的命令時,它將發送節點的名稱而不是要驗證的ip/hostname 。以下是配置。也請讓我知道如果我能穩定失敗檢測一些如何。目前我們得到很多虛警(因爲我正在嘗試使用FD_PING)。如何在Jgroups中使用FD_PING與tcp

<config xmlns="urn:org:jgroups" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.0.xsd"> 
<TCP bind_port="7800" 
    loopback="true" 
    recv_buf_size="${tcp.recv_buf_size:20M}" 
    send_buf_size="${tcp.send_buf_size:640K}" 
    discard_incompatible_packets="true" 
    max_bundle_size="64K" 
    max_bundle_timeout="30" 
    enable_bundling="true" 
    use_send_queues="true" 
    sock_conn_timeout="300" 

    timer_type="new" 
    timer.min_threads="4" 
    timer.max_threads="10" 
    timer.keep_alive_time="3000" 
    timer.queue_max_size="500" 

    thread_pool.enabled="true" 
    thread_pool.min_threads="10" 
    thread_pool.max_threads="100" 
    thread_pool.keep_alive_time="5000" 
    thread_pool.queue_enabled="true" 
    thread_pool.queue_max_size="100" 
    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="true" 
    oob_thread_pool.queue_max_size="100" 
    oob_thread_pool.rejection_policy="discard"/> 

<TCPPING timeout="1000" 
     initial_hosts="${jgroups.tcpping.initial_hosts:localhost[7800]}" 
     port_range="20" 
     num_initial_members="20"/> 
<MERGE2 min_interval="3000" 
     max_interval="10000"/> 
<FD_PING timeout="3000" max_tries="3" cmd="/tmp/test.sh"/> 
<VERIFY_SUSPECT timeout="1500" /> 
<BARRIER /> 
<SCOPE thread_pool.min_threads="25" 
     thread_pool.max_threads="100" 
     thread_pool.keep_alive_time="20000" 
     expiration_time="60000"/> 
<pbcast.NAKACK 
       use_mcast_xmit="false" 
       retransmit_timeout="300,600,1200,2400,4800" 
       discard_delivered_msgs="true"/> 
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000" 
       max_bytes="4M"/> 
<pbcast.GMS print_local_addr="true" join_timeout="3000" 
      view_bundling="true"/> 
<UFC max_credits="2M" 
    min_threshold="0.4"/> 
<MFC max_credits="2M" 
    min_threshold="0.4"/> 
<FRAG2 frag_size="60K" /> 
<pbcast.STATE_TRANSFER/> 

+0

我從緩存中看到,FD協議只有邏輯地址可用,物理地址只存儲在TP類中。有沒有辦法在FD級別獲取物理地址? – Ranger

回答

0

我已經封裝FD_PING用我自己的協議在走到這一步。

import org.jgroups.Address; 
import org.jgroups.Event; 
import org.jgroups.PhysicalAddress; 
import org.jgroups.protocols.FD_PING; 

public class FD_TEST extends FD_PING { 

    public FD_ILABS() { 
     super(); 
     updatePingDestination(); 
    } 

    @Override 
    public Object up(Event evt) { 
     // TODO Auto-generated method stub 
     Object up = super.up(evt); 
     updatePingDestination(); 
     return up; 
    } 

    @Override 
    public Object down(Event evt) { 
     // TODO Auto-generated method stub 
     Object down = super.down(evt); 
     updatePingDestination(); 
     return down; 
    } 

    private void updatePingDestination() { 
     if(ping_dest!=null && !(ping_dest instanceof PhysicalAddress)) { 
      Address p = ping_dest; 
      ping_dest = (PhysicalAddress)down_prot.down(new Event(87, p)); 
     } 
    } 





} 

所有的協議都是堆疊的,所以你最終可以達到TCP。順便提一下,jgroups擁有鏈式協議。