本文整理汇总了Java中com.google.common.util.concurrent.Futures.immediateCheckedFuture方法的典型用法代码示例。如果您正苦于以下问题:Java Futures.immediateCheckedFuture方法的具体用法?Java Futures.immediateCheckedFuture怎么用?Java Futures.immediateCheckedFuture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.util.concurrent.Futures
的用法示例。
在下文中一共展示了Futures.immediateCheckedFuture方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: submit
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public synchronized CheckedFuture<Void, TransactionCommitFailedException> submit() {
Preconditions.checkState(!closed, "Transaction %s is already closed", identifier);
final Set<DOMStoreWriteTransaction> txns = ImmutableSet.copyOf(idToTransaction.values());
final List<DOMStoreThreePhaseCommitCohort> cohorts = new ArrayList<>(txns.size());
for (DOMStoreWriteTransaction tx : txns) {
cohorts.add(tx.ready());
}
try {
return Futures.immediateCheckedFuture(new CommitCoordinationTask(this, cohorts, null).call());
} catch (TransactionCommitFailedException e) {
return Futures.immediateFailedCheckedFuture(e);
}
}
示例2: submit
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
protected CheckedFuture<Void, TransactionCommitFailedException> submit(final DOMDataWriteTransaction transaction,
final Collection<DOMStoreThreePhaseCommitCohort> cohorts) {
Preconditions.checkArgument(transaction != null, "Transaction must not be null.");
Preconditions.checkArgument(cohorts != null, "Cohorts must not be null.");
LOG.debug("Tx: {} is submitted for execution.", transaction.getIdentifier());
if (cohorts.isEmpty()) {
return Futures.immediateCheckedFuture(null);
}
final AsyncNotifyingSettableFuture clientSubmitFuture =
new AsyncNotifyingSettableFuture(clientFutureCallbackExecutor);
doCanCommit(clientSubmitFuture, transaction, cohorts);
return MappingCheckedFuture.create(clientSubmitFuture, COMMIT_ERROR_MAPPER);
}
示例3: read
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
final DataTreeSnapshot snapshot = stableSnapshot;
if (snapshot == null) {
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed"));
}
try {
return Futures.immediateCheckedFuture(snapshot.readNode(path));
} catch (Exception e) {
LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed",e));
}
}
示例4: read
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Read: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
final Optional<NormalizedNode<?, ?>> result;
try {
result = readSnapshotNode(path);
} catch (Exception e) {
LOG.error("Tx: {} Failed Read of {}", getIdentifier(), path, e);
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Read failed", e));
}
if (result == null) {
return Futures.immediateFailedCheckedFuture(new ReadFailedException("Transaction is closed"));
} else {
return Futures.immediateCheckedFuture(result);
}
}
示例5: invokeRpc
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode<?, ?> input) {
LOG.debug("get-singleton-constant invoked, current value: {}", constant);
final LeafNode<Object> value = ImmutableLeafNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(CONSTANT))
.withValue(constant)
.build();
final ContainerNode result = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(OUTPUT))
.withChild(value)
.build();
return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
}
示例6: invokeRpc
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final DOMRpcIdentifier rpc,
@Nullable final NormalizedNode<?, ?> input) {
LOG.debug("get-contexted-constant invoked, current value: {}", constant);
final LeafNode<Object> value = ImmutableLeafNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONSTANT))
.withValue(constant)
.build();
final ContainerNode result = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(OUTPUT))
.withChild(value)
.build();
return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
}
示例7: invokeRpc
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Nonnull
@Override
public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final DOMRpcIdentifier rpc,
@Nullable final NormalizedNode<?, ?> input) {
LOG.debug("get-constant invoked, current value: {}", constant);
final LeafNode<Object> value = ImmutableLeafNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(CONSTANT))
.withValue(constant)
.build();
final ContainerNode result = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(OUTPUT))
.withChild(value)
.build();
return Futures.immediateCheckedFuture(new DefaultDOMRpcResult(result));
}
示例8: exists
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
LOG.debug("Tx: {} Exists: {}", getIdentifier(), path);
checkNotNull(path, "Path must not be null.");
try {
return Futures.immediateCheckedFuture(read(path).checkedGet().isPresent());
} catch (ReadFailedException e) {
return Futures.immediateFailedCheckedFuture(e);
}
}
示例9: exists
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
try {
return Futures.immediateCheckedFuture(
read(path).checkedGet().isPresent());
} catch (ReadFailedException e) {
return Futures.immediateFailedCheckedFuture(e);
}
}
示例10: doExists
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
final CheckedFuture<Boolean, ReadFailedException> doExists(final YangInstanceIdentifier path) {
return Futures.immediateCheckedFuture(readOnlyView().readNode(path).isPresent());
}
示例11: doRead
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> doRead(final YangInstanceIdentifier path) {
return Futures.immediateCheckedFuture(readOnlyView().readNode(path));
}