Infinispan Serverで、JGroupsのstackを追加することを考えてみます。
これをXMLの設定ファイルを直接編集して追加すると、負けな気がするので…。あと、1度やっておいてメモして
おこうという意図です。
Infinispan Serverは、9.3.1.Finalを使用します。
$ wget http://downloads.jboss.org/infinispan/9.3.1.Final/infinispan-server-9.3.1.Final.zip
$ unzip infinispan-server-9.3.1.Final.zip
$ cd infinispan-server-9.3.1.Final
Infinispan Serverを、クラスタリングできる状態で起動します(今回はクラスタは組みませんが)。
$ bin/standalone.sh -c clustered.xml
CLIで接続します。
$ bin/ispn-cli.sh -c [standalone@localhost:9990 /]
すでに構成されているudp stackから、pbcast.GMSにpropertiesを追加しただけのstackをudp2として作ってみましょう。起動時に自Nodeの情報を表示するように、
「print_local_addr」と「print_physical_addrs」をそれぞれtrueに指定します。
[standalone@localhost:9990 /] /subsystem=datagrid-jgroups/stack=udp2:add(transport={type=UDP, socket-binding=jgroups-udp},protocols=[{type=PING},{type=MERGE3},{type=FD_SOCK, socket-binding=jgroups-udp-fd},{type=FD_ALL},{type=VERIFY_SUSPECT},{type=pbcast.NAKACK2},{type=UNICAST3},{type=pbcast.STABLE},{type=pbcast.GMS, properties={print_local_addr=true, print_physical_addrs=true}},{type=UFC_NB},{type=MFC_NB},{type=FRAG3}]) { "outcome" => "success", "response-headers" => { "operation-requires-reload" => true, "process-state" => "reload-required" } }
XML上は、こんな感じになりました。
<stack name="udp2"> <transport type="UDP" socket-binding="jgroups-udp"/> <protocol type="PING"/> <protocol type="MERGE3"/> <protocol type="FD_SOCK" socket-binding="jgroups-udp-fd"/> <protocol type="FD_ALL"/> <protocol type="VERIFY_SUSPECT"/> <protocol type="pbcast.NAKACK2"/> <protocol type="UNICAST3"/> <protocol type="pbcast.STABLE"/> <protocol type="pbcast.GMS"> <property name="print_local_addr"> true </property> <property name="print_physical_addrs"> true </property> </protocol> <protocol type="UFC_NB"/> <protocol type="MFC_NB"/> <protocol type="FRAG3"/> </stack>
再起動を要求されますが、使用するstackを変更したいので、1度停止します。
[standalone@localhost:9990 /] shutdown
再度Infinispan Serverを起動する時に、「jboss.default.jgroups.stack」に追加したstackを指定します。
$ bin/standalone.sh -c clustered.xml -Djboss.default.jgroups.stack=udp2
「print_local_addr」と「print_physical_addrs」をtrueにしたので、自Nodeの情報が表示されます。
22:18:33,859 INFO [stdout] (MSC service thread 1-4) ------------------------------------------------------------------- 22:18:33,860 INFO [stdout] (MSC service thread 1-4) GMS: address=localhost, cluster=cluster, physical address=127.0.0.1:55200 22:18:33,860 INFO [stdout] (MSC service thread 1-4) -------------------------------------------------------------------
また、最初の例では一括で登録しましたが、個々にprotocolを登録していくのでもOKです。以下は、バッチモードで登録。
[standalone@localhost:9990 /] batch [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add(transport={type=UDP, socket-binding=jgroups-udp}) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=PING) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=MERGE3) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=FD_SOCK, socket-binding=jgroups-udp-fd) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=FD_ALL) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=VERIFY_SUSPECT) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=pbcast.NAKACK2) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=UNICAST3) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=pbcast.STABLE) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=pbcast.GMS, properties={print_local_addr=true, print_physical_addrs=true}) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=UFC_NB) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=MFC_NB) [standalone@localhost:9990 / #] /subsystem=datagrid-jgroups/stack=udp3:add-protocol(type=FRAG3) [standalone@localhost:9990 / #] run-batch The batch executed successfully process-state: reload-required
あとでpropertyを変更したり追加したりしたい場合は、write-attributeで。
[standalone@localhost:9990 /] /subsystem=datagrid-jgroups/stack=udp2/protocol=pbcast.GMS:write-attribute(name=properties.print_local_addr,value=true)
protocolやtransportは、remove-protocolやremoveでそれぞれ消すことができます。
[standalone@localhost:9990 /] /subsystem=datagrid-jgroups/stack=udp2:remove-protocol(type=MFC_NG) [standalone@localhost:9990 /] /subsystem=datagrid-jgroups/stack=udp2/transport=UDP:remove()
ですが、stackそのものは消せないようです…?
[standalone@localhost:9990 /] /subsystem=datagrid-jgroups/stack=udp2:remove() { "outcome" => "failed", "failure-description" => "WFLYCTL0158: Operation handler failed: java.lang.IllegalArgumentException", "rolled-back" => true, "response-headers" => undefined }
なお、あとで似たようなことを書いている方がいることに気づきました…。
keycloak を JDBC PING で動かす - moremagic’s diary
オマケ(WildFlyの場合)
WildFlyの場合は、13.0.0.Final。
$ wget http://download.jboss.org/wildfly/13.0.0.Final/wildfly-13.0.0.Final.zip
$ unzip wildfly-13.0.0.Final.zip
$ cd wildfly-13.0.0.Final
WildFlyの場合、中に入っているInfinispanは9.2.4.Finalですが。
起動。
$ bin/standalone.sh -c standalone-ha.xml
CLIで接続。
$ bin/jboss-cli.sh -c [standalone@localhost:9990 /]
udp2を追加。
[standalone@localhost:9990 /] /subsystem=jgroups/stack=udp2:add(transport={type=UDP, socket-binding=jgroups-udp},protocols=[{type=PING},{type=MERGE3},{type=FD_SOCK, socket-binding=jgroups-udp-fd},{type=FD_ALL},{type=VERIFY_SUSPECT},{type=pbcast.NAKACK2},{type=UNICAST3},{type=pbcast.STABLE},{type=pbcast.GMS, properties={print_local_addr=true, print_physical_addrs=true}},{type=UFC_NB},{type=MFC_NB},{type=FRAG3}]) { "outcome" => "success", "response-headers" => { "operation-requires-reload" => true, "process-state" => "reload-required" } }
Infinispan Serverの場合は、JGroupsのサブシステム名は「datagrid-jgroups」でしたが、WildFlyの場合は「jgroups」となることに注意です。
WildFlyの場合は、使用するstackは設定でシステムプロパティではなく、設定で変更します。
[standalone@localhost:9990 /] /subsystem=jgroups/channel=ee:write-attribute(name=stack,value=udp2)
あとは、再起動で。