2015-10-02 24 views
0

我想知道在apache點火器中是否存在AddressResolver接口的示例用法。AddressResolver接口的正確用法

我試圖使用AddressResolver接口將我的本地IP地址(例如192.168.10.101)綁定到我的外部IP地址,但沒有運氣。

當我這樣做,Ignite服務器剛剛掛起(沒有從調試或者輸出)

我對啓動服務器的代碼是:

TcpDiscoverySpi spi = new TcpDiscoverySpi(); 

TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); 

ipFinder.setAddresses(ipaddresses); 
spi.setIpFinder(ipFinder); 
spi.setAddressResolver(new IotAddressResolver()); 
IgniteConfiguration cfg = new IgniteConfiguration(); 

// Override default discovery SPI. 
cfg.setDiscoverySpi(spi); 
System.setProperty("IGNITE_QUIET", "false"); 

// Start Ignite node. 
ignite = Ignition.start(cfg); 

我對AddressResolver實現:

public class IotAddressResolver implements AddressResolver { 

    @Override 
    public Collection<InetSocketAddress> getExternalAddresses(
      InetSocketAddress internalAddresses) throws IgniteCheckedException { 

     String host = "XX.XX.XX.XX"; 


     Collection<InetSocketAddress> result = new ArrayList<InetSocketAddress>(); 
     result.add(new InetSocketAddress(host, internalAddresses.getPort())); 
     return result; 
    } 

} 

點火調試日誌的最後一行是:

WARNING: Timed out waiting for message to be read (most probably, the reason is in long GC pauses on remote node) [curTimeout=9989] 

我會很感激任何幫助。謝謝

回答

1

您能否提供有關您的部署的更多詳細信息以及您在地址解析程序的幫助下嘗試實現的內容?你有多少個物理主機和Ignite節點?它們位於不同的網絡中,它們之間有路由器嗎?

+0

在細節 - 我有部署在一個VPS 2個服務器節點,這是工作正確。 –

+0

我想使用地址解析器,以便能夠在本地機器上以客戶端模式運行Ignite,因此我可以在VPS上運行的節點上運行測試。我的本地機器在本地網絡上運行,只有一個公用IP地址用於整個網絡。我在路由器中使用端口轉發,以便能夠將數據包正確「路由」到本地計算機。 –

+0

同樣在我的應用程序屬性中,addesses字段是:ipaddresses = XX.XX.XX.XX:47501..47510,其中XX.XX.XX.XX是我本地網絡的公共地址 –

0

我不知道這是處理這個最好的方法,但我設法啓動igntie作爲本地服務器。我設置我的本地IP地址和端口這樣的:

System.setProperty("IGNITE_QUIET", "false"); 

    TcpDiscoverySpi spi = new TcpDiscoverySpi(); 
    TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder(); 
    TcpCommunicationSpi commSpi = new TcpCommunicationSpi(); 

    // Set initial IP addresses. 
    ipFinder.setAddresses(ipaddresses); 

    spi.setIpFinder(ipFinder); 

    // Override local port. 
    commSpi.setLocalPort(47501); 
    commSpi.setLocalAddress("XX.XX.XX.XX"); 
    commSpi.setLocalPortRange(50); 

    IgniteConfiguration cfg = new IgniteConfiguration(); 

    // Override default communication SPI. 
    cfg.setCommunicationSpi(commSpi); 
    cfg.setDiscoverySpi(spi); 
    cfg.setAddressResolver(new IotAddressResolver()); 
    cfg.setClientMode(true); 

    // Start Ignite node 
    ignite = Ignition.start(cfg); 

XX.XX.XX.XX哪裏是我的本地IP地址

相關問題