IDEMPIERE-4331 Do not use Hazelcast Cache Service if it is standalone (#113)
Use normal map if hazelcast is stand alone
This commit is contained in:
parent
aac7d81077
commit
2706026b85
|
@ -109,8 +109,12 @@ public class CacheMgt
|
|||
{
|
||||
ICacheService provider = Service.locator().locate(ICacheService.class).getService();
|
||||
if (provider != null)
|
||||
{
|
||||
IClusterService clusterService = Service.locator().locate(IClusterService.class).getService();
|
||||
if (clusterService != null && !clusterService.isStandAlone())
|
||||
map = provider.getMap(name);
|
||||
}
|
||||
}
|
||||
|
||||
if (map == null)
|
||||
{
|
||||
|
|
|
@ -38,4 +38,12 @@ public interface IClusterService {
|
|||
* @return Map of IClusterMember and Future
|
||||
*/
|
||||
public <V> Map<IClusterMember, Future<V>> execute(Callable<V> task, Collection<IClusterMember> members);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if instance is stand alone
|
||||
*/
|
||||
public default boolean isStandAlone() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue