config.getProtocol().getSerializerType(),
PlatformType.Java,
requestProtocol);
Protocol receiveP = null;
Server server = null;
for(int i = 0; i <= count; i++){
server = dispatcher.GetServer();
if (server == null) {
logger.error("cannot get server");
throw new Exception("cannot get server");
}
try{
receiveP = server.request(sendP);
break;
} catch(IOException io){
if(count == 0 || i == ioreconnect){
throw io;
}
if(i < count && i < ioreconnect) {
logger.error(server.getName()+" server has IOException,system will change normal server!");
continue;
}
} catch(RebootException rb){
this.createReboot(server);
if(count == 0 || i == ioreconnect){
throw new IOException("connect fail!");
}
if(i < count && i < ioreconnect) {
logger.error(server.getName()+" server has reboot,system will change normal server!");
continue;
}
}catch(TimeoutException te){
if(count == 0 || i == requestTime){
throw new TimeoutException("Receive data timeout or error!");
}
if(i < count && i < requestTime) {
logger.error(server.getName()+" server has TimeoutException,system will change normal server!");
continue;
}
} catch (Throwable ex){
logger.error("invoke other Exception", ex);
throw ex;
}
}
if(receiveP == null){
throw new Exception("userdatatype error!");
}
if (receiveP.getSDPType() == SDPType.Response) {
ResponseProtocol rp = (ResponseProtocol)receiveP.getSdpEntity();
logger.debug("invoke time:" + (System.currentTimeMillis() - watcher) + "ms");
return new InvokeResult(rp.getResult(), rp.getOutpara());
} else if(receiveP.getSDPType() == SDPType.Reset){ //服务重启
logger.info(server.getName()+" server is reboot,system will change normal server!");
this.createReboot(server);
return invoke(returnType, typeName, methodName, paras);
}else if (receiveP.getSDPType() == SDPType.Exception) {
ExceptionProtocol ep = (ExceptionProtocol)receiveP.getSdpEntity();
throw ThrowErrorHelper.throwServiceError(ep.getErrorCode(), ep.getErrorMsg());