【发布时间】:2021-03-19 01:50:48
【问题描述】:
我正在使用 java 的 datastax 驱动程序:
@Dao
public interface MyDao {
@Insert
CompletableFuture<Void> save(MyEntity entity);
...
}
public class MyDaoTests {
@Test
public void myTest() {
...
List<CompletableFuture<Void>> futureList = myEntityList.parallelStream()
.map((myEntity) -> meterDataMapper.myDao().save(myEntity))
.collect(Collectors.toList());
CompletableFuture.allOf(futureList.toArray(CompletableFuture[]::new)).join();
...
}
}
当我执行测试时,我得到这个错误:java.util.concurrent.CompletionException: com.datastax.oss.driver.api.core.NoNodeAvailableException: No node was available to execute the query
有没有办法配置驱动程序/会话以等待可用节点?
更多信息:
- 我的测试规模约为 2500000 个实体 (
myEntityList)。 - 同步插入工作正常,但速度太慢了。
- 我想用datastax-java-driver mapper 解决这个问题,基于注释,尽可能简单。
- 驱动版本:4.9.0
【问题讨论】:
-
好像有一个spring boot的项目,可以分享到github上吗?而且我之前没有节点可用异常并通过配置限制docs.datastax.com/en/developer/java-driver/4.9/manual/core/…解决了你使用它吗?
标签: java cassandra datastax-java-driver