我正在尝试让 Orient DB 运行嵌入式和分布式。现在,如果 hazelcast 插件处于活动状态,每当我打开本地数据库时,我都会面临 StackOverflowError。当我关闭 hazelcast 插件时,一切都很好。
OrientDB 陷入了这个循环:
at com.orientechnologies.orient.server.distributed.ODistributedAbstractPlugin.onOpen(ODistributedAbstractPlugin.java:141)
at com.orientechnologies.orient.core.db.raw.ODatabaseRaw.open(ODatabaseRaw.java:107)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:49)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.open(ODatabaseRecordAbstract.java:118)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:49)
at com.orientechnologies.orient.server.OServer.openDatabase(OServer.java:657)
at com.orientechnologies.orient.server.distributed.conflict.ODefaultReplicationConflictResolver.startup(ODefaultReplicationConflictResolver.java:74)
at com.orientechnologies.orient.server.distributed.OStorageSynchronizer.<init>(OStorageSynchronizer.java:56)
at com.orientechnologies.orient.server.distributed.ODistributedAbstractPlugin.getDatabaseSynchronizer(ODistributedAbstractPlugin.java:197)
at com.orientechnologies.orient.server.distributed.ODistributedAbstractPlugin.onOpen(ODistributedAbstractPlugin.java:141)
at com.orientechnologies.orient.core.db.raw.ODatabaseRaw.open(ODatabaseRaw.java:107)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:49)
at com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.open(ODatabaseRecordAbstract.java:118)
at com.orientechnologies.orient.core.db.ODatabaseWrapperAbstract.open(ODatabaseWrapperAbstract.java:49)
at com.orientechnologies.orient.server.OServer.openDatabase(OServer.java:657)
at com.orientechnologies.orient.server.distributed.conflict.ODefaultReplicationConflictResolver.startup(ODefaultReplicationConflictResolver.java:74)
at com.orientechnologies.orient.server.distributed.OStorageSynchronizer.<init>(OStorageSynchronizer.java:56)
at com.orientechnologies.orient.server.distributed.ODistributedAbstractPlugin.getDatabaseSynchronizer(ODistributedAbstractPlugin.java:197)
at com.orientechnologies.orient.server.distributed.ODistributedAbstractPlugin.onOpen(ODistributedAbstractPlugin.java:141)
ODatabaseRaw.open 有一个侦听器列表,当 Hazelcast 处于活动状态时,插件被注册为侦听器,并且在每次方法运行时都会被调用。
有人有什么想法吗?
编辑:我有点让它工作,我从 github 获取了分布式配置。当我删除以下行时,它可以工作:
<parameter name="conflict.resolver.impl" value="com.orientechnologies.orient.server.distributed.conflict.ODefaultReplicationConflictResolver" />
不过,我不确定这是否是一个很好的解决方案,所以请随时指出更好的解决方案 =)
我的完整配置如下所示:db.config:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<orient-server>
<network>
<protocols>
<protocol name="binary" implementation="com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary"/>
<protocol name="http" implementation="com.orientechnologies.orient.server.network.protocol.http.ONetworkProtocolHttpDb"/>
</protocols>
<listeners>
<listener ip-address="0.0.0.0" port-range="2480-2490" protocol="http"/>
</listeners>
</network>
<users>
<user name="root" password="ThisIsA_TEST" resources="*"/>
</users>
<properties>
<entry name="server.cache.staticResources" value="false"/>
<entry name="server.database.path" value="."/>
<entry name="log.console.level" value="info"/> <entry name="log.file.level" value="fine"/>
</properties>
<handlers>
<handler class="com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin">
<parameters>
<!-- <parameter name="alias" value="europe1" /> -->
<parameter name="enabled" value="true" />
<parameter name="configuration.db.default" value="src/main/resources/default-distributed-db-config.json" />
<parameter name="configuration.hazelcast" value="src/main/resources/hazelcast.xml" />
<parameter name="alignment.startup" value="true" />
<parameter name="alignment.timer" value="120000" />
</parameters>
</handler>
</handlers>
</orient-server>
default-distributed-db-config.json (github 上的示例中缺少“}”):
{
"synchronization" : true,
"clusters" : {
"internal" : { "synchronization" : false },
"ODistributedConflict" : { "synchronization" : false },
"*" : {
"synchronization" : true,
"master" : "$auto",
"synch-replicas" : 0,
"asynch-replicas" : "100%" },
"index" : { "synchronization" : false }
}
}
hazelcast.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-basic.xsd"
xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>orientdb</name>
<password>orientdb</password>
</group>
<network>
<port auto-increment="true">5701</port>
<join>
<multicast enabled="false">
<multicast-group>224.2.2.3</multicast-group>
<multicast-port>54327</multicast-port>
</multicast>
<tcp-ip enabled="true">
<interface>127.0.0.1</interface>
</tcp-ip>
</join>
</network>
</hazelcast>
编辑2:
当两个实例尝试同步时出现另一个 StackOverflowError:
java.lang.StackOverflowError
-> com.hazelcast.core.DistributedTask.get(DistributedTask.java:126)
-> com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin$1.done(OHazelcastPlugin.java:204)
-> com.hazelcast.impl.ExecutorManager$3.run(ExecutorManager.java:355)
-> com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorImpl$ExecutionSegment.run(ParallelExecutorService.java:212)
-> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
-> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
-> java.lang.Thread.run(Thread.java:722)
-> com.hazelcast.impl.ExecutorThreadFactory$1.run(ExecutorThreadFactory.java:38)
null
-> com.hazelcast.core.DistributedTask.get(DistributedTask.java:126)
-> com.orientechnologies.orient.server.hazelcast.OHazelcastPlugin$1.done(OHazelcastPlugin.java:204)
-> com.hazelcast.impl.ExecutorManager$3.run(ExecutorManager.java:355)
-> com.hazelcast.impl.executor.ParallelExecutorService$ParallelExecutorImpl$ExecutionSegment.run(ParallelExecutorService.java:212)
-> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
-> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
-> java.lang.Thread.run(Thread.java:722)
-> com.hazelcast.impl.ExecutorThreadFactory$1.run(ExecutorThreadFactory.java:38)
在运行分布式和嵌入式时似乎还不是很稳定。可惜了,一直很喜欢。。。