1

我在同一台机器上运行三个 Hazelcast 节点,每个节点都尝试更改 AtomicReference。第一个和第二个节点运行没有问题,第三个节点抛出 HazelcastSerializationException。

Hazelcast 版本:Hazelcast 3.4.2 (20150326 - f6349a4)

有谁知道发生了什么?

    线程“主”com.hazelcast.nio.serialization.HazelcastSerializationException 中的异常:无法写入数据实例!请改用#writeData(ObjectDataOutput out, Data data)。
    在 com.hazelcast.nio.serialization.SerializationServiceImpl.writeObject(SerializationServiceImpl.java:272)
    在 com.hazelcast.nio.serialization.ByteArrayObjectDataOutput.writeObject(ByteArrayObjectDataOutput.java:262)
    在 com.hazelcast.concurrent.atomicreference.operations.AbstractAlterOperation.writeInternal(AbstractAlterOperation.java:61)
    在 com.hazelcast.spi.Operation.writeData(Operation.java:281)
    在 com.hazelcast.nio.serialization.DataSerializer.write(DataSerializer.java:140)
    在 com.hazelcast.nio.serialization.DataSerializer.write(DataSerializer.java:39)
    在 com.hazelcast.nio.serialization.StreamSerializerAdapter.toData(StreamSerializerAdapter.java:51)
    在 com.hazelcast.nio.serialization.SerializationServiceImpl.toData(SerializationServiceImpl.java:222)
    在 com.hazelcast.nio.serialization.SerializationServiceImpl.toData(SerializationServiceImpl.java:203)
    在 com.hazelcast.spi.impl.NodeEngineImpl.toData(NodeEngineImpl.java:180)
    在 com.hazelcast.spi.impl.BasicOperationService.send(BasicOperationService.java:348)
    在 com.hazelcast.spi.impl.BasicInvocation.doInvokeRemote(BasicInvocation.java:288)
    在 com.hazelcast.spi.impl.BasicInvocation.doInvoke(BasicInvocation.java:260)
    在 com.hazelcast.spi.impl.BasicInvocation.invoke(BasicInvocation.java:229)
    在 com.hazelcast.spi.impl.BasicOperationService.invokeOnPartition(BasicOperationService.java:272)
    在 com.hazelcast.concurrent.atomicreference.AtomicReferenceProxy.asyncInvoke(AtomicReferenceProxy.java:56)
    在 com.hazelcast.concurrent.atomicreference.AtomicReferenceProxy.asyncAlterAndGet(AtomicReferenceProxy.java:87)
    在 com.hazelcast.concurrent.atomicreference.AtomicReferenceProxy.alterAndGet(AtomicReferenceProxy.java:78)
    在 com.senior.seguranca.csm.datamart.hazelcast.HazelcastTest.(HazelcastTest.java:18)
    在 com.senior.seguranca.csm.datamart.hazelcast.HazelcastTest.main(HazelcastTest.java:22)

我的代码:

package com.senior.seguranca.csm.datamart.hazelcast;

import com.hazelcast.config.Config;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IAtomicReference;
import com.hazelcast.core.IFunction;

public class HazelcastTest {

    public HazelcastTest() {
        Config config = new Config();
        config.setInstanceName("HAZELCAST_INSTANCE");
        HazelcastInstance hazelcastInstance = Hazelcast.getOrCreateHazelcastInstance(config);

        IAtomicReference<String> atomicReference = hazelcastInstance.getAtomicReference("TEST");
        String item = "A";
        System.out.println("Item: " + atomicReference.alterAndGet(new MyFunction(item)));
    }

    public static void main(String[] args) {
        new HazelcastTest();
    }
}

class MyFunction implements IFunction<String, String> {

    private String newItem;

    public MyFunction(String newItem) {
        this.newItem = newItem;
    }

    @Override
    public String apply(String item) {
        return newItem;
    }
}
4

1 回答 1

0

如果您确定所有三个节点都具有相同的 Hazelcast 版本(请验证这一点,因为我会假设第三个节点由于未知原因具有旧版本)然后请在错误跟踪器中提交问题。

于 2015-05-07T17:49:28.820 回答