use of com.weibo.api.motan.exception.MotanFrameworkException in project motan by weibocom.
the class ProtobufCodec method decodeResponse.
private Object decodeResponse(CodedInputStream input, byte dataType, long requestId, Serialization serialization) throws IOException, ClassNotFoundException {
long processTime = input.readInt64();
DefaultResponse response = new DefaultResponse();
response.setRequestId(requestId);
response.setProcessTime(processTime);
if (dataType == MotanConstants.FLAG_RESPONSE_VOID) {
return response;
}
String className = input.readString();
Class<?> clz = ReflectUtil.forName(className);
Object result = serialization.deserialize(input.readByteArray(), clz);
if (dataType == MotanConstants.FLAG_RESPONSE) {
response.setValue(result);
} else if (dataType == MotanConstants.FLAG_RESPONSE_EXCEPTION) {
response.setException((Exception) result);
} else {
throw new MotanFrameworkException("decode error: response dataType not support " + dataType, MotanErrorMsgConstant.FRAMEWORK_DECODE_ERROR);
}
response.setRequestId(requestId);
return response;
}
use of com.weibo.api.motan.exception.MotanFrameworkException in project motan by weibocom.
the class GrpcServer method addExporter.
@SuppressWarnings("rawtypes")
public void addExporter(Exporter<?> exporter) throws Exception {
Provider provider = exporter.getProvider();
ServerServiceDefinition serviceDefine = GrpcUtil.getServiceDefByAnnotation(provider.getInterface());
boolean urlShareChannel = exporter.getUrl().getBooleanParameter(URLParamType.shareChannel.getName(), URLParamType.shareChannel.getBooleanValue());
synchronized (serviceDefinetions) {
if (!(shareChannel && urlShareChannel) && !serviceDefinetions.isEmpty()) {
URL url = serviceDefinetions.keySet().iterator().next();
throw new MotanFrameworkException("url:" + exporter.getUrl() + " cannot share channel with url:" + url);
}
registry.addService(serviceDefine, provider);
if (httpHandler != null) {
httpHandler.addProvider(provider);
}
serviceDefinetions.put(exporter.getUrl(), serviceDefine);
}
}
Aggregations