首页 > 解决方案 > Hazelcast 实例在访问分布式地图时未激活

问题描述

我正在运行一个在嵌入式模式下使用 Hazelcast的应用程序。在访问缓存时间歇性地看到这个问题,应用程序抛出 Hazelcast instance is not active 错误。

代码文件如下:

public DistributedServiceProvider() {
            
        LOGGER.info("DistributedServiceProvider: " + type);

       if ("hazelcast".equalsIgnoreCase(type)) {
            hazelcastInstance = HazelcastConfig.getInstance();
        } else {
            throw new Exception(NOT_CONFIGURED);
        }
    }

    public IMap getMap(String name) { 
        if (hazelcastInstance != null) {
            return hazelcastInstance.getMap(name);
        }
        throw new RuntimeException(NOT_INITIALIZED);
    }

运行应用程序并执行某些用例时,间歇性地出现以下错误。

An exception has occurred. Method:: compareIRTrackerRedemptions[null, Fri Apr 30 00:00:00 EDT 2021, Mon May 31 00:00:00 EDT 2021, true]
    Root Cause: com.hazelcast.core.HazelcastInstanceNotActiveException: Hazelcast instance is not active!
        at com.hazelcast.instance.impl.HazelcastInstanceProxy.getOriginal(HazelcastInstanceProxy.java:315)
        at com.hazelcast.instance.impl.HazelcastInstanceProxy.getMap(HazelcastInstanceProxy.java:95)
        at deshaw.descap.server.cache.provider.DistributedServiceProvider.getMap(DistributedServiceProvider.java:52)
        at deshaw.descap.server.cache.BasicCache.getData(BasicCache.java:100)
        at deshaw.descap.server.cache.FundCaches$FundCache.get(FundCaches.java:185)

标签: javahazelcast

解决方案


推荐阅读