本文整理匯總了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));
}