madiskou
madiskou

Reputation: 21

Hazlcast Cluster with in spring boot application docker conf

I am using hazelcast in my spring boot app, i have a hazelcast.yml in my classpath :

hazelcast:
  cluster-name: access-cache
  network:
    join:
      multicast:
        enabled: false
      tcp-ip:
        enabled: true
        member-list:
          - 127.0.0.1:5701
  map:
    default:
      backup-count: 1
      time-to-live-seconds: 300
      max-idle-seconds: 30
      cache-deserialized-values: ALWAYS
      eviction:
        max-size-policy: PER_NODE
        size: 200
        eviction-policy: LRU

and in my application.yml :

spring:
  hazelcast:
    config: classpath:hazelcast.yml

Now when i run a docker container with the app jar, i want to create a hazelcast-prod.yml that contain member-list for this env (prod) that override the hazlecast.yml conf in the jar.

in my container i create hazelcast-prod.yml :

hazelcast:
  cluster-name: SAV5
  network:
      tcp-ip:
        enabled: true
        member-list:
          - ip-server-1:5701
          - ip-server-2:5701

and a application-prod.properties :

spring.hazelcast.config=file:/config/hazelcast.yml

The problem is when i start the app, hazelcast take the default conf with the local ip and not the one that i create with the different servers addresses :

INFO  [c.h.h.HazelcastCacheRegionFactory] [] [] - Starting up HazelcastCacheRegionFactory
INFO  [c.h.i.c.AbstractConfigLocator] [] [] - Loading 'hazelcast-default.xml' from the classpath.

How can i define different conf for each environment ?

Thank you

INFO  [c.h.i.AddressPicker] [] [] - [LOCAL] [access-cache] [5.5.0] Interfaces is disabled, trying to pick one address from TCP-IP config addresses: [127.0.0.1]
INFO  [c.h.s.logo] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] 
    o    o     o     o---o   o--o o      o---o     o     o----o o--o--o
    |    |    / \       /         |     /         / \    |         |
    o----o       o     o   o----o |    o             o   o----o    |
    |    |  *     \   /           |     \       *     \       |    |
    o    o *       o o---o   o--o o----o o---o *       o o----o    o

INFO  [c.h.system] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved.
INFO  [c.h.system] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] Hazelcast Platform 5.5.0 (20240725) starting at [127.0.0.1]:5701
INFO  [c.h.system] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] Cluster name: sas-access-cache
INFO  [c.h.system] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] Integrity Checker is disabled. Fail-fast on corrupted executables will not be performed. For more information, see the documentation for Integrity Checker.
INFO  [c.h.system] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] The Jet engine is disabled.
To enable the Jet engine on the members, do one of the following:
  - Change member config using Java API: config.getJetConfig().setEnabled(true)
  - Change XML/YAML configuration property: Set hazelcast.jet.enabled to true
  - Add system property: -Dhz.jet.enabled=true (for Hazelcast embedded, works only when loading config via Config.load)
  - Add environment variable: HZ_JET_ENABLED=true (recommended when running container image. For Hazelcast embedded, works only when loading config via Config.load)
INFO  [c.h.s.security] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] Enable DEBUG/FINE log level for log category com.hazelcast.system.security  or use -Dhazelcast.security.recommendations system property to see 🔒 security recommendations and the status of current config.
INFO  [c.h.i.i.Node] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] Using TCP/IP discovery
INFO  [c.h.i.d.Diagnostics] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
INFO  [c.h.c.LifecycleService] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] [127.0.0.1]:5701 is STARTING
INFO  [c.h.i.c.i.TcpIpJoiner] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] [127.0.0.1]:5702 is added to the blacklist.
INFO  [c.h.i.c.ClusterService] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] 

Members {size:1, ver:1} [
    Member [127.0.0.1]:5701 - 49 this
]
INFO  [c.h.c.LifecycleService] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] [127.0.0.1]:5701 is STARTED
INFO  [c.h.i.d.HealthMonitor] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] The HealthMonitor has detected a high load on the system. For more detailed information,
enable Diagnostics by adding the property -Dhazelcast.diagnostics.enabled=true
INFO  [c.h.i.d.HealthMonitor] [] [] - [127.0.0.1]:5701 [access-cache] [5.5.0] processors=12, physical.memory.total=14.9G, physical.memory.free=1.1G, swap.space.total=0, swap.space.free=0, heap.memory.used=47.6M, heap.memory.free=102.9M, heap.memory.total=152.0M, heap.memory.max=3.7G, heap.memory.used/total=31.29%, heap.memory.used/max=1.24%, minor.gc.count=21, minor.gc.time=133ms, major.gc.count=0, major.gc.time=0ms, unknown.gc.count=6, unknown.gc.time=19ms, load.process=0.00%, load.system=80.56%, load.systemAverage=6.77, thread.count=70, thread.peakCount=70, cluster.timeDiff=0, event.q.size=0, executor.q.async.size=0, executor.q.client.size=0, executor.q.client.query.size=0, executor.q.client.blocking.size=0, executor.q.query.size=0, executor.q.scheduled.size=0, executor.q.io.size=0, executor.q.system.size=0, executor.q.operations.size=0, executor.q.priorityOperation.size=0, operations.completed.count=0, executor.q.mapLoad.size=0, executor.q.mapLoadAllKeys.size=0, executor.q.cluster.size=0, executor.q.response.size=0, operations.running.count=0, operations.pending.invocations.percentage=0.00%, operations.pending.invocations.count=0, proxy.count=0, clientEndpoint.count=0, connection.active.count=0, client.connection.count=0, connection.count=0
INFO  [o.h.c.i.RegionFactoryInitiator] [] [] - HHH000025: Second-level cache region factory [com.hazelcast.hibernate.HazelcastCacheRegionFactory]

INFO  [c.h.h.HazelcastCacheRegionFactory] [] [] - Starting up HazelcastCacheRegionFactory
INFO  [c.h.i.c.AbstractConfigLocator] [] [] - Loading 'hazelcast-default.xml' from the classpath.
INFO  [c.h.s.logo] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] 
    o    o     o     o---o   o--o o      o---o     o     o----o o--o--o
    |    |    / \       /         |     /         / \    |         |
    o----o       o     o   o----o |    o             o   o----o    |
    |    |  *     \   /           |     \       *     \       |    |
    o    o *       o o---o   o--o o----o o---o *       o o----o    o

INFO  [c.h.system] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] Copyright (c) 2008-2024, Hazelcast, Inc. All Rights Reserved.
INFO  [c.h.system] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] Hazelcast Platform 5.5.0 (20240725) starting at [172.17.0.2]:5702
INFO  [c.h.system] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] Cluster name: dev
INFO  [c.h.system] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] Integrity Checker is disabled. Fail-fast on corrupted executables will not be performed. For more information, see the documentation for Integrity Checker.
INFO  [c.h.system] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] The Jet engine is disabled.
To enable the Jet engine on the members, do one of the following:
  - Change member config using Java API: config.getJetConfig().setEnabled(true)
  - Change XML/YAML configuration property: Set hazelcast.jet.enabled to true
  - Add system property: -Dhz.jet.enabled=true (for Hazelcast embedded, works only when loading config via Config.load)
  - Add environment variable: HZ_JET_ENABLED=true (recommended when running container image. For Hazelcast embedded, works only when loading config via Config.load)
INFO  [c.h.s.security] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] Enable DEBUG/FINE log level for log category com.hazelcast.system.security  or use -Dhazelcast.security.recommendations system property to see 🔒 security recommendations and the status of current config.
INFO  [c.h.i.i.Node] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] Using Multicast discovery
INFO  [c.h.i.d.Diagnostics] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
INFO  [c.h.c.LifecycleService] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] [172.17.0.2]:5702 is STARTING
INFO  [c.h.i.c.ClusterService] [] [] - [172.17.0.2]:5702 [dev] [5.5.0] 

Upvotes: 0

Views: 25

Answers (0)

Related Questions