gpt4 book ai didi

java - PoolingOptions 和 Cassandra - java

转载 作者:行者123 更新时间:2023-12-02 12:02:50 24 4
gpt4 key购买 nike

我正在使用 datastax 驱动程序将 Cassandra 用作 Apache Flink 的某些数据流的接收器:我在执行应用程序时遇到问题,在运行时引发有关队列在几秒钟后变满的错误。我发现默认值是 256,这对于我的负载来说可能太低,因此我使用 poolingOptions 设置 maxRequestsPerConnection 来提高它,如下所示:http://docs.datastax.com/en/developer/java-driver/3.1/manual/pooling/ .

不幸的是,使用以下代码时,我在启动它时收到以下错误:

The implementation of the ClusterBuilder is not serializable. 
The object probably contains or references non serializable fields.

我的代码:

PoolingOptions poolingOptions = new PoolingOptions();
poolingOptions
.setMaxRequestsPerConnection(HostDistance.LOCAL, 32768)
.setMaxRequestsPerConnection(HostDistance.REMOTE, 10000);


ClusterBuilder cassandraBuilder = new ClusterBuilder() {

@Override
public Cluster buildCluster(Cluster.Builder builder) {
return builder.addContactPoint(CASSANDRA_ADDRESS)
.withPort(CASSANDRA_PORT)
.withPoolingOptions(poolingOptions)
.build();
}
};

sinkBuilderNormalStream
.setQuery("INSERT INTO keyspace_local.values_by_sensors_users"
+ " (user, sensor, timestamp, rdf_stream, observed_value, value)"
+ " VALUES (?, ?, ?, ?, ?, ?);")
.setClusterBuilder(cassandraBuilder)
.build();

我该如何处理?

最佳答案

您必须在 ClusterBuilder#buildCluster 中定义 PoolingOptions。

关于java - PoolingOptions 和 Cassandra - java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47124495/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com