8 Replies Latest reply on Oct 9, 2017 10:55 AM by mikedevva

    Wildfly 10 - How to tell which HA Singleton node is Master

    mikedevva

      We are migrating from JBoss 6 to Wildfly 10. We were using an mbean of class "org.jboss.ha.singleton.HASingletonController" similar to this example:

      5.11.2. Mbean deployments using HASingletonController to tell whether a node was the master or not.

       

      We are running two nodes on separate servers and need this for certain scheduled tasks which should only be run by one node, not both.

       

      It doesn't look like this class exists in Wildfly 10. Is there a replacement for it or has it moved to a different package? Or is there another class that does something similar (triggers methods when a node is started and stopped)?

        • 1. Re: Wildfly 10 - How to tell which HA Singleton node is Master
          mikedevva

          If anyone has a solution to this please still post it. But after reading more about it, I'm thinking the intent of Wildfly HA Singleton is to only have one node running at a time and therefore this isn't necessary. But we want to take advantage of multiple applications for more parallel processing. So instead of using any advantages of the HA Singleton which isn't really helping us.

           

          We wanted to know which one was the master so that only one instance would run certain scheduled functionality. So instead, we will just try to use a JMS queue to trigger scheduled events. Then only one of the instances will pick up the event from the queue and do the processing. That should do what we need.

          • 2. Re: Wildfly 10 - How to tell which HA Singleton node is Master
            pferraro

            There are a couple of ways to do this in WF10.

            1. Install a singleton service, and perform your logic within the context of an MSC service. See: quickstart/ha-singleton-service at 11.x · wildfly/quickstart · GitHub
            2. Deploy a singleton deployment containing a @Singletion @Startup EJB that performs your logic on @PostConstruct. See: quickstart/ha-singleton-deployment at 11.x · wildfly/quickstart · GitHub
            • 3. Re: Wildfly 10 - How to tell which HA Singleton node is Master
              mikedevva

              Paul, thank you for the answer. It looks like that is what we're looking for although I have not tried it yet. I would probably try the second option. I only have one more question. How does wildfly know about the other instance running in the cluster if they are on separate servers? Is there configuration that I'm not seeing?

              • 4. Re: Wildfly 10 - How to tell which HA Singleton node is Master
                pferraro

                A singleton deployment is only started on one node in the cluster at a time.  If that node is shutdown/crashes or its singleton deployment is removed, the deployment will be automatically started on another node in the cluster.

                 

                Singleton deployments are distinguished by a singleton-deployment.xml deployment descriptor, which identifies the singleton policy used to deploy the application (if none is defined, the default policy is used).  Singleton policies are defined via the singleton subsystem, found within one of the ha profiles (e.g. standalone-ha.xml).  Internally, singleton deployment state is managed by Infinispan.

                • 5. Re: Wildfly 10 - How to tell which HA Singleton node is Master
                  mikedevva

                  Yes, I understand that is how it probably is supposed to be run. But aren't you limited to running all nodes of the cluster on a single server that way?

                   

                  We are trying to run 2 instances on 2 separate servers in one cluster to take advantage of parallel processing. But we only want one instance to perform some of the scheduled tasks.

                   

                  The second quickstart you listed actually does what we want (I think). The instructions are to start wildfly on the two nodes. It makes it sound like the two nodes can be on separate servers. Then the application is deployed to one node and then the other. So both are running at the same time. I did this (on one server) and I can see that the singleton class was only running on one node. And the failover works. I can understand how the failover would work on a single server from one node to another.

                   

                  But if I start the two nodes on separate servers, how do I let one server know about the other? On failover, how does it know where the other node is? Is this not possible without using domain management? The quickstart implies that it is possible:

                  Start the two ${product.name} servers with the same HA profile using the following commands. Note that a socket binding port offset and a unique node name must be passed to the second server if the servers are binding to the same host.

                  Unfortunately I haven't been able to try the quickstart on two separate servers. I don't have another one available to me right now that has maven and the JDK installed. Both are required for the quickstart.

                   

                  But I did make similar changes to our application. I ran it on two separate servers, starting one and then the other. And of course, without any additional configuration, they don't know about each other. So the singleton was started in each instance. So I'm still wondering if there is a way to configure it to run on multiple servers or not. I can't find any documentation that would explain how to modify the singleton subsystem or the singleton-deployment.xml file.

                  • 6. Re: Wildfly 10 - How to tell which HA Singleton node is Master
                    pferraro

                    WildFly's default configuration configures the socket bindings used by JGroups to use the "private" network interface, which by default uses the following configuration:

                     

                    <interface name="private">
                        <inet-address value="${jboss.bind.address.private:127.0.0.1}"/>
                    </interface>
                    

                     

                    This is why you only observe proper cluster formation when your nodes reside on the same host.  To function across multiple hosts, you will need to modify this to use a non-loopback interface, either by explicitly defining an interface address, or via the "jboss.bind.address.private" system property.

                    • 7. Re: Wildfly 10 - How to tell which HA Singleton node is Master
                      mikedevva

                      Makes sense. I probably won't be able to try that until Monday. I'll respond back if I get it to work. Thanks.

                      • 8. Re: Wildfly 10 - How to tell which HA Singleton node is Master
                        mikedevva

                        I'm still having trouble with this. I'm setting the "jboss.bind.address.private" to a non-loopback address from the command line. I'm also using the same "jboss.default.multicast.address" for both instances by using the -u option a the command line. I'm guessing that's how they should be able to find each other? Here are the commands I'm using:

                         

                        ./standalone.sh --debug --server-config=standalone-full-ha.xml -u=239.255.100.101 -bprivate=10.20.145.74 -Djboss.node.name=node1

                         

                        ./standalone.sh --debug --server-config=standalone-full-ha.xml -u=239.255.100.101 -bprivate=10.20.145.82 -Djboss.node.name=node2

                         

                        The @PostConstruct method of the Singleton class is called in both instances when starting up each one.