String errorClass = null;
String error = null;
Message returnValue = null;
thread2Address.put(Thread.currentThread(), (InetSocketAddress) ctx
.getChannel().getRemoteAddress());
NettyDataPack dataPack = (NettyDataPack) e.getMessage();
List<ByteBuffer> req = dataPack.getDatas();
ByteBufferInputStream dis = new ByteBufferInputStream(req);
ConnectionHeader header = ConnectionHeader.parseDelimitedFrom(dis);
@SuppressWarnings("unused")
RpcRequestHeader request = RpcRequestHeader.parseDelimitedFrom(dis);
RpcRequestBody rpcRequestBody;
try {
if (!started) {
throw new ServerNotRunningYetException("Server is not running yet");
}
rpcRequestBody = RpcRequestBody.parseDelimitedFrom(dis);
} catch (Throwable t) {
LOG.warn("Unable to read call parameters for client "
+ getRemoteAddress(), t);
List<ByteBuffer> res = prepareResponse(null, Status.FATAL, t
.getClass().getName(),
"IPC server unable to read call parameters:" + t.getMessage());
if (res != null) {
dataPack.setDatas(res);
e.getChannel().write(dataPack);
}
return;
}
try {
Class<? extends VersionedProtocol> class_ = className2Class
.get(header.getProtocol());
if (class_ == null) {
try {
className2Class.put(header.getProtocol(),
(Class<? extends VersionedProtocol>) Class.forName(header
.getProtocol()));
} catch (Exception e1) {
LOG.error("ClassNotFoundException.", e1);
throw new ClassNotFoundException(e1.getMessage(), e1);
}
class_ = className2Class.get(header.getProtocol());
}
returnValue = call(class_, rpcRequestBody, System.currentTimeMillis());
} catch (Throwable e2) {
LOG.error(Thread.currentThread().getName() + ", call "
+ rpcRequestBody + ": error: ", e2);
errorClass = e2.getClass().getName();
error = e2.getMessage();
}
List<ByteBuffer> res = prepareResponse(returnValue,
errorClass == null ? Status.SUCCESS : Status.ERROR, errorClass,
error);
// response will be null for one way messages.
if (res != null) {
dataPack.setDatas(res);
e.getChannel().write(dataPack);
}
} catch (OutOfMemoryError e4) {
throw e4;
} catch (ClosedChannelException cce) {