本文整理汇总了Java中com.google.common.util.concurrent.Futures.makeChecked方法的典型用法代码示例。如果您正苦于以下问题:Java Futures.makeChecked方法的具体用法?Java Futures.makeChecked怎么用?Java Futures.makeChecked使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.util.concurrent.Futures
的用法示例。
在下文中一共展示了Futures.makeChecked方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: read
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
checkState(root != null, "A modify operation (put, merge or delete) must be performed prior to a read operation");
final SettableFuture<Optional<NormalizedNode<?, ?>>> readResult = SettableFuture.create();
final Queue<Modification> currentHistory = Lists.newLinkedList(modificationHistoryMap.get(store));
Futures.addCallback(initialReadMap.get(store), new FutureCallback<Optional<NormalizedNode<?, ?>>>() {
@Override
public void onSuccess(@Nullable final Optional<NormalizedNode<?, ?>> result) {
final DataTreeModification mod = snapshotMap.get(store).newModification();
if (result.isPresent()) {
mod.write(path, result.get());
}
applyModificationHistoryToSnapshot(mod, currentHistory);
readResult.set(mod.readNode(path));
}
@Override
public void onFailure(final Throwable t) {
readResult.setException(t);
}
}, MoreExecutors.directExecutor());
return Futures.makeChecked(readResult, ReadFailedException.MAPPER);
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:26,代码来源:ShardedDOMDataBrokerDelegatingReadWriteTransaction.java
示例2: getSource
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<YangTextSchemaSource, SchemaSourceException> getSource(SourceIdentifier sourceIdentifier) {
LOG.trace("Getting yang schema source for {}", sourceIdentifier.getName());
Future<YangTextSchemaSourceSerializationProxy> result = remoteRepo.getYangTextSchemaSource(sourceIdentifier);
final SettableFuture<YangTextSchemaSource> res = SettableFuture.create();
result.onComplete(new OnComplete<YangTextSchemaSourceSerializationProxy>() {
@Override
public void onComplete(Throwable throwable,
YangTextSchemaSourceSerializationProxy yangTextSchemaSourceSerializationProxy) {
if (yangTextSchemaSourceSerializationProxy != null) {
res.set(yangTextSchemaSourceSerializationProxy.getRepresentation());
}
if (throwable != null) {
res.setException(throwable);
}
}
}, executionContext);
return Futures.makeChecked(res, MAPPER);
}
示例3: executeAsync
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
public <T> CheckedFuture<T, UserException> executeAsync(final ElasticAction2<T> action){
final ContextListenerImpl listener = new ContextListenerImpl();
// need to cast to jersey since the core javax.ws.rs Invocation doesn't support a typed submission.
final JerseyInvocation invocation = (JerseyInvocation) action.buildRequest(target, listener);
final SettableFuture<T> future = SettableFuture.create();
invocation.submit(new GenericType<T>(action.getResponseClass()), new AsyncCallback<T>(future));
return Futures.makeChecked(future, new Function<Exception, UserException>(){
@Override
public UserException apply(Exception input) {
if(input instanceof ExecutionException){
input = (Exception) input.getCause();
}
return handleException(input, action, listener);
}});
}
示例4: exists
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
checkState(root != null, "A modify operation (put, merge or delete) must be performed prior to an exists operation");
return Futures.makeChecked(Futures.transform(read(store, path),
(Function<Optional<NormalizedNode<?, ?>>, Boolean>) Optional::isPresent),
ReadFailedException.MAPPER);
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:ShardedDOMDataBrokerDelegatingReadWriteTransaction.java
示例5: read
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
return Futures.makeChecked(delegateTx.read(LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType(store), path), ReadFailedException.MAPPER);
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:6,代码来源:ShardedDOMDataBrokerDelegatingReadTransaction.java
示例6: exists
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
return Futures.makeChecked(delegateTx.exists(LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType(store), path), ReadFailedException.MAPPER);
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:ShardedDOMDataBrokerDelegatingReadTransaction.java
示例7: submit
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Void, TransactionCommitFailedException> submit() {
return Futures.makeChecked(delegateTx.submit(), TransactionCommitFailedExceptionMapper.COMMIT_ERROR_MAPPER);
}
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:5,代码来源:ShardedDOMDataBrokerDelegatingWriteTransaction.java
示例8: read
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
return Futures.makeChecked(delegate().read(path), ReadFailedException.MAPPER);
}
示例9: exists
import com.google.common.util.concurrent.Futures; //导入方法依赖的package包/类
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
return Futures.makeChecked(delegate().exists(path), ReadFailedException.MAPPER);
}