|
@@ -104,8 +104,10 @@ public abstract class Server {
|
|
|
* Initial and max size of response buffer
|
|
|
*/
|
|
|
static int INITIAL_RESP_BUF_SIZE = 10240;
|
|
|
- static int MAX_RESP_BUF_SIZE = 1024*1024;
|
|
|
-
|
|
|
+ static final String IPC_SERVER_RPC_MAX_RESPONSE_SIZE_KEY =
|
|
|
+ "ipc.server.max.response.size";
|
|
|
+ static final int IPC_SERVER_RPC_MAX_RESPONSE_SIZE_DEFAULT = 1024*1024;
|
|
|
+
|
|
|
public static final Log LOG = LogFactory.getLog(Server.class);
|
|
|
|
|
|
private static final ThreadLocal<Server> SERVER = new ThreadLocal<Server>();
|
|
@@ -174,6 +176,7 @@ public abstract class Server {
|
|
|
private SecretManager<TokenIdentifier> secretManager;
|
|
|
|
|
|
private int maxQueueSize;
|
|
|
+ private final int maxRespSize;
|
|
|
private int socketSendBufferSize;
|
|
|
private final boolean tcpNoDelay; // if T then disable Nagle's Algorithm
|
|
|
|
|
@@ -1201,10 +1204,10 @@ public abstract class Server {
|
|
|
setupResponse(buf, call,
|
|
|
(error == null) ? Status.SUCCESS : Status.ERROR,
|
|
|
value, errorClass, error);
|
|
|
- // Discard the large buf and reset it back to
|
|
|
- // smaller size to freeup heap
|
|
|
- if (buf.size() > MAX_RESP_BUF_SIZE) {
|
|
|
- LOG.warn("Large response size " + buf.size() + " for call " +
|
|
|
+ // Discard the large buf and reset it back to
|
|
|
+ // smaller size to freeup heap
|
|
|
+ if (buf.size() > maxRespSize) {
|
|
|
+ LOG.warn("Large response size " + buf.size() + " for call " +
|
|
|
call.toString());
|
|
|
buf = new ByteArrayOutputStream(INITIAL_RESP_BUF_SIZE);
|
|
|
}
|
|
@@ -1249,6 +1252,8 @@ public abstract class Server {
|
|
|
this.handlerCount = handlerCount;
|
|
|
this.socketSendBufferSize = 0;
|
|
|
this.maxQueueSize = handlerCount * MAX_QUEUE_SIZE_PER_HANDLER;
|
|
|
+ this.maxRespSize = conf.getInt(IPC_SERVER_RPC_MAX_RESPONSE_SIZE_KEY,
|
|
|
+ IPC_SERVER_RPC_MAX_RESPONSE_SIZE_DEFAULT);
|
|
|
this.callQueue = new LinkedBlockingQueue<Call>(maxQueueSize);
|
|
|
this.maxIdleTime = 2*conf.getInt("ipc.client.connection.maxidletime", 1000);
|
|
|
this.maxConnectionsToNuke = conf.getInt("ipc.client.kill.max", 10);
|