瀏覽代碼

Apply local Configuration to parameters received via RPC if they
implement Configurable. Fix by Marko Bauhardt.

Note: in the future there may be protocols that assume
different local and remote Configuration. However, with the
current RPC implementation we don't support it anyway, and for
now it seems better that parameters implementing Configurable
should be provided with non-null Configuration.


git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@384008 13f79535-47bb-0310-9956-ffa450edef68

Andrzej Bialecki 19 年之前
父節點
當前提交
2e0f1051ff
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      src/java/org/apache/hadoop/ipc/Server.java

+ 6 - 0
src/java/org/apache/hadoop/ipc/Server.java

@@ -33,6 +33,7 @@ import java.util.logging.Logger;
 import java.util.logging.Level;
 
 import org.apache.hadoop.util.LogFormatter;
+import org.apache.hadoop.conf.Configurable;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.UTF8;
@@ -52,6 +53,7 @@ public abstract class Server {
   private int handlerCount;                       // number of handler threads
   private int maxQueuedCalls;                     // max number of queued calls
   private Class paramClass;                       // class of call parameters
+  private Configuration conf;
 
   private int timeout;
 
@@ -229,6 +231,7 @@ public abstract class Server {
    * the number of handler threads that will be used to process calls.
    */
   protected Server(int port, Class paramClass, int handlerCount, Configuration conf) {
+    this.conf = conf;
     this.port = port;
     this.paramClass = paramClass;
     this.handlerCount = handlerCount;
@@ -280,6 +283,9 @@ public abstract class Server {
     Writable param;                               // construct param
     try {
       param = (Writable)paramClass.newInstance();
+      if (param instanceof Configurable) {
+        ((Configurable)param).setConf(conf);
+      }
     } catch (InstantiationException e) {
       throw new RuntimeException(e.toString());
     } catch (IllegalAccessException e) {