From c85cc9fe7a331cfa51e106ab1426a41356a7fafb Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Sat, 29 Jul 2023 02:34:20 +0200 Subject: [PATCH] IDEMPIERE-5816 Upgrade Hazelcast version (FHCA-4436) (#1955) * IDEMPIERE-5816 Upgrade Hazelcast version (FHCA-4436) * - fix on discovery of service using UUID --- .../hazelcast-template.xml | 422 ++++++++++++------ org.idempiere.hazelcast.service/pom.xml | 4 +- .../hazelcast/service/Activator.java | 6 +- .../service/CacheConsoleProvider.java | 8 +- .../hazelcast/service/CacheServiceImpl.java | 2 +- .../hazelcast/service/ClusterMember.java | 5 +- .../hazelcast/service/ClusterServiceImpl.java | 10 +- .../hazelcast/service/MessageServiceImpl.java | 2 +- .../hazelcast/service/TopicImpl.java | 13 +- 9 files changed, 317 insertions(+), 155 deletions(-) diff --git a/org.adempiere.server-feature/hazelcast-template.xml b/org.adempiere.server-feature/hazelcast-template.xml index 25f6bf2764..0b25ff8b56 100644 --- a/org.adempiere.server-feature/hazelcast-template.xml +++ b/org.adempiere.server-feature/hazelcast-template.xml @@ -1,6 +1,6 @@ + http://www.hazelcast.com/schema/config/hazelcast-config-5.3.xsd"> + + + @ADEMPIERE_DB_USER@.@ADEMPIERE_DB_NAME@/@ADEMPIERE_DB_SERVER@:@ADEMPIERE_DB_PORT@ - - @ADEMPIERE_DB_USER@.@ADEMPIERE_DB_NAME@/@ADEMPIERE_DB_SERVER@:@ADEMPIERE_DB_PORT@ - - - http://localhost:8080/hazelcast-mancenter - false + 5701 0 + + + + + + 224.2.2.3 + 54327 + + 127.0.0.1 127.0.0.1 + - my-access-key - my-secret-key - - us-west-1 - - ec2.amazonaws.com - - hazelcast-sg - type - hz-nodes + - us-east1-b,us-east1-c + - CLIENT_ID - CLIENT_SECRET - TENANT_ID - SUB_ID - HZLCAST001 - GROUP-NAME + - MY-KUBERNETES-NAMESPACE - MY-SERVICE-NAME - MY-SERVICE-LABEL-NAME - MY-SERVICE-LABEL-VALUE + + true + hazelcast @@ -110,11 +158,45 @@ + 10.10.1.* + + + 0 + 16 + true + + 100 + 1 + 16 + true + + + 100 + 1 + 16 + com.hazelcast.spi.merge.PutIfAbsentMergePolicy + true + true @@ -165,11 +261,27 @@ Number of async backups. 0 means no backup. --> 0 - + -1 com.hazelcast.spi.merge.PutIfAbsentMergePolicy + + + + tiered-store + + 4096 + 4 + 4 + + 1800 - - LRU - - 1000 - - 25 - - 100 + com.hazelcast.spi.merge.PutIfAbsentMergePolicy @@ -258,41 +343,48 @@ ALWAYS: Always cache deserialized values. --> INDEX-ONLY - + + + true + + + false + + + + + + + + + + + + OBJECT true + - - - mapName - 10000 - 0 - - - - cacheName - 10000 - 0 - - - - - mapName - 10 - - 1 SET @@ -316,22 +408,6 @@ com.hazelcast.spi.merge.PutIfAbsentMergePolicy - - 0 - - 0 - 0 - 1000 - true - CANCEL_RUNNING_OPERATION - - - - 0 - 1 - 0 - - 10 BLOCK @@ -348,29 +424,58 @@ + 100 + 600000 - 0 + + 1514764800000 + 0 + + 6 + + 16 + + 15000 + true - - com.hazelcast.spi.merge.PutIfAbsentMergePolicy - - - - com.hazelcast.spi.merge.PutIfAbsentMergePolicy - - - - + 0 - - + @@ -379,13 +484,6 @@ HyperLogLogMergePolicy - - 100 - 1 - 16 - com.hazelcast.spi.merge.PutIfAbsentMergePolicy - - 1000 1 @@ -395,4 +493,68 @@ 2147483647 true + + + + 5 + + + 5 + + + + 0 + false + + + + + 100 + + 1 + + 10000 + + false + + 9223372036854775807 + + + 1024 + + + 16384 + + + 3 + + + diff --git a/org.idempiere.hazelcast.service/pom.xml b/org.idempiere.hazelcast.service/pom.xml index 42d78bdae4..0a601294dc 100644 --- a/org.idempiere.hazelcast.service/pom.xml +++ b/org.idempiere.hazelcast.service/pom.xml @@ -26,12 +26,12 @@ com.hazelcast hazelcast - 3.12.12 + 5.3.1 com.hazelcast hazelcast-aws - 2.4 + 3.4 lib diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java index 6e5e9a0120..efa199a0f9 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/Activator.java @@ -126,7 +126,7 @@ public class Activator implements BundleActivator { hazelcastInstance = Hazelcast.newHazelcastInstance(config); MapConfig mc = config.getMapConfig("default"); if (mc != null) { - logger.info("Hazelcast Max Size Config: "+mc.getMaxSizeConfig().getMaxSizePolicy() + " " + mc.getMaxSizeConfig().getSize()); + logger.info("Hazelcast Max Size Config: "+mc.getEvictionConfig().getMaxSizePolicy() + " " + mc.getEvictionConfig().getSize()); } return; } catch (FileNotFoundException e) {} @@ -142,7 +142,7 @@ public class Activator implements BundleActivator { hazelcastInstance = Hazelcast.newHazelcastInstance(config); MapConfig mc = config.getMapConfig("default"); if (mc != null) { - logger.info("Hazelcast Max Size Config: "+mc.getMaxSizeConfig().getMaxSizePolicy() + " " + mc.getMaxSizeConfig().getSize()); + logger.info("Hazelcast Max Size Config: "+mc.getEvictionConfig().getMaxSizePolicy() + " " + mc.getEvictionConfig().getSize()); } return; } catch (IOException e) {} @@ -154,7 +154,7 @@ public class Activator implements BundleActivator { logger.warning("Starting hazelcast with default configuration"); MapConfig mc = config.getMapConfig("default"); if (mc != null) { - logger.info("Hazelcast Max Size Config: "+mc.getMaxSizeConfig().getMaxSizePolicy() + " " + mc.getMaxSizeConfig().getSize()); + logger.info("Hazelcast Max Size Config: "+mc.getEvictionConfig().getMaxSizePolicy() + " " + mc.getEvictionConfig().getSize()); } } diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheConsoleProvider.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheConsoleProvider.java index 4419aa3eef..de7f6f329e 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheConsoleProvider.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheConsoleProvider.java @@ -6,13 +6,13 @@ import java.util.Set; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; +import com.hazelcast.cluster.Cluster; +import com.hazelcast.cluster.Member; +import com.hazelcast.collection.ISet; import com.hazelcast.collection.impl.set.SetService; -import com.hazelcast.core.Cluster; import com.hazelcast.core.DistributedObject; import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; -import com.hazelcast.core.ISet; -import com.hazelcast.core.Member; +import com.hazelcast.map.IMap; import com.hazelcast.map.impl.MapService; public class CacheConsoleProvider implements CommandProvider { diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java index 29503eb297..165ac2febd 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/CacheServiceImpl.java @@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit; import org.idempiere.distributed.ICacheService; -import com.hazelcast.core.IMap; +import com.hazelcast.map.IMap; /** * @author hengsin diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterMember.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterMember.java index 5aa13effad..0e42e3b5d2 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterMember.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterMember.java @@ -17,7 +17,7 @@ import java.net.InetAddress; import org.idempiere.distributed.IClusterMember; -import com.hazelcast.core.Member; +import com.hazelcast.cluster.Member; /** * @author hengsin @@ -39,9 +39,8 @@ public class ClusterMember implements IClusterMember { this.port = port; } - @SuppressWarnings("deprecation") public ClusterMember(Member member) { - this.id = member.getUuid(); + this.id = member.getUuid().toString(); this.address = member.getSocketAddress().getAddress(); this.port = member.getSocketAddress().getPort(); } diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterServiceImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterServiceImpl.java index 68384d3f7c..ac7371832e 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterServiceImpl.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/ClusterServiceImpl.java @@ -24,11 +24,11 @@ import java.util.concurrent.Future; import org.idempiere.distributed.IClusterMember; import org.idempiere.distributed.IClusterService; +import com.hazelcast.cluster.Member; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.IExecutorService; -import com.hazelcast.core.Member; -import com.hazelcast.instance.HazelcastInstanceImpl; -import com.hazelcast.instance.HazelcastInstanceProxy; +import com.hazelcast.instance.impl.HazelcastInstanceImpl; +import com.hazelcast.instance.impl.HazelcastInstanceProxy; /** * @author hengsin @@ -75,7 +75,7 @@ public class ClusterServiceImpl implements IClusterService { if (instance != null) { Set members = instance.getCluster().getMembers(); for(Member member : members) { - if (member.getUuid().equals(clusterMember.getId())) { + if (member.getUuid().toString().equals(clusterMember.getId())) { IExecutorService service = Activator.getHazelcastInstance().getExecutorService("default"); return service.submitToMember(task, member); } @@ -99,7 +99,7 @@ public class ClusterServiceImpl implements IClusterService { Set members = instance.getCluster().getMembers(); Set selectedMembers = new HashSet(); for(Member member : members) { - if (selectedIds.contains(member.getUuid())) { + if (selectedIds.contains(member.getUuid().toString())) { selectedMembers.add(member); } } diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/MessageServiceImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/MessageServiceImpl.java index 19888efcff..24e9a301c3 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/MessageServiceImpl.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/MessageServiceImpl.java @@ -34,7 +34,7 @@ public class MessageServiceImpl implements IMessageService { public ITopic getTopic(String name) { HazelcastInstance instance = Activator.getHazelcastInstance(); if (instance != null) { - com.hazelcast.core.ITopic topic = instance.getTopic(name); + com.hazelcast.topic.ITopic topic = instance.getTopic(name); return new TopicImpl(topic); } else { return null; diff --git a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java index f2e7c81446..8ba1ba7e82 100644 --- a/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java +++ b/org.idempiere.hazelcast.service/src/org/idempiere/hazelcast/service/TopicImpl.java @@ -17,12 +17,13 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import org.idempiere.distributed.ITopic; import org.idempiere.distributed.ITopicSubscriber; -import com.hazelcast.core.Message; -import com.hazelcast.core.MessageListener; +import com.hazelcast.topic.Message; +import com.hazelcast.topic.MessageListener; /** * @author hengsin @@ -30,7 +31,7 @@ import com.hazelcast.core.MessageListener; */ public class TopicImpl implements ITopic { - private com.hazelcast.core.ITopic topic; + private com.hazelcast.topic.ITopic topic; private List> adapters; private Map, String> registrationMap; @@ -38,7 +39,7 @@ public class TopicImpl implements ITopic { /** * */ - public TopicImpl(com.hazelcast.core.ITopic topic) { + public TopicImpl(com.hazelcast.topic.ITopic topic) { this.topic = topic; adapters = new ArrayList>(); registrationMap = new HashMap<>(); @@ -52,7 +53,7 @@ public class TopicImpl implements ITopic { @Override public void subscribe(final ITopicSubscriber subscriber) { TopicSubscriberAdapter adapter = new TopicSubscriberAdapter(subscriber); - String registrationId = topic.addMessageListener(adapter); + String registrationId = topic.addMessageListener(adapter).toString(); adapters.add(adapter); registrationMap.put(adapter, registrationId); } @@ -64,7 +65,7 @@ public class TopicImpl implements ITopic { if (adapter.subscriber == subscriber) { found = adapter; String registrationId = registrationMap.get(adapter); - if (topic.removeMessageListener(registrationId)) + if (topic.removeMessageListener(UUID.fromString(registrationId))) registrationMap.remove(adapter); break; }