2

I'm very new to SpringBoot Admin, HazelCast and Docker Swarm... What I'm trying to do is to run 2 instances of SpringBoot Admin Server, in Docker Swarm. It works fine with one instance. I have every feature of SBA working well. If I set the number of replicas to "2", with the following in swarm, then the logging in page doesn't work (it shows up but I can't log in, with no error in the console):

mode: replicated
      replicas: 2
      update_config:
        parallelism: 1
        delay: 60s
        failure_action: rollback
        order: start-first
        monitor: 60s
      rollback_config:
        parallelism: 1
        delay: 60s
        failure_action: pause
        order: start-first
        monitor: 60s
      restart_policy:
        condition: any
        delay: 60s
        max_attempts: 3
        window: 3600s

My current HazelCast config is the following (as specified in SpringBoot Admin doc):

@Bean
    public Config hazelcast() {
        // This map is used to store the events.
        // It should be configured to reliably hold all the data,
        // Spring Boot Admin will compact the events, if there are too many
        MapConfig eventStoreMap = new MapConfig(DEFAULT_NAME_EVENT_STORE_MAP).setInMemoryFormat(InMemoryFormat.OBJECT)
                .setBackupCount(1).setEvictionPolicy(EvictionPolicy.NONE)
                .setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

        // This map is used to deduplicate the notifications.
        // If data in this map gets lost it should not be a big issue as it will atmost
        // lead to
        // the same notification to be sent by multiple instances
        MapConfig sentNotificationsMap = new MapConfig(DEFAULT_NAME_SENT_NOTIFICATIONS_MAP)
                .setInMemoryFormat(InMemoryFormat.OBJECT).setBackupCount(1).setEvictionPolicy(EvictionPolicy.LRU)
                .setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

        Config config = new Config();
        config.addMapConfig(eventStoreMap);
        config.addMapConfig(sentNotificationsMap);
        config.setProperty("hazelcast.jmx", "true");

        // WARNING: This setups a local cluster, you change it to fit your needs.
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);
        TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
        tcpIpConfig.setEnabled(true);

//        NetworkConfig network = config.getNetworkConfig();
//        InterfacesConfig interfaceConfig = network.getInterfaces();
//        interfaceConfig.setEnabled( true )
//                .addInterface( "192.168.1.3" );
//        tcpIpConfig.setMembers(singletonList("127.0.0.1"));
        return config;

    }
```

I guess these inputs are not enough for you to properly help, but since I don't really weel understand the way HazelCast is workging, I don't really know what is useful or not. So please don't hesitate to ask me for what is needed to help! :)

Do you guys have any idea of what I'm doing wrong?

Many thanks!

John Student
  • 298
  • 1
  • 6
  • 18
  • 1
    Could you paste the logs from your application (especially the logs from Hazelcast)? In general, I'm not sure that the following configuration is correct: `config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);`. Not sure that multicast works correctly in Docker Swarm. You can check out this community plugin: https://github.com/bitsofinfo/hazelcast-docker-swarm-discovery-spi – Rafał Leszko Aug 24 '20 at 07:58
  • @RafałLeszko I will post the logs as soon as I reproduce the pb, next week I guess :) – John Student Aug 26 '20 at 12:04

1 Answers1

0

Multicast is not working in Docker Swarm in default overlay driver (at least it stated here). I have tried to make it run with weave network plugin but without luck. In my case, it was enough to switch Hazelcast to the TCP mode and provide the network I like to search for the other replicas.

Something like that:

 -Dhz.discovery.method=TCP
 -Dhz.network.interfaces=10.0.251.*
 -Dhz.discovery.tcp.members=10.0.251.*
Dmytro Sirant
  • 118
  • 10
  • Thanks for the answer! Where should I put this config exactly? In the application.yml ? – John Student Aug 26 '20 at 12:04
  • It should be a way to specify it somehow in the config. I believe it's somewhere here: // NetworkConfig network = config.getNetworkConfig(); // InterfacesConfig interfaceConfig = network.getInterfaces(); // interfaceConfig.setEnabled( true ) // .addInterface( "192.168.1.3" ); // tcpIpConfig.setMembers(singletonList("127.0.0.1")); – Dmytro Sirant Aug 27 '20 at 13:33