Infinispan Hotrod远程服务器异常

时间:2012-09-13 22:12:43

标签: distributed-caching infinispan

我正在尝试在远程服务器上使用Infinispan远程缓存。我在用 Java应用程序连接到服务器并在内存中存储对象。

当我使用环回地址为本地hotrod服务器运行此应用程序时 (127.0.0.1)它有效。但是,当我尝试将它用于远程服务器时,它会失败。

以下是代码段:

import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCacheManager;

public class HotRodRemoteClient {

     public void start() {
         RemoteCacheManager manager = new RemoteCacheManager("10.100.9.28");
         RemoteCache<Integer, Ticket> cache = manager.getCache();
      }
}

以下是例外:

ISPN004017: Could not fetch transport
org.infinispan.client.hotrod.exceptions.TransportException:: Could not connect to server: /10.100.9.28:11222
     at org.infinispan.client.hotrod.impl.transport.tcp.TcpTransport.<init>(TcpTransport.java:90)
     at org.infinispan.client.hotrod.impl.transport.tcp.TransportObjectFactory.makeObject(TransportObjectFactory.java:57)
     at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1220)
     at org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory.borrowTransportFromPool(TcpTransportFactory.java:254)
     at org.infinispan.client.hotrod.impl.transport.tcp.TcpTransportFactory.getTransport(TcpTransportFactory.java:145)
     at org.infinispan.client.hotrod.impl.operations.FaultTolerantPingOperation.getTransport(FaultTolerantPingOperation.java:44)
     at org.infinispan.client.hotrod.impl.operations.RetryOnFailureOperation.execute(RetryOnFailureOperation.java:67)
     at org.infinispan.client.hotrod.impl.RemoteCacheImpl.ping(RemoteCacheImpl.java:432)
     at org.infinispan.client.hotrod.RemoteCacheManager.ping(RemoteCacheManager.java:538)
     at org.infinispan.client.hotrod.RemoteCacheManager.createRemoteCache(RemoteCacheManager.java:520)
     at org.infinispan.client.hotrod.RemoteCacheManager.getCache(RemoteCacheManager.java:452)
     at org.infinispan.client.hotrod.RemoteCacheManager.getCache(RemoteCacheManager.java:447)
     at com.packtpub.infinispan.chapter2.HotRodRemoteClient.start(HotRodRemoteClient.java:17)
     at com.packtpub.infinispan.chapter2.HotRodRemoteClient.main(HotRodRemoteClient.java:65)

Caused by: java.net.ConnectException: Connection refused
     at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
     at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:599)
     at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:100)
     at org.infinispan.client.hotrod.impl.transport.tcp.TcpTransport.<init>(TcpTransport.java:81)

             ... 13 more

我可以ping服务器10.100.9.28:

shell> ping 10.100.9.28

PING 10.100.9.28 (10.100.9.28): 56 data bytes
64 bytes from 10.100.9.28: icmp_seq=0 ttl=64 time=0.261 ms
64 bytes from 10.100.9.28: icmp_seq=1 ttl=64 time=0.184 ms
64 bytes from 10.100.9.28: icmp_seq=2 ttl=64 time=0.290 ms
64 bytes from 10.100.9.28: icmp_seq=3 ttl=64 time=0.285 ms

我使用的是Infinispan 5.1.6,Maven 3.04,JDK6.33。

我的hotrod服务器在Centos 5.5上运行,但Java应用程序在Mac 10.7上运行

两台计算机上的防火墙都被禁用。

我怀疑这是配置问题。我应该改变什么来使其发挥作用?

谢谢,

Jacob Nikom

3 个答案:

答案 0 :(得分:0)

您应该在构造函数中添加端口:

RemoteCacheManager manager = new RemoteCacheManager("10.100.9.28", port);

答案 1 :(得分:0)

  

属性props = new Properties();

     

props.put(“infinispan.client.hotrod.server_list”,“127.0.0.1:11222”);

     

RemoteCacheManager manager = new RemoteCacheManager(props);

     

RemoteCache defaultCache = manager.getCache();

引自:https://access.redhat.com/site/documentation/en-US/Red_Hat_JBoss_Data_Grid/6.1/html/Getting_Started_Guide/Create_a_New_RemoteCacheManager.html

希望这有帮助!

答案 2 :(得分:0)

在配置文件standalone.xml中查看,而hotrod的套接字绑定没有接口或适用的接口。 默认standalone.xml:

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
    <socket-binding name="management-native" interface="management" port="${jboss.management.native.port:9999}"/>
    <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
    <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9443}"/>
    <socket-binding name="ajp" port="8009"/>
    <socket-binding name="hotrod" interface="management" port="11222"/>
    <socket-binding name="http" port="8080"/>
    <socket-binding name="https" port="8443"/>
    <socket-binding name="memcached" interface="management" port="11211"/>
    <socket-binding name="remoting" port="4447"/>
    <socket-binding name="txn-recovery-environment" port="4712"/>
    <socket-binding name="txn-status-manager" port="4713"/>
</socket-binding-group>

尝试更改

 <socket-binding name="memcached" interface="management" port="11211"/>

 <socket-binding name="memcached" port="11211"/>