Neo4j:无法实例化BatchInserter

时间:2015-09-18 18:44:48

标签: java neo4j spring-data-neo4j

当我尝试创建org.neo4j.unsafe.batchinsert.BatchInserter时遇到以下错误

Caused by: java.lang.IllegalStateException: Misaligned file size 68 for DynamicArrayStore[fileName:neostore.nodestore.db.labels, blockSize:60], expected version length 25
    at org.neo4j.kernel.impl.store.AbstractDynamicStore.verifyFileSizeAndTruncate(AbstractDynamicStore.java:265)
    at org.neo4j.kernel.impl.store.CommonAbstractStore.loadStorage(CommonAbstractStore.java:230)
    at org.neo4j.kernel.impl.store.CommonAbstractStore.<init>(CommonAbstractStore.java:118)
    at org.neo4j.kernel.impl.store.AbstractDynamicStore.<init>(AbstractDynamicStore.java:92)
    at org.neo4j.kernel.impl.store.DynamicArrayStore.<init>(DynamicArrayStore.java:64)
    at org.neo4j.kernel.impl.store.StoreFactory.newNodeStore(StoreFactory.java:328)
    at org.neo4j.kernel.impl.store.StoreFactory.newNodeStore(StoreFactory.java:317)
    at org.neo4j.kernel.impl.store.StoreFactory.newNeoStore(StoreFactory.java:161)
    at org.neo4j.unsafe.batchinsert.BatchInserterImpl.<init>(BatchInserterImpl.java:262)
    at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:87)
    at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:81)
    at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:56)
    at nl.aegon.maintenance.config.MainConfiguration.getBatchInserter(MainConfiguration.java:137)
    at nl.aegon.maintenance.config.MainConfiguration$$EnhancerBySpringCGLIB$$a40c43d.CGLIB$getBatchInserter$6(<generated>)
    at nl.aegon.maintenance.config.MainConfiguration$$EnhancerBySpringCGLIB$$a40c43d$$FastClassBySpringCGLIB$$1b2b386e.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
    at nl.aegon.maintenance.config.MainConfiguration$$EnhancerBySpringCGLIB$$a40c43d.getBatchInserter(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
    ... 62 more

您可以在下面找到我的Java配置类的片段

private static class configurationSettings extends HashMap<String, String> {
    {
      put("dump_configuration", "false");
      put("cache_type", "none");
      put("use_memory_mapped_buffers", "true");
      put("neostore.propertystore.db.index.keys.mapped_memory", "5M");
      put("neostore.propertystore.db.index.mapped_memory", "5M");
      put("neostore.nodestore.db.mapped_memory", "200M");
      put("neostore.relationshipstore.db.mapped_memory", "500M");
      put("neostore.propertystore.db.mapped_memory", "200M");
      put("neostore.propertystore.db.strings.mapped_memory", "200M");
    }
  }

@Bean
  public BatchInserter getBatchInserter() {
    LOG.debug("Initialising a batch inserter with store directory: {}", databaseConnectionProperties.getStoreDirectory());
    return BatchInserters.inserter(databaseConnectionProperties.getStoreDirectory(), new configurationSettings());
  }

要通过此错误的正确配置属性集应该是什么?我正在尝试并行批量导入,每个64 MB的3个文件

我在git hub中提到了以下内容 https://github.com/jexp/batch-import/blob/2.2/sample/batch.properties

以下是来自Neo4j的相关方法,即抛出异常

/**
     * Note: This method runs before the file has been mapped by the page cache, and therefore needs to
     * operate on the store files directly. This method is called by constructors.
     */
@Override
    protected void verifyFileSizeAndTruncate() throws IOException
    {
        int expectedVersionLength = UTF8.encode( buildTypeDescriptorAndVersion( getTypeDescriptor() ) ).length;
        long fileSize = getFileChannel().size();
        if ( (fileSize - expectedVersionLength) % blockSize != 0 )
        {
            setStoreNotOk( new IllegalStateException(
                    "Misaligned file size " + fileSize + " for " + this + ", expected version length " +
                    expectedVersionLength ) );
        }
        if ( getStoreOk() )
        {
            getFileChannel().truncate( fileSize - expectedVersionLength );
        }
    }

我在OSX上使用java 8,SDN4和neo4j 2.2.5。

2 个答案:

答案 0 :(得分:1)

问题可能是您尝试在未完全关闭的现有商店上启动BatchInserter。是吗?

答案 1 :(得分:1)

我发现正常neo4j服务器启动,然后关闭,storeDir修复了此问题。

我认为这是由于未能在之前的运行中调用BatchInserter.shutdown()造成的。