Skip to content

Commit

Permalink
feat: added possibility to add attributes to hazelcast members
Browse files Browse the repository at this point in the history
  • Loading branch information
mherwig committed May 13, 2024
1 parent 1178187 commit 98d95b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
@ConfigurationProperties("horizon.cache")
Expand All @@ -21,6 +24,8 @@ public class CacheProperties {

private DeDuplicationProperties deDuplication = new DeDuplicationProperties();

private Map<String, String> attributes = new HashMap<>();

@Getter
@Setter
public static class DeDuplicationProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package de.telekom.eni.pandora.horizon.autoconfigure.cache;

import com.hazelcast.config.Config;
import com.hazelcast.config.MemberAttributeConfig;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spi.properties.ClusterProperty;
Expand Down Expand Up @@ -43,6 +44,10 @@ public HazelcastInstance hazelcastInstance(CacheProperties cacheProperties) {
log.debug("Initialized new hazelcast instance");
var config = new Config();

var attributeConfig = new MemberAttributeConfig();
cacheProperties.getAttributes().forEach(attributeConfig::setAttribute);
config.setMemberAttributeConfig(attributeConfig);

config.setProperty(ClusterProperty.SHUTDOWNHOOK_ENABLED.getName(), "false");
config.setProperty(ClusterProperty.SHUTDOWNHOOK_POLICY.getName(), "GRACEFUL");
config.setInstanceName(DEFAULT_HAZELCAST_INSTANCE_NAME);
Expand Down

0 comments on commit 98d95b5

Please sign in to comment.