1

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

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

这是代码片段:

导入 org.infinispan.client.hotrod.RemoteCache;导入 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 上

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

我怀疑这是配置问题。我应该改变什么才能让它工作?

谢谢,

雅各布尼康

4

3 回答 3

0

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

RemoteCacheManager manager = new RemoteCacheManager("10.100.9.28", port);
于 2013-10-14T08:40:36.787 回答
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"/>
于 2015-06-29T16:29:50.850 回答
-1

属性 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

希望这可以帮助!

于 2014-05-07T07:35:15.030 回答