Java Hazelcast TargetNotMemberException:不是成员!目标

Java Hazelcast TargetNotMemberException:不是成员!目标,java,hazelcast,Java,Hazelcast,我看过很多关于acom.hazelcast.spi.exception.TargetNotMemberException的帖子:不是会员!目标: 但在这种情况下该怎么办呢?问题:是否可以捕获异常并执行“hazelCastInstance.shutdown()`” 还可以在“错误节点”中连续看到:“队列中剩余的迁移任务=>1” Hazelcast 3.7群集具有两个节点 完整堆栈跟踪: com.hazelcast.spi.exception.TargetNotMemberException: No

我看过很多关于a
com.hazelcast.spi.exception.TargetNotMemberException的帖子:不是会员!目标:

但在这种情况下该怎么办呢?问题:是否可以捕获异常并执行“hazelCastInstance.shutdown()`”

还可以在“错误节点”中连续看到:“队列中剩余的迁移任务=>1”

Hazelcast 3.7群集具有两个节点

完整堆栈跟踪:

com.hazelcast.spi.exception.TargetNotMemberException: Not Member! target: [machine]:5704, partitionId: 0, operation: com.hazelcast.map.impl.query.QueryPartitionOperation, service: hz:impl:mapService
        at com.hazelcast.spi.impl.operationservice.impl.Invocation.initInvocationTarget(Invocation.java:324)
        at com.hazelcast.spi.impl.operationservice.impl.Invocation.doInvoke(Invocation.java:256)
        at com.hazelcast.spi.impl.operationservice.impl.Invocation.access$300(Invocation.java:94)
        at com.hazelcast.spi.impl.operationservice.impl.Invocation$InvocationRetryTask.run(Invocation.java:530)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
        at java.lang.Thread.run(Thread.java:682)
        at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
        at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)
        at ------ submitted from ------.(Unknown Source)
        at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolve(InvocationFuture.java:111)
        at com.hazelcast.spi.impl.operationservice.impl.InvocationFuture.resolveAndThrow(InvocationFuture.java:74)
        at com.hazelcast.spi.impl.AbstractInvocationFuture.get(AbstractInvocationFuture.java:158)
        at com.hazelcast.map.impl.query.MapQueryEngineImpl.addResultsOfPredicate(MapQueryEngineImpl.java:605)
        at com.hazelcast.map.impl.query.MapQueryEngineImpl.invokeQueryAllPartitions(MapQueryEngineImpl.java:506)
        at com.hazelcast.map.impl.proxy.MapProxyImpl.entrySet(MapProxyImpl.java:633)
        at com.hazelcast.map.impl.proxy.MapProxyImpl.entrySet(MapProxyImpl.java:622)
        at myClass.getAll(MyClass.java:10)

TargetNotMemberException扩展了RetryableHazelcastException,它进一步扩展了HazelcastException,因此您可以捕获HazelcastException然后关闭实例,也可以直接捕获TargetNotMemberException并关闭Hazelcast实例。你可以在课下调查

你可以这样编码

import java.io.PrintWriter;
import java.io.StringWriter;

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastException;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spi.exception.TargetNotMemberException;

public class HazelcastExceptionTest {
    public static void main(String[] args) {
        Config config = new Config("instanceOne");
        HazelcastInstance instanceOne = Hazelcast.newHazelcastInstance(config);

        try {
            testTargetNotMemberException();
        }
        catch (HazelcastException e) {
            StringWriter trace = new StringWriter();
            PrintWriter eTrace = new PrintWriter(trace, true);
            e.printStackTrace(eTrace);
            System.out.println("exception " + trace.toString());
            instanceOne.shutdown();

        }
    }

    public static void testTargetNotMemberException() {
        throw new TargetNotMemberException("TargetNotMemberException");
    }
}

TargetNotMemberException扩展了RetryableHazelcastException,它进一步扩展了HazelcastException,因此您可以捕获HazelcastException然后关闭实例,也可以直接捕获TargetNotMemberException并关闭Hazelcast实例。你可以在课下调查

你可以这样编码

import java.io.PrintWriter;
import java.io.StringWriter;

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastException;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.spi.exception.TargetNotMemberException;

public class HazelcastExceptionTest {
    public static void main(String[] args) {
        Config config = new Config("instanceOne");
        HazelcastInstance instanceOne = Hazelcast.newHazelcastInstance(config);

        try {
            testTargetNotMemberException();
        }
        catch (HazelcastException e) {
            StringWriter trace = new StringWriter();
            PrintWriter eTrace = new PrintWriter(trace, true);
            e.printStackTrace(eTrace);
            System.out.println("exception " + trace.toString());
            instanceOne.shutdown();

        }
    }

    public static void testTargetNotMemberException() {
        throw new TargetNotMemberException("TargetNotMemberException");
    }
}