本文介绍了带Datastax DS驱动程序连接端口的Kundera的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有Datastax DS Driver的Kundera进行Cassandra连接。
在persistence.xml上,我将端口定义为9042。

I'm using Kundera with Datastax DS Driver for Cassandra connection.On persistence.xml, I defined the port as 9042.

但是,我注意到Kundera无法连接到Cassandra:

However, I noticed that that Kundera failed to connect to Cassandra:

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.503 sec <<< FAILURE! - in com.abc.DataServiceImplTest
writeReadTest(com.abc.DataServiceImplTest)  Time elapsed: 0.38 sec  <<< ERROR!
com.impetus.kundera.configure.schema.SchemaGenerationException: Error while opening socket, Caused by: .
    at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.initiateClient(CassandraSchemaManager.java:718)
    at com.impetus.kundera.configure.schema.api.AbstractSchemaManager.exportSchema(AbstractSchemaManager.java:112)
    at com.impetus.client.cassandra.schemamanager.CassandraSchemaManager.exportSchema(CassandraSchemaManager.java:166)
    at com.impetus.kundera.configure.SchemaConfiguration.configure(SchemaConfiguration.java:191)
    at com.impetus.kundera.configure.ClientMetadataBuilder.buildClientFactoryMetadata(ClientMetadataBuilder.java:48)
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configureClientFactories(EntityManagerFactoryImpl.java:408)
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.configure(EntityManagerFactoryImpl.java:161)
    at com.impetus.kundera.persistence.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:135)
    at com.impetus.kundera.KunderaPersistence.createEntityManagerFactory(KunderaPersistence.java:85)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54)

一旦我在/etc/cassandra/cassandra.yaml中启用了Thrift端口(9160),事情就开始起作用

And once I enabled the Thrift port (9160) at /etc/cassandra/cassandra.yaml, things start working.

这是persistence.xml:

Here's the persistence.xml:

  <persistence-unit name="cassandra_pu">
<provider>com.impetus.kundera.KunderaPersistence</provider>
<class>com.abc.Person</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>

<properties>
        <property name="kundera.nodes" value="localhost" />
        <property name="kundera.port" value="9042" />
        <property name="kundera.keyspace" value="testkeyspace" />
  <property name="kundera.ddl.auto.prepare" value="update" />
  <property name="kundera.dialect" value="cassandra" />
       <property name="kundera.client.lookup.class"
            value="com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory" />
  <property name="kundera.annotations.scan.package" value="com.abc.impl"/>
</properties>

想知道即使我使用DS-Driver也需要启用9160吗?

Wonder if I need to enable 9160 even with using DS-Driver?

谢谢!

推荐答案

kundera.ddl.auto.prepare 通过节俭的方式工作,该方式在端口9160上有效,但是您使用的是datastax&提供的 com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory 。正如您在 persistence.xml 中提到的那样,可在端口9042上工作。因此,

kundera.ddl.auto.prepare works via thrift way which works on port 9160 but you are using com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory provided by datastax & works on port 9042 as you have also mentioned in your persistence.xml. So ,

删除此行

<属性名称= kundera.ddl.auto.prepare value =更新 />

从您的 persistence.xml 将解决此问题。

这篇关于带Datastax DS驱动程序连接端口的Kundera的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-09 03:33