当前位置: 首页>>代码示例>>Java>>正文


Java Futures.immediateCheckedFuture方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:17,代码来源:ShardedDOMDataWriteTransaction.java

示例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);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:ConcurrentDOMDataBroker.java

示例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));
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:SnapshotBackedReadTransaction.java

示例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);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:20,代码来源:SnapshotBackedReadWriteTransaction.java

示例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));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:18,代码来源:SingletonGetConstantService.java

示例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));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:RoutedGetConstantService.java

示例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));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:19,代码来源:GetConstantService.java

示例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);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:12,代码来源:SnapshotBackedReadTransaction.java

示例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);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:10,代码来源:SnapshotBackedReadWriteTransaction.java

示例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());
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:LocalProxyTransaction.java

示例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));
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:LocalProxyTransaction.java


注:本文中的com.google.common.util.concurrent.Futures.immediateCheckedFuture方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。