2017-03-09 60 views
0

我們使用Kundera ORM從REST服務連接到Cassandra。在persistence.xml我們指定客戶端查找類作爲ThriftClientFactory如下關於Kundera和Cassandra ThriftClient

<property name="kundera.client.lookup.class" 
       value="com.impetus.client.cassandra.thrift.ThriftClientFactory" /> 

這是連接到卡桑德拉正確的方式或者是有過昆德拉使用CQL任何方式,我們可以連接到卡桑德拉?

回答

0

是的,昆德拉的ThriftClient使用CQL與Cassandra進行通信。此外,確保在使用此客戶端時從應用程序啓用CQL3。

設置CQL3:您可以選擇以下

  • 給出在EntityManagerFactory的任何方法

    HashMap propertyMap = new HashMap(); 
    propertyMap.put(CassandraConstants.CQL_VERSION, CassandraConstants.CQL_VERSION_3_0); 
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu", propertyMap); 
    
  • 在EntityManager的

    EntityManagerFactory emf = Persistence.createEntityManagerFactory("cassandra_pu"); 
    EntityManager em = emf.createEntityManager(); 
    em.setProperty("cql.version", "3.0.0"); 
    
+0

感謝卡思我的迴應。目前我使用com.impetus.client.cassandra.thrift.ThriftClientFactory類作爲「kundera.client.lookup.class」並通過9160的thrift prot來連接。但是在我們的cassandra prod集羣中,9160端口被禁用並獲得了指令使用9042的CQL3端口。那麼,我應該使用哪個類來查找kundera客戶端?建議使用「com.impetus.kundera.client.cassandra.dsdriver.DSClientFactory」嗎? – Raj

+0

@Raj是的,你可以使用'DSClientFactory',但是自動模式生成功能在這種情況下不起作用。如果這不是要求,那麼你可以繼續'com.impetus.kundera.client.cassandra.dsdriver.DSClientFacto ry' –