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