2012-04-16 52 views
3

我被玩弄的Infinispan最近,曾與Infinispan的沒有經驗。Web App將不會加入Infinispan的集羣

我遇到了一個有趣的問題,我想知道,如果任何人可以擺脫一些關於它的光。

我有捆綁Infinispan的罐子和有一個類添加/刪除和列表從電網項目一個獨立的Java應用程序(GridGrabber.jar)。在該應用程序創建的CacheManager如下:

DefaultCacheManager m = new DefaultCacheManager("cluster.xml"); 

應用程序的命令行中運行具有java -jar GridGrabber.jar和工作正常,當我在終端上,他們兩個集羣啓動兩個實例在一起,我可以看到的內容來自兩個節點的網格:

[email protected] $ java -jar GridGrabber.jar -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=127.0.0.1 
Apr 16, 2012 9:50:04 PM org.infinispan.remoting.transport.jgroups.JGroupsTransport start 
INFO: ISPN000078: Starting JGroups Channel 
Apr 16, 2012 9:50:04 PM org.infinispan.remoting.transport.jgroups.JGroupsTransport buildChannel 
INFO: ISPN000088: Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration! 
Apr 16, 2012 9:50:05 PM org.jgroups.logging.JDKLogImpl warn 
WARNING: receive buffer of socket [email protected] was set to 20MB, but the OS only allocated 65.51KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux) 
Apr 16, 2012 9:50:05 PM org.jgroups.logging.JDKLogImpl warn 
WARNING: receive buffer of socket [email protected] was set to 25MB, but the OS only allocated 65.51KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux) 
Apr 16, 2012 9:50:06 PM org.infinispan.remoting.transport.jgroups.JGroupsTransport viewAccepted 
INFO: ISPN000094: Received new cluster view: [Samuel-Weavers-MacBook-Pro-62704|1] [Samuel-Weavers-MacBook-Pro-62704, Samuel-Weavers-MacBook-Pro-3360] 
Apr 16, 2012 9:50:06 PM org.infinispan.remoting.transport.jgroups.JGroupsTransport startJGroupsChannelIfNeeded 
INFO: ISPN000079: Cache local address is Samuel-Weavers-MacBook-Pro-3360, physical addresses are [fe80:0:0:0:e2f8:47ff:fe06:109a%5:51422] 
Apr 16, 2012 9:50:06 PM org.jgroups.logging.JDKLogImpl warn 
WARNING: Samuel-Weavers-MacBook-Pro-3360: not member of view [Samuel-Weavers-MacBook-Pro-62704|2]; discarding it 
Apr 16, 2012 9:50:06 PM org.infinispan.factories.GlobalComponentRegistry start 
INFO: ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.2.FINAL 
Apr 16, 2012 9:50:06 PM org.infinispan.jmx.CacheJmxRegistration start 
INFO: ISPN000031: MBeans were successfully registered to the platform mbean server. 
Apr 16, 2012 9:50:12 PM org.infinispan.remoting.transport.jgroups.JGroupsTransport viewAccepted 
INFO: ISPN000093: Received new, MERGED cluster view: MergeView::[Samuel-Weavers-MacBook-Pro-3360|3] [Samuel-Weavers-MacBook-Pro-3360, Samuel-Weavers-MacBook-Pro-62704], subgroups=[Samuel-Weavers-MacBook-Pro-62704|1] [Samuel-Weavers-MacBook-Pro-3360], [Samuel-Weavers-MacBook-Pro-62704|2] [Samuel-Weavers-MacBook-Pro-62704] 

現在,在這裏它變得有趣。我還有一個在AS7上部署的Web應用程序(servlet + JSP),誰的目標是提供一個實時更新網頁的數據輸入網格。該servlet基本上調用與GridGrabber相同的代碼並使用相同的cluster.xml。

當它啓動了一切部署好了,但是但由於某種原因,它不會在網格拿起其他節點,儘管它們都在同一臺機器上運行,並且看到對方沒有問題。部署信息是:

17:06:16,889 INFO [org.jboss.modules] JBoss Modules version 1.1.1.GA 
17:06:17,107 INFO [org.jboss.msc] JBoss MSC version 1.0.2.GA 
17:06:17,155 INFO [org.jboss.as] JBAS015899: JBoss AS 7.1.1.Final "Brontes" starting 
17:06:17,972 INFO [org.xnio] XNIO Version 3.0.3.GA 
17:06:17,972 INFO [org.jboss.as.server] JBAS015888: Creating http management service using socket-binding (management-http) 
17:06:17,981 INFO [org.xnio.nio] XNIO NIO Implementation Version 3.0.3.GA 
17:06:17,990 INFO [org.jboss.remoting] JBoss Remoting version 3.2.3.GA 
17:06:18,006 INFO [org.jboss.as.logging] JBAS011502: Removing bootstrap log handlers 
17:06:18,013 INFO [org.jboss.as.configadmin] (ServerService Thread Pool -- 26) JBAS016200: Activating ConfigAdmin Subsystem 
17:06:18,017 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 31) JBAS010280: Activating Infinispan subsystem. 
17:06:18,038 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 38) JBAS011800: Activating Naming Subsystem 
17:06:18,062 INFO [org.jboss.as.osgi] (ServerService Thread Pool -- 39) JBAS011940: Activating OSGi Subsystem 
17:06:18,070 INFO [org.jboss.as.security] (ServerService Thread Pool -- 44) JBAS013101: Activating Security Subsystem 
17:06:18,077 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension 
17:06:18,103 INFO [org.jboss.as.security] (MSC service thread 1-8) JBAS013100: Current PicketBox version=4.0.7.Final 
17:06:18,121 INFO [org.jboss.as.connector] (MSC service thread 1-3) JBAS010408: Starting JCA Subsystem (JBoss IronJacamar 1.0.9.Final) 
17:06:18,134 INFO [org.jboss.as.naming] (MSC service thread 1-4) JBAS011802: Starting Naming Service 
17:06:18,173 INFO [org.jboss.as.mail.extension] (MSC service thread 1-4) JBAS015400: Bound mail session [java:jboss/mail/Default] 
17:06:18,241 INFO [org.jboss.ws.common.management.AbstractServerConfig] (MSC service thread 1-7) JBoss Web Services - Stack CXF Server 4.0.2.GA 
17:06:18,290 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 
17:06:18,407 INFO [org.apache.coyote.http11.Http11Protocol] (MSC service thread 1-7) Starting Coyote HTTP/1.1 on http-localhost-127.0.0.1-8080 
17:06:18,802 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-7) JBAS010400: Bound data source [java:jboss/datasources/ExampleDS] 
17:06:18,885 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-7) JBAS015012: Started FileSystemDeploymentService for directory /Users/Sam/Downloads/jboss-as-7.1.1.Final/standalone/deployments 
17:06:18,893 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found TwitterWebApp.war in deployment directory. To trigger deployment create a file called TwitterWebApp.war.dodeploy 
17:06:18,894 INFO [org.jboss.as.server.deployment.scanner] (DeploymentScanner-threads - 1) JBAS015003: Found SBTwitterStreamGui.war in deployment directory. To trigger deployment create a file called SBTwitterStreamGui.war.dodeploy 
17:06:18,920 INFO [org.jboss.as.remoting] (MSC service thread 1-5) JBAS017100: Listening on localhost/127.0.0.1:4447 
17:06:18,920 INFO [org.jboss.as.remoting] (MSC service thread 1-2) JBAS017100: Listening on /127.0.0.1:9999 
17:06:19,018 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://127.0.0.1:9990 
17:06:19,019 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: JBoss AS 7.1.1.Final "Brontes" started in 2479ms - Started 133 of 208 services (74 services are passive or on-demand) 
17:06:19,031 INFO [org.jboss.as.server.deployment] (MSC service thread 1-5) JBAS015876: Starting deployment of "TwitterWebApp.war" 
17:06:19,031 INFO [org.jboss.as.server.deployment] (MSC service thread 1-4) JBAS015876: Starting deployment of "SBTwitterStreamGui.war" 
17:06:19,426 INFO [org.jboss.web] (MSC service thread 1-7) JBAS018210: Registering web context: /SBTwitterStreamGui 
17:06:20,267 INFO [org.jboss.web] (MSC service thread 1-3) JBAS018210: Registering web context: /TwitterWebApp 
17:06:20,313 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "TwitterWebApp.war" 
17:06:20,313 INFO [org.jboss.as.server] (DeploymentScanner-threads - 2) JBAS018559: Deployed "SBTwitterStreamGui.war" 
17:06:23,399 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (http-localhost-127.0.0.1-8080-1) ISPN000078: Starting JGroups Channel 
17:06:23,400 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (http-localhost-127.0.0.1-8080-1) ISPN000088: Unable to use any JGroups configuration mechanisms provided in properties {}. Using default JGroups configuration! 
17:06:23,805 WARN [org.jgroups.protocols.UDP] (http-localhost-127.0.0.1-8080-1) receive buffer of socket [email protected] was set to 20MB, but the OS only allocated 65.51KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux) 
17:06:23,807 WARN [org.jgroups.protocols.UDP] (http-localhost-127.0.0.1-8080-1) receive buffer of socket [email protected] was set to 25MB, but the OS only allocated 65.51KB. This might lead to performance problems. Please set your max receive buffer in the OS correctly (e.g. net.core.rmem_max on Linux) 
17:06:26,824 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (http-localhost-127.0.0.1-8080-1) ISPN000094: Received new cluster view: [Samuel-Weavers-MacBook-Pro-102|0] [Samuel-Weavers-MacBook-Pro-102] 
17:06:26,946 INFO [org.infinispan.remoting.transport.jgroups.JGroupsTransport] (http-localhost-127.0.0.1-8080-1) ISPN000079: Cache local address is Samuel-Weavers-MacBook-Pro-102, physical addresses are [10.36.5.166:64952] 
17:06:26,955 INFO [org.infinispan.factories.GlobalComponentRegistry] (http-localhost-127.0.0.1-8080-1) ISPN000128: Infinispan version: Infinispan 'Brahma' 5.1.2.FINAL 
17:06:26,956 WARN [org.infinispan.config.TimeoutConfigurationValidatingVisitor] (http-localhost-127.0.0.1-8080-1) ISPN000148: Invalid <transport>: distributedSyncTimout value of 240000. It can not be higher than <stateRetrieval>:timeout which is 120000 
17:06:27,045 INFO [org.infinispan.jmx.CacheJmxRegistration] (http-localhost-127.0.0.1-8080-1) ISPN000031: MBeans were successfully registered to the platform mbean server. 
17:06:27,061 INFO [stdout] (http-localhost-127.0.0.1-8080-1) Cache Size: 0 
17:06:27,062 INFO [stdout] (http-localhost-127.0.0.1-8080-1) Cluster Name: demoCluster 
17:06:27,063 INFO [stdout] (http-localhost-127.0.0.1-8080-1) Cluster Size: 1 
17:06:27,063 INFO [stdout] (http-localhost-127.0.0.1-8080-1) Cluster Members: [Samuel-Weavers-MacBook-Pro-102] 
17:06:27,064 INFO [stdout] (http-localhost-127.0.0.1-8080-1) Cache Manager: [email protected]@Address:Samuel-Weavers-MacBook-Pro-102 

有誰知道是否有一個原因,一個在AS7部署不會看到在網格中的其他節點?在我看來,它應該可以工作,因爲它們都在尋找相同的羣集名稱(demoCluster),並且它們都使用相同的cluster.xml。該cluster.xml如下:

<infinispan 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="urn:infinispan:config:5.1 http://www.infinispan.org/schemas/infinispan-config-5.1.xsd" 
     xmlns="urn:infinispan:config:5.1"> 

    <global> 
     <transport clusterName="demoCluster"/> 
     <globalJmxStatistics enabled="true"/> 
    </global> 

    <default> 
     <jmxStatistics enabled="true"/> 
     <clustering mode="distribution"> 
     <hash numOwners="2" rehashRpcTimeout="120000"/> 
     <sync/> 
     </clustering> 
    </default> 
</infinispan> 

一件事,我已經從部署的消息注意到的是,Web應用程序似乎使用的IPv4地址和罐子似乎使用與JGroups的IPv6地址,但我不知道這是否會成爲根本原因。任何幫助讚賞。

回答

2

我似乎做已經解決了這個問題,以下內容:

我沿着圍繞的JGroups的IPv4/IPv6地址行權,所以我不得不獨立的應用程序通過給予以下JVM參數使用IPv4: -Djava.net.preferIPv4Stack=true

在這裏需要注意的一件事 - 我從終端運行獨立的jar,並且Web應用程序從Eclipse內部部署到AS7。從終端運行JAR時傳遞JVM參數不成功。但是,也可以從Eclipse內部運行應用程序,並在運行配置「運行」菜單 - >「運行配置」 - >在Java應用程序下添加新的應用程序(或編輯現有應用程序) - >參數 - > VM參數中爲其提供JVM參數 - >在上面粘貼喜歡ipv4stack參數的方塊。

現在在Eclipse中運行兩個獨立的應用程序和Web應用程序時,他們應該加入同一集羣,並開始將消息發送到對方。

在附註上 - 在發出「放棄郵件 - 發件人不在窗口中」之後,我有一個JGroups錯誤。經過進一步調查後,事實證明,連接到(企業)VPN導致郵件被丟棄。一旦我關閉VPN,它就開始工作完美。

希望這可能會幫助有同樣問題的人。

+2

您應該強制將哪個NIC綁定到。你可以通過傳遞:'-Djgroups.bind_addr = xxx' – 2012-04-18 09:21:44

2

如果您想在AS7中部署Infinispan實例,我強烈建議您遵循here的指導。這樣,如果最終在AS7中使用其他集羣服務,則不需要保留單獨的通信層以及其負擔等。

+0

好點,謝謝! – sweaves 2012-04-18 12:37:25