spring-boothazelcasthazelcast-cloud

HazelcastException: CP Subsystem is not enabled


while doing hazelcast migration from 3.12.13 to 5.1.6 version facing issue anyone know how this could be fixed let me know.

import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.cp.ISemaphore;

public class HazelcastSemaphore implements MetaSemaphore {

    private HazelcastInstance hazelcastInstance;

    public boolean init(int permits) {

        if(semaphore == null){
            hz1.getCPSubsystem().getSemaphore(id);
            semaphore.init(permits);
        }
        return true;
    }
}

Facing error

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.services.config.ConfigService]: Factory method 'configService' threw exception; nested exception is com.hazelcast.core.HazelcastException: CP Subsystem is not enabled!


Solution

  • You have to enable CP subsystem.

    XML sample

    <hazelcast>
      <cp-subsystem>
       <!-- set cp-member-count with value 0 to run in unsafe mode -->
        <cp-member-count>3</cp-member-count>
        <!-- configuration options here -->
      </cp-subsystem>
    </hazelcast>
    

    Read more here: https://docs.hazelcast.com/hazelcast/5.3/cp-subsystem/configuration