use of com.weibo.api.motan.rpc.DefaultResponse in project motan by weibocom.
the class SwitcherFilter method mockDefaultResponse.
/**
* 返回的reponse需要设置exception,这样invocationhandler会在throwException为false时,构建默认值返回
*
* @param request
* @return
*/
private Response mockDefaultResponse(Request request) {
DefaultResponse response = new DefaultResponse(null, request.getRequestId());
response.setException(new MotanServiceException("Request false for switcher is on"));
return response;
}
use of com.weibo.api.motan.rpc.DefaultResponse in project motan by weibocom.
the class ProviderProtectedMessageRouter method reject.
private Response reject(String method, int requestCounter, int totalCounter, int maxThread) {
DefaultResponse response = new DefaultResponse();
MotanServiceException exception = new MotanServiceException("ThreadProtectedRequestRouter reject request: request_counter=" + requestCounter + " total_counter=" + totalCounter + " max_thread=" + maxThread, MotanErrorMsgConstant.SERVICE_REJECT);
exception.setStackTrace(new StackTraceElement[0]);
response.setException(exception);
LoggerUtil.error("ThreadProtectedRequestRouter reject request: request_method=" + method + " request_counter=" + requestCounter + " =" + totalCounter + " max_thread=" + maxThread);
return response;
}
use of com.weibo.api.motan.rpc.DefaultResponse in project motan by weibocom.
the class DefaultRpcCodecTest method responseSize.
/**
* 不带返回值的response大小
*/
private static byte[] responseSize(DefaultRpcCodec codec, Channel channel, Object data) throws Exception {
DefaultResponse response = new DefaultResponse();
response.setRequestId(System.currentTimeMillis());
response.setProcessTime(System.currentTimeMillis());
if (data != null) {
response.setValue(data);
}
byte[] bytes = codec.encode(channel, response);
return bytes;
}
Aggregations