Kundera with Datastax DS Driver Connection Port

依然范特西╮ 提交于 2019-12-23 05:14:30

问题


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

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)

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

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>

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

Thanks!


回答1:


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 ,

removing this line

<property name="kundera.ddl.auto.prepare" value="update" />

from your persistence.xml will solve this issue.



来源:https://stackoverflow.com/questions/42374743/kundera-with-datastax-ds-driver-connection-port

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!