Java: Hazelcast: java.io.EOFException: не может прочитать 4 байта
Для моего веб-приложения у меня есть 2 экземпляра, которые я определил в hazelcast xml. Когда я запускаю один сервер, он запускается правильно, но когда я запускаю второй сервер, я получаю следующую ошибку:
SEVERE: [192.168.1.32]: 5701 [dev] [3.5] java.io.EOFException: Невозможно прочитать 4 байта! 2015-07-31 18:08:49 com.hazelcast.nio.serialization.HazelcastSerializationException: java.io.EOFException: невозможно прочитать 4 байта! 2015-07-31 18:08:49 в com.hazelcast.nio.serialization.SerializationServiceImpl.handleException(SerializationServiceImpl.java:380) 2015-07-31 18:08:49 в com.hazelcast.nio.serialization.SerializationServiceImpl.toObject(SerializationServiceImpl.java:282) 2015-07-31 18:08:49 в com.hazelcast.spi.impl.NodeEngineImpl.toObject(NodeEngineImpl.java:200) 2015-07-31 18:08:49 в com.hazelcast.spi.impl.operationservice.impl.OperationRunnerImpl.run(OperationRunnerImpl.java:294) 2015-07-31 18:08:49 at com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.processPacket(OperationThread.java:142) 2015-07-31 18:08:49 на com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.process(OperationThread.java:115) 2015-07-31 18:08:49 на com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.doRun(OperationThread.java:101) 2015-07-31 18:08:49 в com.hazelcast.spi.impl.operationexecutor.classic.OperationThread.run(OperationThread.java:76) 2015-07-31 18:08:49 Вызвано: java.io.EO FException: невозможно прочитать 4 байта! 2015-07-31 18:08:49 в com.hazelcast.nio.serialization.ByteArrayObjectDataInput.checkAvailable(ByteArrayObjectDataInput.java:543) 2015-07-31 18:08:49 в com.hazelcast.nio.serialization.ByteArrayObjectDataInput.readInt(ByteArrayObjectDataInput.java:255) 2015-07-31 18:08:49 в com.hazelcast.nio.serialization.ByteArrayObjectDataInput.readInt(ByteArrayObjectDataInput.java:249) 2015-07-31 18:08:49 в com.hazelcast.cluster.impl.ConfigCheck.readData(ConfigCheck.java:217) 2015-07-31 18:08:49 в com.hazelcast.cluster.impl.JoinMessage.readData(JoinMessage.java:80) 2015-07-31 18:08:49 в com.hazelcast.cluster.impl.operations.MasterDiscoveryOperation.readInternal(MasterDiscoveryOperation.java:46) 2015-07-31 18:08:49 в com.hazelcast.spi.Operation.readData(Operation.java:451) 2015-07-31 18:08:49 на com.hazelcast.nio.serialization.DataSerializer.read(DataSerializer.java:111) 2015-07-31 18:08:49 на com.hazelcast.nio.serialization.DataSerializer.read(DataSerializer.java:39) 2015-07-31 18:08:49 на ком.hazelcast.nio.serialization.StreamSerializerAdapter.read(StreamSerializerAdapter.java:41) 2015-07-31 18:08:49 в com.hazelcast.nio.serialization.SerializationServiceImpl.toObject(SerializationServiceImpl.java:276) 2015-07-31 18:08:49 ... еще 6
Кто-нибудь может мне помочь? Я не могу ничего найти:(
Вот мой орешник xml:
- no hazelcast.xml if present
-> dev dev-pass http://localhost:8080/mancenter 5701 0 224.2.2.3 54327 192.168.1.67 192.168.1.75 my-access-key my-secret-ключ us-west-1 ec2.amazonaws.com hazelcast- hg-узлы типа sg 10.10.1.* PBEWithMD5AndDES thesalt thepass 19 16 0 0 1
<!--
Number of async backups. 0 means no backup.
-->
<async-backup-count>0</async-backup-count>
<empty-queue-ttl>-1</empty-queue-ttl>
</queue>
<map name="persistent.*">
<!--
Data type that will be used for storing recordMap.
Possible values:
BINARY (default): keys and values will be stored as binary data
OBJECT : values will be stored in their object forms
NATIVE : values will be stored in non-heap region of JVM
-->
<in-memory-format>BINARY</in-memory-format>
<!--
Number of backups. If 1 is set as the backup-count for example,
then all entries of the map will be copied to another JVM for
fail-safety. 0 means no backup.
-->
<backup-count>1</backup-count>
<!--
Number of async backups. 0 means no backup.
-->
<async-backup-count>0</async-backup-count>
<!--
Maximum number of seconds for each entry to stay in the map. Entries that are
older than <time-to-live-seconds> and not updated for <time-to-live-seconds>
will get automatically evicted from the map.
Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
-->
<time-to-live-seconds>0</time-to-live-seconds>
<!--
Maximum number of seconds for each entry to stay idle in the map. Entries that are
idle(not touched) for more than <max-idle-seconds> will get
automatically evicted from the map. Entry is touched if get, put or containsKey is called.
Any integer between 0 and Integer.MAX_VALUE. 0 means infinite. Default is 0.
-->
<max-idle-seconds>0</max-idle-seconds>
<!--
Valid values are:
NONE (no eviction),
LRU (Least Recently Used),
LFU (Least Frequently Used).
NONE is the default.
-->
<eviction-policy>NONE</eviction-policy>
<!--
Maximum size of the map. When max size is reached,
map is evicted based on the policy defined.
Any integer between 0 and Integer.MAX_VALUE. 0 means
Integer.MAX_VALUE. Default is 0.
-->
<max-size policy="PER_NODE">0</max-size>
<!--
When max. size is reached, specified percentage of
the map will be evicted. Any integer between 0 and 100.
If 25 is set for example, 25% of the entries will
get evicted.
-->
<eviction-percentage>25</eviction-percentage>
<!--
Minimum time in milliseconds which should pass before checking
if a partition of this map is evictable or not.
Default value is 100 millis.
-->
<min-eviction-check-millis>100</min-eviction-check-millis>
<!--
While recovering from split-brain (network partitioning),
map entries in the small cluster will merge into the bigger cluster
based on the policy set here. When an entry merge into the
cluster, there might an existing entry with the same key already.
Values of these entries might be different for that same key.
Which value should be set for the key? Conflict is resolved by
the policy set here. Default policy is PutIfAbsentMapMergePolicy
There are built-in merge policies such as
com.hazelcast.map.merge.PassThroughMergePolicy; entry will be overwritten if merging entry exists for the key.
com.hazelcast.map.merge.PutIfAbsentMapMergePolicy ; entry will be added if the merging entry doesn't exist in the cluster.
com.hazelcast.map.merge.HigherHitsMapMergePolicy ; entry with the higher hits wins.
com.hazelcast.map.merge.LatestUpdateMapMergePolicy ; entry with the latest update wins.
-->
<merge-policy>com.hazelcast.map.merge.PutIfAbsentMapMergePolicy</merge-policy>
<map-store enabled="true">
<factory-class-name>com.adeptia.indigo.services.hazelcast.PersistentMapStoreFactory</factory-class-name>
<write-delay-seconds>0</write-delay-seconds>
</map-store>
</map>
<multimap name="default">
<backup-count>1</backup-count>
<value-collection-type>SET</value-collection-type>
</multimap>
<list name="default">
<backup-count>1</backup-count>
</list>
<set name="default">
<backup-count>1</backup-count>
</set>
<jobtracker name="default">
<max-thread-size>0</max-thread-size>
<!-- Queue size 0 means number of partitions * 2 -->
<queue-size>0</queue-size>
<retry-count>0</retry-count>
<chunk-size>1000</chunk-size>
<communicate-stats>true</communicate-stats>
<topology-changed-strategy>CANCEL_RUNNING_OPERATION</topology-changed-strategy>
</jobtracker>
<semaphore name="default">
<initial-permits>0</initial-permits>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
</semaphore>
<reliable-topic name="default">
<read-batch-size>10</read-batch-size>
<topic-overload-policy>BLOCK</topic-overload-policy>
<statistics-enabled>true</statistics-enabled>
</reliable-topic>
<ringbuffer name="default">
<capacity>10000</capacity>
<backup-count>1</backup-count>
<async-backup-count>0</async-backup-count>
<time-to-live-seconds>30</time-to-live-seconds>
<in-memory-format>BINARY</in-memory-format>
</ringbuffer>
<serialization>
<portable-version>0</portable-version>
</serialization>
<services enable-defaults="true"/>
1 ответ
У меня была такая же проблема. Я попытался сохранить следующую структуру данных в Hazelcast, используя переносимые устройства (строка и ячейка - разные переносимые значения):
row {cell {'name': 'cell_0_0', 'value': 'cell_value_0_0'}, cell {'name': 'cell_0_1', 'value': 1}},...
Проблема состоит в том, что для первой ячейки Hazelcast сохраняет для имени поля "значение" тип поля UTF, но во время сохранения второй ячейки Hazelcast извлекает сохраненное определение поля для имени поля "значение", и это был UTF. Таким образом, тип поля - не Int, а UTF, и при чтении сохраненных портативных устройств из карты использовалось readUTF, и это вызвало для меня исключение, поскольку значение сохраненного поля и тип сохраненного поля не соответствуют друг другу.
РЕДАКТИРОВАТЬ: В вашем случае после запуска второго экземпляра хранящиеся объекты обмениваются и, конечно, читать. Возможно, проблема заключается в этом.