From 17de23ca0e0a9ed6e5da94e19e3050ac2a379e2c Mon Sep 17 00:00:00 2001 From: "P. Taylor Goetz" Date: Fri, 13 Dec 2013 12:12:29 -0500 Subject: [PATCH] prevent OOME if random data is sent to nimbus thrift port --- conf/defaults.yaml | 1 + storm-core/src/clj/backtype/storm/daemon/nimbus.clj | 5 ++--- storm-core/src/jvm/backtype/storm/Config.java | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/conf/defaults.yaml b/conf/defaults.yaml index a5b31f41ab9..6c12d185e13 100644 --- a/conf/defaults.yaml +++ b/conf/defaults.yaml @@ -23,6 +23,7 @@ storm.messaging.transport: "backtype.storm.messaging.zmq" ### nimbus.* configs are for the master nimbus.host: "localhost" nimbus.thrift.port: 6627 +nimbus.thrift.max_buffer_size: 1048576 nimbus.childopts: "-Xmx1024m" nimbus.task.timeout.secs: 30 nimbus.supervisor.timeout.secs: 60 diff --git a/storm-core/src/clj/backtype/storm/daemon/nimbus.clj b/storm-core/src/clj/backtype/storm/daemon/nimbus.clj index caac9963d03..bc50197d1e0 100644 --- a/storm-core/src/clj/backtype/storm/daemon/nimbus.clj +++ b/storm-core/src/clj/backtype/storm/daemon/nimbus.clj @@ -1137,15 +1137,14 @@ options (-> (TNonblockingServerSocket. (int (conf NIMBUS-THRIFT-PORT))) (THsHaServer$Args.) (.workerThreads 64) - (.protocolFactory (TBinaryProtocol$Factory.)) + (.protocolFactory (TBinaryProtocol$Factory. false true (conf NIMBUS-THRIFT-MAX-BUFFER-SIZE))) (.processor (Nimbus$Processor. service-handler)) ) - server (THsHaServer. options)] + server (THsHaServer. (do (set! (. options maxReadBufferBytes)(conf NIMBUS-THRIFT-MAX-BUFFER-SIZE)) options))] (.addShutdownHook (Runtime/getRuntime) (Thread. (fn [] (.shutdown service-handler) (.stop server)))) (log-message "Starting Nimbus server...") (.serve server))) - ;; distributed implementation (defmethod setup-jar :distributed [conf tmp-jar-location stormroot] diff --git a/storm-core/src/jvm/backtype/storm/Config.java b/storm-core/src/jvm/backtype/storm/Config.java index 13e8d02be86..544e82a4d37 100644 --- a/storm-core/src/jvm/backtype/storm/Config.java +++ b/storm-core/src/jvm/backtype/storm/Config.java @@ -204,6 +204,12 @@ public class Config extends HashMap { public static final String NIMBUS_THRIFT_PORT = "nimbus.thrift.port"; public static final Object NIMBUS_THRIFT_PORT_SCHEMA = Number.class; + /** + * The maximum buffer size thrift should use when reading messages. + */ + public static final String NIMBUS_THRIFT_MAX_BUFFER_SIZE = "nimbus.thrift.max_buffer_size"; + public static final Object NIMBUS_THRIFT_MAX_BUFFER_SIZE_SCHEMA = Number.class; + /** * This parameter is used by the storm-deploy project to configure the