我正在尝试连接到Wso2 ESB&的Cassandra DB. wso2 DSS,在两种方法中都得到了相同的错误.
1)方法1:从WSO2 ESB连接到Cassandra
我们正在尝试从Wso2 ESB 4.9连接Cassandra DB 3.0.3
下面是复制到components / lib文件夹的jar.
(jar listing)
在master-datasource.xml中,添加了配置.
<datasource>
<name>CassandraDB</name>
<description>The datasource used for cassandra</description>
<jndiConfig>
<name>cassandraWSO2DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:cassandra://127.0.0.1:9042/sample</url>(tried with port 9160)
<username>cassandra</username>
<password>cassandra</password>
<driverClassName>org.apache.cassandra.cql.jdbc.CassandraDriver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT COUNT(*) from sample.users</validationQuery>
<validationInterval>30000</validationInterval>
<defaultAutoCommit>true</defaultAutoCommit>
</configuration>
</definition>
</datasource>
2)方法2:从WSO2 DSS连接到Cassandra
我们正在尝试从Wso2 DSS 3.5.0连接Cassandra DB
下面是复制到components / lib文件夹的jar.
创建数据服务并添加下面的数据源是相同的配置:
<config enableOData="false" id="CassandraSampleId">
<property name="url">jdbc:cassandra://127.0.0.1:9042/sample</property>
<property name="driverClassName">org.apache.cassandra.cql.jdbc.CassandraDriver</property>
<query id="SampleQuery" useConfig="CassandraSampleId">
<expression>select * from users</expression>
在上面的配置中,“sample”是在Cassandra中创建的密钥空间.
在这两种情况下,即1和[2]面临同样的错误.你能否建议解决这个问题.
java.sql.SQLNonTransientConnectionException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
at org.wso2.carbon.dataservices.core.description.config.RDBMSConfig.<init>(RDBMSConfig.java:45)
at org.wso2.carbon.dataservices.core.description.config.ConfigFactory.getRDBMSConfig(ConfigFactory.java:92)
at org.wso2.carbon.dataservices.core.description.config.ConfigFactory.createConfig(ConfigFactory.java:60)
at org.wso2.carbon.dataservices.core.DataServiceFactory.createDataService(DataServiceFactory.java:150)
at org.wso2.carbon.dataservices.core.DBDeployer.createDBService(DBDeployer.java:785)
at org.wso2.carbon.dataservices.core.DBDeployer.processService(DBDeployer.java:1139)
at org.wso2.carbon.dataservices.core.DBDeployer.deploy(DBDeployer.java:195)
... 8 more
Caused by: java.sql.SQLNonTransientConnectionException: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:159)
at org.apache.cassandra.cql.jdbc.CassandraDriver.connect(CassandraDriver.java:92)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:278)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635)
at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
at org.wso2.carbon.dataservices.core.description.config.SQLConfig.createConnection(SQLConfig.java:187)
at org.wso2.carbon.dataservices.core.description.config.SQLConfig.createConnection(SQLConfig.java:173)
at org.wso2.carbon.dataservices.core.description.config.SQLConfig.initSQLDataSource(SQLConfig.java:151)
at org.wso2.carbon.dataservices.core.description.config.RDBMSConfig.<init>(RDBMSConfig.java:43)
... 14 more
Caused by: org.apache.thrift.transport.TTransportException: Read a negative frame size (-2080374784)!
at org.apache.thrift.transport.TFramedTransport.readFrame(TFramedTransport.java:133)
at org.apache.thrift.transport.TFramedTransport.read(TFramedTransport.java:101)
at org.apache.thrift.transport.TTransport.readAll(TTransport.java:84)
at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:378)
at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:297)
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:204)
at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:69)
at org.apache.cassandra.thrift.Cassandra$Client.recv_describe_cluster_name(Cassandra.java:1101)
at org.apache.cassandra.thrift.Cassandra$Client.describe_cluster_name(Cassandra.java:1089)
at org.apache.cassandra.cql.jdbc.CassandraConnection.<init>(CassandraConnection.java:130)
最佳答案
<query id="SampleQuery" useConfig="CassandraSampleId">
<expression>select * from users</expression>
<validationQuery>SELECT COUNT(*) from sample.users</validationQuery>
我注意到的第一件事是……在Cassandra中,未绑定的查询不是一个好主意.您应始终使用分区键进行查询.这不会解决您的问题,但您绝对不希望在具有数百万行的生产中执行此操作.
We are trying to connect Cassandra DB 3.0.3 from Wso2 ESB 4.9
<definition type="RDBMS">
<configuration>
<url>jdbc:cassandra://127.0.0.1:9042/sample</url>(tried with port 9160)
org.apache.thrift.transport.TTransportException:
好的,我在这里注意到了几件事.我从来没有使用过WSO2(实际上,我不知道它是什么),但看起来它在这里做了几个(坏的)假设.
>我不知道你对“类型”的选择是什么,但Cassandra肯定不是RDBMS.
>我看到你正在使用JDBC.有很多驱动程序可以与Java中的Cassandra交互. JDBC最初是为关系数据库设计的,并且经过扩充以与Cassandra一起使用.使用DataStax Java驱动程序将获得最大的成功机会,尤其是在运行Cassandra 3.x时.
>我看到它抛出了thrift.transport.TTransportException. Cassandra 3.0.3安装默认情况下禁用thrift(9160)协议.将端口更改为9042是不够的…您需要使用本机二进制协议才能工作.
首先要尝试的是在Cassandra节点内重新启用Thrift.在你的cassandra.yaml中,找到start_rpc属性,并将其设置为true:
start_rpc: true
至少,这将使Thrift在9160上运行,并且您将准备再次尝试连接.但是,我不知道JDBC是否可以与Cassandra 3.x一起使用.如果确实如此,您肯定无法获得所有可用功能.
我在这里看到的最大问题是,你正在尝试使用新版本的Cassandra,而这些技术实际上并不是为了与之交互而设计的.但是尝试在卡桑德拉开始Thrift,看看是否有帮助.如果有的话,它应该让你到下一个问题.