I don't fully understand your scenario. What is it that you are trying to achieve? You have some service that you only want running on a single node, but you don't ever want it to run on node3?
Yes, exactly. This is a common pattern. Say the first two servers are really expensive big machines with tons of GB memory and cores. In order to achieve high availability we need a quorum which allows to avoid the split brain problem. And this server for the quorum can be a low end server with very low memory and cores setup.
Does this make sense for you?
Why would you install the service on a node that you never want to run it?
Is not sufficient to specify a name preference for node1 and node2?
It was just a question. I see in the code that the service and quorum is installed in different steps. So, my idea was to install just the quorum.
But if that is not supported or doesn't make sense then the current implementation is fine for me.
I am not sure what you mean with the name preference. This just selects the default node... It doesn't solve the split brain problem, right?
I'm not sure what you mean by "install just the quorum". If you have 3 nodes, but you want only node1 or node2 to run your service, you can install it via:
factory.createSingletonServiceBuilder(name, service) .requireQuorum(2) .electionPolicy(new PreferredSingletonElectionPolicy(new SimpleSingletonElectionPolicy(), new NamePreference("node1"), new NamePreference("node2"))) .build(target) .install();