我有一个批量工作,写大约30万行到卡桑德拉。我把它们分成小批,每批50行。
下面是伪代码。
@Override
public void executeQuery(List<BatchStatement> batches) {
List<ResultSetFuture> futures = List.of();
for (BatchStatement batch: batches) {
futures.add(session.executeAsync(batch));
}
for(ResultSetFuture rsf: futures) {
rsf.getUninterruptibly();
/* I have to add the following code to avoid WriteTimeoutException
try {
Thread.sleep(100);
} catch (InterruptedException e) {
logger.error("Thread.sleep", e);
}
*/
}
}
我不知道没有thread.sleep为什么会出现writetimeout异常。如何避免这种情况?