diff --git a/org.adempiere.base/src/org/compiere/util/CacheMgt.java b/org.adempiere.base/src/org/compiere/util/CacheMgt.java index 8574d4198f..c2671ce25b 100644 --- a/org.adempiere.base/src/org/compiere/util/CacheMgt.java +++ b/org.adempiere.base/src/org/compiere/util/CacheMgt.java @@ -109,7 +109,11 @@ public class CacheMgt { ICacheService provider = Service.locator().locate(ICacheService.class).getService(); if (provider != null) - map = provider.getMap(name); + { + IClusterService clusterService = Service.locator().locate(IClusterService.class).getService(); + if (clusterService != null && !clusterService.isStandAlone()) + map = provider.getMap(name); + } } if (map == null) diff --git a/org.adempiere.base/src/org/idempiere/distributed/IClusterService.java b/org.adempiere.base/src/org/idempiere/distributed/IClusterService.java index b38a9aa357..f58c09adb0 100644 --- a/org.adempiere.base/src/org/idempiere/distributed/IClusterService.java +++ b/org.adempiere.base/src/org/idempiere/distributed/IClusterService.java @@ -38,4 +38,12 @@ public interface IClusterService { * @return Map of IClusterMember and Future */ public Map> execute(Callable task, Collection members); + + /** + * + * @return true if instance is stand alone + */ + public default boolean isStandAlone() { + return false; + } } 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 716312f9e3..68384d3f7c 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 @@ -27,6 +27,8 @@ import org.idempiere.distributed.IClusterService; 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; /** * @author hengsin @@ -114,4 +116,23 @@ public class ClusterServiceImpl implements IClusterService { return null; } + @Override + public boolean isStandAlone() { + HazelcastInstance instance = Activator.getHazelcastInstance(); + if (instance != null) { + if (instance instanceof HazelcastInstanceImpl) { + HazelcastInstanceImpl impl = (HazelcastInstanceImpl) instance; + return impl.node.getJoiner() == null; + } else if (instance instanceof HazelcastInstanceProxy) { + HazelcastInstanceProxy proxy = (HazelcastInstanceProxy) instance; + HazelcastInstanceImpl impl = proxy.getOriginal(); + return impl.node.getJoiner() == null; + } else { + return false; + } + } else { + return true; + } + } + }