本文整理汇总了Java中com.netflix.astyanax.MutationBatch.setConsistencyLevel方法的典型用法代码示例。如果您正苦于以下问题:Java MutationBatch.setConsistencyLevel方法的具体用法?Java MutationBatch.setConsistencyLevel怎么用?Java MutationBatch.setConsistencyLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.netflix.astyanax.MutationBatch
的用法示例。
在下文中一共展示了MutationBatch.setConsistencyLevel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doWriteContent
import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
protected void doWriteContent(Content content, @Nullable Content previous) {
try {
long id = content.getId().longValue();
MutationBatch batch = keyspace.prepareMutationBatch();
batch.setConsistencyLevel(writeConsistency);
marshaller.marshallInto(
content.getId(),
batch.withRow(mainCf, id),
content,
java.util.Optional.ofNullable(previous),
true
);
batch.mergeShallow(aliasIndex.mutateAliases(content, previous));
batch.execute();
log.trace("Written content id " + id);
} catch (Exception e) {
throw new CassandraPersistenceException(content.toString(), e);
}
}
示例2: doWrite
import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
protected void doWrite(Topic topic, @Nullable Topic previous) {
//Allow migration of owl content that has changed source
//checkArgument(previous == null || topic.getSource().equals(previous.getSource()));
try {
long id = topic.getId().longValue();
MutationBatch batch = keyspace.prepareMutationBatch();
batch.setConsistencyLevel(writeConsistency);
batch.withRow(mainCf, id)
.putColumn(valueColumn, topicSerializer.serialize(topic));
batch.mergeShallow(aliasIndex.mutateAliases(topic, previous));
batch.execute();
} catch (Exception e) {
throw new CassandraPersistenceException(topic.toString(), e);
}
}
示例3: atomicIncrement
import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
public Deferred<Long> atomicIncrement(final AtomicIncrementRequest request) {
num_atomic_increments.incrementAndGet();
if (Bytes.memcmp(tsdb_uid_table, request.table) != 0) {
return Deferred.fromError(new UnsupportedOperationException(
"Increments are not supported on other tables yet"));
}
final Keyspace keyspace = getContext(request.table);
ColumnPrefixDistributedRowLock<byte[]> lock =
new ColumnPrefixDistributedRowLock<byte[]>(keyspace,
TSDB_UID_ID_CAS, request.key)
.withBackoff(new BoundedExponentialBackoff(250, 10000, 10))
.expireLockAfter(lock_timeout, TimeUnit.MILLISECONDS);
try {
num_row_locks.incrementAndGet();
final ColumnMap<String> columns = lock.acquireLockAndReadRow();
// Modify a value and add it to a batch mutation
final String qualifier = new String(request.qualifier());
long value = 1;
if (columns.get(qualifier) != null) {
value = columns.get(qualifier).getLongValue() + 1;
}
final MutationBatch mutation = keyspace.prepareMutationBatch();
mutation.setConsistencyLevel(ConsistencyLevel.CL_EACH_QUORUM);
mutation.withRow(TSDB_UID_ID_CAS, request.key)
.putColumn(qualifier, value, null);
lock.releaseWithMutation(mutation);
return Deferred.fromResult(value);
} catch (Exception e) {
try {
lock.release();
} catch (Exception e1) {
LOG.error("Error releasing lock post exception for request: " + request, e1);
}
return Deferred.fromError(e);
}
}
示例4: writeContainerSummary
import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
protected void writeContainerSummary(ContainerSummary summary, Iterable<ItemRef> items) {
MutationBatch batch = keyspace.prepareMutationBatch();
batch.setConsistencyLevel(writeConsistency);
for (ItemRef itemRef : items) {
Item item = itemFromRef(itemRef);
item.setContainerSummary(summary);
ColumnListMutation<String> itemMutation = batch.withRow(
mainCf,
itemRef.getId().longValue()
);
marshaller.marshallInto(
itemRef.getId(),
itemMutation,
item,
java.util.Optional.empty(),
false
);
}
try {
batch.execute();
} catch (ConnectionException | RuntimeException e) {
Throwables.propagate(e);
}
}
示例5: removeAllReferencesToItem
import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
@Override
protected void removeAllReferencesToItem(ContainerRef containerRef, ItemRef itemRef) {
MutationBatch batch = keyspace.prepareMutationBatch();
batch.setConsistencyLevel(writeConsistency);
removeAllReferencesToItem(containerRef, itemRef, batch);
try {
batch.execute();
} catch (ConnectionException e) {
Throwables.propagate(e);
}
}
示例6: removeItemRefsFromContainers
import com.netflix.astyanax.MutationBatch; //导入方法依赖的package包/类
private void removeItemRefsFromContainers(Item item) throws ConnectionException {
MutationBatch batch = keyspace.prepareMutationBatch();
batch.setConsistencyLevel(writeConsistency);
if (item.getContainerRef() != null) {
removeAllReferencesToItem(item.getContainerRef(), item.toRef(), batch);
}
if (item instanceof Episode && ((Episode) item).getSeriesRef() != null) {
Episode episode = (Episode) item;
removeAllReferencesToItem(episode.getSeriesRef(), episode.toRef(), batch);
}
batch.execute();
}