我正在尝试在远程服务器上使用 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 上
两台机器上的防火墙都被禁用。
我怀疑这是配置问题。我应该改变什么才能让它工作?
谢谢,
雅各布尼康