本文整理匯總了Java中com.datastax.driver.core.BatchStatement.setDefaultTimestamp方法的典型用法代碼示例。如果您正苦於以下問題:Java BatchStatement.setDefaultTimestamp方法的具體用法?Java BatchStatement.setDefaultTimestamp怎麽用?Java BatchStatement.setDefaultTimestamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.datastax.driver.core.BatchStatement
的用法示例。
在下文中一共展示了BatchStatement.setDefaultTimestamp方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: flushBatch
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
private void flushBatch(BatchStatement batch, long timestamp) {
if(batch==null){
return;
}
batch.setDefaultTimestamp(timestamp);
List<Row> rows = cassandraSession.execute(batch).all();
for (Row row : rows) {
if(!row.getBool("[applied]")) {
LockedBatch lb = lockedBatches.values().iterator().next();
LOG.log(Level.FINE, "flushBatch optimistic locking exception, version: "+ lb.getVersion());
throw new OptimisticLockingException("Process instance was updated by another transaction concurrently.");
}
}
}
示例2: handle
import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
@Subscribe
public void handle(YouTubeVideoAdded youTubeVideoAdded) {
LOGGER.debug("Start handling YouTubeVideoAdded");
final UUID userId = UUID.fromString(youTubeVideoAdded.getUserId().getValue());
final UUID videoId = UUID.fromString(youTubeVideoAdded.getVideoId().getValue());
final HashSet<String> tags = Sets.newHashSet(youTubeVideoAdded.getTagsList());
final String name = youTubeVideoAdded.getName();
final String previewImageLocation = youTubeVideoAdded.getPreviewImageLocation();
Date addedDate = Date.from(Instant.ofEpochSecond(youTubeVideoAdded.getAddedDate().getSeconds(), youTubeVideoAdded.getTimestamp().getNanos()));
Date taggedDate = Date.from(Instant.ofEpochSecond(youTubeVideoAdded.getTimestamp().getSeconds(), youTubeVideoAdded.getTimestamp().getNanos()));
final BatchStatement batchStatement = new BatchStatement(BatchStatement.Type.LOGGED);
tags.forEach(tag -> {
batchStatement.add(videoByTagManager
.crud()
.insert(new VideoByTag(tag, videoId, userId, name, previewImageLocation, addedDate, taggedDate))
.generateAndGetBoundStatement());
batchStatement.add(tagsByLetterManager
.crud()
.insert(new TagsByLetter(tag.substring(0,1), tag))
.generateAndGetBoundStatement());
});
batchStatement.setDefaultTimestamp(taggedDate.getTime());
FutureUtils.buildCompletableFuture(videoByTagManager.getNativeSession().executeAsync(batchStatement))
.handle((rs, ex) -> {
if (rs != null) {
LOGGER.debug("End handling YouTubeVideoAdded");
}
if (ex != null) {
}
return rs;
});
}