public interface Result extends Serializable
Result.
Known implementations are:
1. AsyncRpcResult, it's a CompletionStage whose underlying value signifies the return value of an RPC call.
2. AppResponse, it inevitably inherits CompletionStage and Future, but you should never treat AppResponse as a type of Future,
instead, it is a normal concrete type.| 限定符和类型 | 方法和说明 |
|---|---|
void |
addAttachments(Map<String,String> map)
Add the specified map to existing attachments in this instance.
|
void |
addObjectAttachments(Map<String,Object> map)
Add the specified map to existing attachments in this instance.
|
Result |
get() |
Result |
get(long timeout,
TimeUnit unit) |
String |
getAttachment(String key)
get attachment by key.
|
String |
getAttachment(String key,
String defaultValue)
get attachment by key with default value.
|
Map<String,String> |
getAttachments()
get attachments.
|
Throwable |
getException()
Get exception.
|
Object |
getObjectAttachment(String key)
get attachment by key.
|
Object |
getObjectAttachment(String key,
Object defaultValue)
get attachment by key with default value.
|
Map<String,Object> |
getObjectAttachments()
get attachments.
|
Object |
getValue()
Get invoke result.
|
boolean |
hasException()
Has exception.
|
Object |
recreate()
Recreate.
|
void |
setAttachment(String key,
Object value) |
void |
setAttachment(String key,
String value) |
void |
setAttachments(Map<String,String> map)
Replace the existing attachments with the specified param.
|
void |
setException(Throwable t) |
void |
setObjectAttachment(String key,
Object value) |
void |
setObjectAttachments(Map<String,Object> map)
Replace the existing attachments with the specified param.
|
void |
setValue(Object value) |
<U> CompletableFuture<U> |
thenApply(Function<Result,? extends U> fn) |
Result |
whenCompleteWithContext(BiConsumer<Result,Throwable> fn)
Add a callback which can be triggered when the RPC call finishes.
|
Object getValue()
void setValue(Object value)
Throwable getException()
void setException(Throwable t)
boolean hasException()
Object recreate() throws Throwable
if (hasException()) {
throw getException();
} else {
return getValue();
}
if - has exception throw it.Throwablevoid addAttachments(Map<String,String> map)
map - void addObjectAttachments(Map<String,Object> map)
map - void setAttachments(Map<String,String> map)
map - void setObjectAttachments(Map<String,Object> map)
map - Object getObjectAttachment(String key)
String getAttachment(String key, String defaultValue)
Object getObjectAttachment(String key, Object defaultValue)
Result whenCompleteWithContext(BiConsumer<Result,Throwable> fn)
Just as the method name implies, this method will guarantee the callback being triggered under the same context as when the call was started,
see implementation in whenCompleteWithContext(BiConsumer)
fn - <U> CompletableFuture<U> thenApply(Function<Result,? extends U> fn)
Result get() throws InterruptedException, ExecutionException
Result get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
Copyright © 2011–2021 The Apache Software Foundation. All rights reserved.