@InterfaceAudience.Private public class ServerRpcController extends Object implements com.google.protobuf.RpcController
Service
implementations.
When implementing Service
defined methods,
coprocessor endpoints can use the following pattern to pass exceptions back to the RPC client:
public void myMethod(RpcController controller, MyRequest request,
RpcCallback<MyResponse> done) {
MyResponse response = null;
try {
// do processing
response = MyResponse.getDefaultInstance(); // or use a new builder to populate the response
} catch (IOException ioe) {
// pass exception back up
ResponseConverter.setControllerException(controller, ioe);
}
done.run(response);
}
构造器和说明 |
---|
ServerRpcController() |
限定符和类型 | 方法和说明 |
---|---|
void |
checkFailed()
Throws an IOException back out if one is currently stored.
|
String |
errorText() |
boolean |
failed() |
boolean |
failedOnException()
Returns whether or not a server exception was generated in the prior RPC invocation.
|
IOException |
getFailedOn()
Returns any exception thrown during service method invocation, or
null if no exception
was thrown. |
boolean |
isCanceled() |
void |
notifyOnCancel(com.google.protobuf.RpcCallback<Object> objectRpcCallback) |
void |
reset() |
void |
setFailed(String message) |
void |
setFailedOn(IOException ioe)
Sets an exception to be communicated back to the
Service client. |
void |
startCancel() |
public void reset()
reset
在接口中 com.google.protobuf.RpcController
public boolean failed()
failed
在接口中 com.google.protobuf.RpcController
public String errorText()
errorText
在接口中 com.google.protobuf.RpcController
public void startCancel()
startCancel
在接口中 com.google.protobuf.RpcController
public void setFailed(String message)
setFailed
在接口中 com.google.protobuf.RpcController
public boolean isCanceled()
isCanceled
在接口中 com.google.protobuf.RpcController
public void notifyOnCancel(com.google.protobuf.RpcCallback<Object> objectRpcCallback)
notifyOnCancel
在接口中 com.google.protobuf.RpcController
public void setFailedOn(IOException ioe)
Service
client.ioe
- the exception encountered during execution of the service methodpublic IOException getFailedOn()
null
if no exception
was thrown. This can be used by clients to receive exceptions generated by RPC calls, even
when RpcCallback
s are used and no ServiceException
is
declared.public boolean failedOnException()
public void checkFailed() throws IOException
IOException
Copyright © 2007–2018 The Apache Software Foundation. All rights reserved.