public class DefaultResponseFuture extends Object implements ResponseFuture, Traceable
| Modifier and Type | Field and Description |
|---|---|
protected long |
createTime |
protected Exception |
exception |
protected List<FutureListener> |
listeners |
protected Object |
lock |
protected long |
processTime |
protected Request |
request |
protected Object |
result |
protected Class |
returnType |
protected URL |
serverUrl |
protected FutureState |
state |
protected int |
timeout |
| Constructor and Description |
|---|
DefaultResponseFuture(Request requestObj,
int timeout,
URL serverUrl) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(FutureListener listener)
add future listener , when task is success,failure, timeout, cancel, it will be called
|
boolean |
cancel()
cancle the task
|
protected boolean |
cancel(Exception e) |
protected boolean |
done() |
Map<String,String> |
getAttachments() |
long |
getCreateTime() |
Exception |
getException()
if task is done or cancle, return the exception
|
long |
getProcessTime()
业务处理时间
|
long |
getRequestId()
与 Request 的 requestId 相对应
|
Object |
getRequestObj() |
byte |
getRpcProtocolVersion() |
FutureState |
getState() |
int |
getTimeout() |
TraceableContext |
getTraceableContext() |
Object |
getValue()
if task is success, return the result.
|
boolean |
isCancelled()
task cancelled
|
boolean |
isDone()
task is complete : normal or exception
|
boolean |
isSuccess()
isDone() & normal
|
void |
onFailure(Response response) |
void |
onSuccess(Response response) |
void |
setAttachment(String key,
String value) |
void |
setProcessTime(long time)
业务处理时间
|
void |
setReturnType(Class<?> clazz) |
void |
setRpcProtocolVersion(byte rpcProtocolVersion) |
protected final Object lock
protected volatile FutureState state
protected Object result
protected Exception exception
protected long createTime
protected int timeout
protected long processTime
protected Request request
protected List<FutureListener> listeners
protected URL serverUrl
protected Class returnType
public void onSuccess(Response response)
onSuccess in interface ResponseFuturepublic void onFailure(Response response)
onFailure in interface ResponseFuturepublic Object getValue()
Futurepublic Exception getException()
FuturegetException in interface FuturegetException in interface Responsepublic boolean cancel()
Futureprotected boolean cancel(Exception e)
public boolean isCancelled()
FutureisCancelled in interface Futurepublic boolean isDone()
Futurepublic boolean isSuccess()
Futurepublic void addListener(FutureListener listener)
FutureaddListener in interface Futurepublic long getCreateTime()
getCreateTime in interface ResponseFuturepublic void setReturnType(Class<?> clazz)
setReturnType in interface ResponseFuturepublic Object getRequestObj()
public FutureState getState()
protected boolean done()
public long getRequestId()
ResponsegetRequestId in interface Responsepublic long getProcessTime()
ResponsegetProcessTime in interface Responsepublic void setProcessTime(long time)
ResponsesetProcessTime in interface Responsepublic int getTimeout()
getTimeout in interface Responsepublic Map<String,String> getAttachments()
getAttachments in interface Responsepublic void setAttachment(String key, String value)
setAttachment in interface Responsepublic byte getRpcProtocolVersion()
getRpcProtocolVersion in interface Responsepublic void setRpcProtocolVersion(byte rpcProtocolVersion)
setRpcProtocolVersion in interface Responsepublic TraceableContext getTraceableContext()
getTraceableContext in interface TraceableCopyright © 2019. All rights reserved.