简体   繁体   English

无法将 Java 客户端连接到远程一致性集群缓存

[英]Can not connect Java client to Remote Coherence Cluster Cache

I'm using coherence cluster as remote cache servers (run with Weblogic 12.2.1.3.0) and trying connect from Java application as clients.我将 coherence 集群用作远程缓存服务器(使用 Weblogic 12.2.1.3.0 运行)并尝试从 Java 应用程序作为客户端进行连接。 But I faced error exception while try to connect to Coherence Cluster with cause : Caused by: com.tangosol.net.messaging.ConnectionException: could not establish a connection to one of the following addresses: [10.165.17.23:7574]但是我在尝试连接到 Coherence Cluster 时遇到错误异常,原因是:原因Caused by: com.tangosol.net.messaging.ConnectionException: could not establish a connection to one of the following addresses: [10.165.17.23:7574]

Here is my code :这是我的代码:

  1. Server side :服务器端 :
  • Custom cache config custom-cache-config.xml :自定义缓存配置custom-cache-config.xml
<?xml version="1.0"?>
<cache-config>
    <caching-scheme-mapping>
        <cache-mapping>
            <cache-name>mycache</cache-name>
            <scheme-name>mycache</scheme-name>
        </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
        <distributed-scheme>
            <scheme-name>mycache</scheme-name>
            <service-name>mycacheService</service-name>
            <autostart>true</autostart>
            <backing-map-scheme>
                <read-write-backing-map-scheme>
                    <internal-cache-scheme>
                        <local-scheme>
                <expiry-delay>10d</expiry-delay>
                <flush-delay>1d</flush-delay>
            </local-scheme>
                    </internal-cache-scheme>
                    <read-only>false</read-only>
                </read-write-backing-map-scheme>
                <autostart>true</autostart>
            </backing-map-scheme>
        </distributed-scheme>
    <proxy-scheme>
        <service-name>ExtendTcpCacheService</service-name>
        <autostart>true</autostart>
    </proxy-scheme>
    </caching-schemes>
    <tcp-acceptor>
       <local-address>
          <address>10.165.17.23</address>
          <port>7574</port>
       </local-address>
    </tcp-acceptor>
</cache-config>
  • Run Servers Cache : java -Dtangosol.coherence.cacheconfig=custom-cache-config.xml -Dtangosol.coherence.cluster=mycache -Dtangosol.coherence.clusteraddress=10.165.17.23 -Dtangosol.coherence.clusterport=7574 -Dtangosol.coherence.extend.enabled=true -jar ../lib/coherence.jar运行服务器缓存: java -Dtangosol.coherence.cacheconfig=custom-cache-config.xml -Dtangosol.coherence.cluster=mycache -Dtangosol.coherence.clusteraddress=10.165.17.23 -Dtangosol.coherence.clusterport=7574 -Dtangosol.coherence.extend.enabled=true -jar ../lib/coherence.jar
  • Server logs :服务器日志:
2022-03-11 13:50:01.110/0.325 Oracle Coherence 12.2.1.3.17 <Info> (thread=main, member=n/a): Loaded operational configuration from "jar:file:/data01/install/fmw/coherence/lib/coherence.jar!/tangosol-coherence.xml"
2022-03-11 13:50:01.141/0.355 Oracle Coherence 12.2.1.3.17 <Info> (thread=main, member=n/a): Loaded operational overrides from "jar:file:/data01/install/fmw/coherence/lib/coherence.jar!/tangosol-coherence-override-dev.xml"
2022-03-11 13:50:01.141/0.356 Oracle Coherence 12.2.1.3.17 <Info> (thread=main, member=n/a): Optional configuration override "/tangosol-coherence-override.xml" is not specified
2022-03-11 13:50:01.143/0.358 Oracle Coherence 12.2.1.3.17 <Info> (thread=main, member=n/a): Optional configuration override "cache-factory-config.xml" is not specified
2022-03-11 13:50:01.143/0.358 Oracle Coherence 12.2.1.3.17 <Info> (thread=main, member=n/a): Optional configuration override "cache-factory-builder-config.xml" is not specified
2022-03-11 13:50:01.144/0.358 Oracle Coherence 12.2.1.3.17 <Info> (thread=main, member=n/a): Optional configuration override "/custom-mbeans.xml" is not specified

Oracle Coherence Version 12.2.1.3.17 Build 89350
 Grid Edition: Development mode
Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.

2022-03-11 13:50:01.237/0.451 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=main, member=n/a): Loaded cache configuration from "file:/data01/install/fmw/coherence/bin/custom-cache-config.xml"; this document does not refer to any schema definition and has not been validated.
2022-03-11 13:50:01.452/0.667 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=main, member=n/a): Created cache factory com.tangosol.net.ExtensibleConfigurableCacheFactory
2022-03-11 13:50:01.712/0.927 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=main, member=n/a): TCMP bound to /10.165.17.23:33457 using SystemDatagramSocketProvider
2022-03-11 13:50:02.792/2.007 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=NameServiceBridge:TcpInitiator, member=n/a): Loaded POF configuration from "jar:file:/data01/install/fmw/coherence/lib/coherence.jar!/coherence-pof-config.xml"
2022-03-11 13:50:05.965/5.179 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=NameService:TcpAcceptor, member=n/a): TcpAcceptor now listening for connections on testingCache101652523:33457.3
2022-03-11 13:50:05.968/5.182 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=Cluster, member=n/a): Created a new cluster "mycache" with Member(Id=1, Timestamp=2022-03-11 13:50:01.733, Address=10.165.17.23:33457, MachineId=39228, Location=process:3784, Role=CoherenceServer, Edition=Grid Edition, Mode=Development, CpuCount=12, SocketCount=3)
2022-03-11 13:50:05.988/5.202 Oracle Coherence GE 12.2.1.3.17 <D5> (thread=Transport:TransportService, member=n/a): Service TransportService is bound to tmb://10.165.17.23:33457.58346
2022-03-11 13:50:05.995/5.210 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=Transport:TransportService, member=n/a): Service TransportService joined the cluster with senior service member 1
2022-03-11 13:50:05.997/5.211 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=main, member=n/a): Started cluster Name=mycache, ClusterPort=7574

Group{Address=10.165.17.23, TTL=4}

MasterMemberSet(
  ThisMember=Member(Id=1, Timestamp=2022-03-11 13:50:01.733, Address=10.165.17.23:33457, MachineId=39228, Location=process:3784, Role=CoherenceServer)
  OldestMember=Member(Id=1, Timestamp=2022-03-11 13:50:01.733, Address=10.165.17.23:33457, MachineId=39228, Location=process:3784, Role=CoherenceServer)
  ActualMemberSet=MemberSet(Size=1
    Member(Id=1, Timestamp=2022-03-11 13:50:01.733, Address=10.165.17.23:33457, MachineId=39228, Location=process:3784, Role=CoherenceServer)
    )
  MemberId|ServiceJoined|MemberState|Version
    1|2022-03-11 13:50:01.733|JOINED|12.2.1.3.17
  RecycleMillis=1200000
  RecycleSet=MemberSet(Size=0
    )
  )

TcpRing{Connections=[]}
IpMonitor{Addresses=0, Timeout=15s}

2022-03-11 13:50:06.007/5.221 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=Invocation:Management, member=1): Service Management joined the cluster with senior service member 1
2022-03-11 13:50:06.043/5.257 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=main, member=1): Loaded Reporter configuration from "jar:file:/data01/install/fmw/coherence/lib/coherence.jar!/reports/report-group.xml"
2022-03-11 13:50:06.066/5.280 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=main, member=1): JMXConnectorServer now listening for connections on testingCache101652523:35163
2022-03-11 13:50:06.074/5.288 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=main, member=1): Loaded Reporter configuration from "jar:file:/data01/install/fmw/coherence/lib/coherence.jar!/reports/report-group.xml"
2022-03-11 13:50:06.228/5.443 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=DistributedCache:mycacheService, member=1): Service mycacheService joined the cluster with senior service member 1
2022-03-11 13:50:06.240/5.455 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=DistributedCache:mycacheService, member=1): Service mycacheService: sending PartitionConfig ConfigSync to all
2022-03-11 13:50:06.255/5.469 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=DistributedCache:mycacheService, member=1): This member has become the distribution coordinator for MemberSet(Size=1
  Member(Id=1, Timestamp=2022-03-11 13:50:01.733, Address=10.165.17.23:33457, MachineId=39228, Location=process:3784, Role=CoherenceServer)
  )
2022-03-11 13:50:06.268/5.482 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=Proxy:ExtendTcpCacheService:TcpAcceptor, member=1): TcpAcceptor now listening for connections on testingcoherence101652523:33457.52436
2022-03-11 13:50:06.274/5.488 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=Proxy:ExtendTcpCacheService, member=1): Service ExtendTcpCacheService joined the cluster with senior service member 1
2022-03-11 13:50:06.276/5.490 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=main, member=1): 
Services
  (
  ClusterService{Name=Cluster, State=(SERVICE_STARTED, STATE_JOINED), Id=0, OldestMemberId=1}
  TransportService{Name=TransportService, State=(SERVICE_STARTED), Id=1, OldestMemberId=1}
  InvocationService{Name=Management, State=(SERVICE_STARTED), Id=2, OldestMemberId=1}
  PartitionedCache{Name=mycacheService, State=(SERVICE_STARTED), Id=3, OldestMemberId=1, LocalStorage=enabled, PartitionCount=257, BackupCount=1, AssignedPartitions=257, BackupPartitions=0, CoordinatorId=1}
  ProxyService{Name=ExtendTcpCacheService, State=(SERVICE_STARTED), Id=4, OldestMemberId=1}
  )

Started DefaultCacheServer...

2022-03-11 13:50:06.282/5.497 Oracle Coherence GE 12.2.1.3.17 <Info> (thread=DistributedCache:myCacheService, member=1): Partition ownership has stabilized with 1 nodes
  1. Client side :客户端 :
  • cache config coherence-cache-config.xml缓存配置coherence-cache-config.xml
<?xml version="1.0"?>

<!DOCTYPE cache-config SYSTEM "cache-config.dtd">

<cache-config>
    <caching-scheme-mapping>
        <cache-mapping>
            <cache-name>*</cache-name>
            <scheme-name>mycache</scheme-name>
        </cache-mapping>
    </caching-scheme-mapping>
    <caching-schemes>
        <!--
        Default-Replicated caching scheme.
        -->
        <remote-cache-scheme>
            <scheme-name>mycache</scheme-name>
            <service-name>mycacheService</service-name>
            <initiator-config>
                <tcp-initiator>
                    <remote-addresses>
                        <socket-address>
                            <address>10.165.17.23</address>
                            <port>7574</port>
                            <reusable>true</reusable>
                        </socket-address>
                    </remote-addresses>
                    <connect-timeout>10s</connect-timeout>
                </tcp-initiator>
                <outgoing-message-handler>
                    <request-timeout>20s</request-timeout>
                </outgoing-message-handler>
            </initiator-config>
        </remote-cache-scheme>
        <remote-invocation-scheme>
            <scheme-name>extend-invocation</scheme-name>
            <service-name>ExtendTcpInvocationService</service-name>
            <initiator-config>
                <tcp-initiator>
                    <remote-addresses>
                        <socket-address>
                            <address>10.165.17.23</address>
                            <port>7574</port>
                        </socket-address>
                    </remote-addresses>
                    <connect-timeout>10s</connect-timeout>
                </tcp-initiator>
                <outgoing-message-handler>
                    <request-timeout>5s</request-timeout>
                </outgoing-message-handler>
            </initiator-config>
        </remote-invocation-scheme>
        <class-scheme>
            <scheme-name>default-backing-map</scheme-name>
            <class-name>com.tangosol.util.SafeHashMap</class-name>
        </class-scheme>
    </caching-schemes>
</cache-config>
  • tangosol-coherence-override.xml tangosol-coherence-override.xml
<?xml version='1.0'?>
<coherence>
    <cluster-config>
        <member-identity>
            <cluster-name>mycache</cluster-name>
        </member-identity>
        <multicast-listener>
            <address>10.165.17.23</address>
            <port>7574</port>
        </multicast-listener>
    </cluster-config>
    <configurable-cache-factory-config>
        <class-name>com.tangosol.net.DefaultConfigurableCacheFactory
        </class-name>
        <init-params>
            <init-param>
                <param-type>java.lang.String</param-type>
                <param-value>coherence-cache-config.xml</param-value>
            </init-param>
        </init-params>
    </configurable-cache-factory-config>
</coherence>
  • Arguments when run client:运行客户端时的参数:
<arguments>
                        <argument>-Dtangosol.coherence.override=${project.basedir}/src/main/resources/tangosol-coherence-override.xml</argument>
                        <argument>-Djava.net.preferIPv4Stack=true</argument>
                    </arguments>

And here is full client error logs :这是完整的客户端错误日志:

Caused by: com.tangosol.net.messaging.ConnectionException: could not establish a connection to one of the following addresses: [10.165.17.23:7574]
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.peer.initiator.TcpInitiator.openConnection(TcpInitiator.CDB:139) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.peer.Initiator.ensureConnection(Initiator.CDB:11) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.net.extend.remoteService.RemoteCacheService.openChannel(RemoteCacheService.CDB:7) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.net.extend.RemoteService.ensureChannel(RemoteService.CDB:6) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.net.extend.RemoteService.doStart(RemoteService.CDB:11) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.net.extend.RemoteService.start(RemoteService.CDB:5) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.util.SafeService.startService(SafeService.CDB:66) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.util.safeService.SafeCacheService.startService(SafeCacheService.CDB:5) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.util.SafeService.ensureRunningService(SafeService.CDB:28) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.util.SafeService.startInternal(SafeService.CDB:14) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.util.SafeService$StartAction.run(SafeService.CDB:1) ~[coherence.jar:12.2.1.3.17]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_282]
    at javax.security.auth.Subject.doAs(Subject.java:360) ~[na:1.8.0_282]
    at com.tangosol.net.security.DoAsAction.run(DoAsAction.java:42) ~[coherence.jar:12.2.1.3.17]
    at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_282]
    at com.tangosol.coherence.component.util.SafeService.start(SafeService.CDB:4) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.net.DefaultConfigurableCacheFactory.startService(DefaultConfigurableCacheFactory.java:1237) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.net.DefaultConfigurableCacheFactory.ensureServiceInternal(DefaultConfigurableCacheFactory.java:1223) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.net.DefaultConfigurableCacheFactory.ensureService(DefaultConfigurableCacheFactory.java:1054) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.net.DefaultConfigurableCacheFactory.ensureCache(DefaultConfigurableCacheFactory.java:1036) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.net.DefaultConfigurableCacheFactory.configureCache(DefaultConfigurableCacheFactory.java:1430) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.net.DefaultConfigurableCacheFactory.ensureCache(DefaultConfigurableCacheFactory.java:366) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.net.CacheFactory.getCache(CacheFactory.java:296) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.net.CacheFactory.getCache(CacheFactory.java:212) ~[coherence.jar:12.2.1.3.17]
    at com.vnpt.coherence.adapter.configurations.CacheConfiguration.getCache(CacheConfiguration.java:20) ~[classes/:na]
    at com.vnpt.coherence.adapter.configurations.CacheConfiguration$$EnhancerBySpringCGLIB$$84145143.CGLIB$getCache$1(<generated>) ~[classes/:na]
    at com.vnpt.coherence.adapter.configurations.CacheConfiguration$$EnhancerBySpringCGLIB$$84145143$$FastClassBySpringCGLIB$$c9ebfb0c.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.2.8.RELEASE.jar:5.2.8.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.2.8.RELEASE.jar:5.2.8.RELEASE]
    at com.vnpt.coherence.adapter.configurations.CacheConfiguration$$EnhancerBySpringCGLIB$$84145143.getCache(<generated>) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_282]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_282]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_282]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_282]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.2.8.RELEASE.jar:5.2.8.RELEASE]
    ... 33 common frames omitted
Caused by: com.tangosol.net.messaging.ConnectionException: TcpConnection(Id=null, Open=true, LocalAddress=::aa9:1bd:55668, RemoteAddress=10.165.17.23:7574)
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.peer.initiator.TcpInitiator$TcpConnection$TcpReader.onNotify(TcpInitiator.CDB:46) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.util.Daemon.run(Daemon.CDB:54) ~[coherence.jar:12.2.1.3.17]
    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_282]
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(SocketInputStream.java:210) ~[na:1.8.0_282]
    at java.net.SocketInputStream.read(SocketInputStream.java:141) ~[na:1.8.0_282]
    at java.io.BufferedInputStream.fill(BufferedInputStream.java:246) ~[na:1.8.0_282]
    at java.io.BufferedInputStream.read(BufferedInputStream.java:265) ~[na:1.8.0_282]
    at java.io.DataInputStream.readUnsignedByte(DataInputStream.java:288) ~[na:1.8.0_282]
    at com.tangosol.util.ExternalizableHelper.readInt(ExternalizableHelper.java:616) ~[coherence.jar:12.2.1.3.17]
    at com.tangosol.coherence.component.util.daemon.queueProcessor.service.peer.initiator.TcpInitiator$TcpConnection$TcpReader.onNotify(TcpInitiator.CDB:15) ~[coherence.jar:12.2.1.3.17]

What is I missing in my code.我的代码中缺少什么。 Thanks for help !!!感谢帮助 !!!

Looking at your provided coherence configuration files, you are incorrectly using the cluster port value of 7574 specified in tangosol-coherence-override.xml in coherence.cluster-config.multicast-listener.port for the proxy port.查看您提供的一致性配置文件,您错误地使用了 coherence.cluster-config.multicast-listener.port 中 tangosol-coherence-override.xml 中指定的集群端口值 7574 作为代理端口。 The proxy port should be a port that is not in use.代理端口应该是未使用的端口。

Thus, in custom-cache-config.xml, change the port to a port that is not in use, lets just call the integer value XXXX for tcp-acceptor.local-address.port.因此,在 custom-cache-config.xml 中,将端口更改为未使用的端口,我们只需调用 tcp-acceptor.local-address.port 的整数值 XXXX。 In client coherence-cache-config.xml, make following changes in xml fragement.在客户端 coherence-cache-config.xml 中,对 xml 片段进行以下更改。

         <initiator-config>
            <tcp-initiator>
                <remote-addresses>
                    <socket-address>
                        <address>10.165.17.23</address>
                        <port>XXXX</port>.         
                        <reusable>true</reusable> <!-- DELETE THIS -->
                    </socket-address>
                </remote-addresses>

To summarize, choose a port that is not in use and substitute where XXXX is mentioned above.总而言之,选择一个未使用的端口并替换上面提到的 XXXX。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM