hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r524205 - in /lucene/hadoop/trunk: CHANGES.txt src/java/org/apache/hadoop/dfs/NameNode.java src/java/org/apache/hadoop/ipc/Server.java
Date Fri, 30 Mar 2007 17:49:08 GMT
Author: cutting
Date: Fri Mar 30 10:49:07 2007
New Revision: 524205

URL: http://svn.apache.org/viewvc?view=rev&rev=524205
Log:
HADOOP-1178.  Fix a NullPointerException during namenode startup.  Contributed by Dhruba.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=524205&r1=524204&r2=524205
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Fri Mar 30 10:49:07 2007
@@ -70,6 +70,9 @@
 21. HADOOP-1110.  Fix an off-by-one error counting map inputs.
     (David Bowen via cutting)
 
+22. HADOOP-1178.  Fix a NullPointerException during namenode startup.
+    (Dhruba Borthakur via cutting)
+
 
 Release 0.12.3 (not yet released)
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java?view=diff&rev=524205&r1=524204&r2=524205
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java Fri Mar 30 10:49:07 2007
@@ -180,18 +180,24 @@
       this.handlerCount = conf.getInt("dfs.namenode.handler.count", 10);
       this.server = RPC.getServer(this, hostname, port, handlerCount, 
                                   false, conf);
-      this.server.start();      
 
       // The rpc-server port can be ephemeral... ensure we have the correct info
       this.nameNodeAddress = this.server.getListenerAddress(); 
       conf.set("fs.default.name", new String(nameNodeAddress.getHostName() + ":" + nameNodeAddress.getPort()));
       LOG.info("Namenode up at: " + this.nameNodeAddress);
 
-      this.namesystem = new FSNamesystem(dirs, this.nameNodeAddress.getHostName(), this.nameNodeAddress.getPort(),
this, conf);
+      try {
+        this.namesystem = new FSNamesystem(dirs, this.nameNodeAddress.getHostName(), this.nameNodeAddress.getPort(),
this, conf);
+        this.server.start();  //start RPC server   
 
-      this.emptier = new Thread(new Trash(conf).getEmptier(), "Trash Emptier");
-      this.emptier.setDaemon(true);
-      this.emptier.start();
+        this.emptier = new Thread(new Trash(conf).getEmptier(), "Trash Emptier");
+        this.emptier.setDaemon(true);
+        this.emptier.start();
+      } catch (IOException e) {
+        this.server.stop();
+        throw e;
+      }
+      
     }
     
     /**

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java?view=diff&rev=524205&r1=524204&r2=524205
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/ipc/Server.java Fri Mar 30 10:49:07 2007
@@ -133,14 +133,15 @@
   private long maxCallStartAge;
   private int maxQueueSize;
 
-  private boolean running = true;                 // true while server runs
+  volatile private boolean running = true;         // true while server runs
   private LinkedList callQueue = new LinkedList(); // queued calls
 
   private List connectionList = 
        Collections.synchronizedList(new LinkedList()); //maintain a list
                                                        //of client connectionss
-  private Listener listener;
+  private Listener listener = null;
   private int numConnections = 0;
+  private Handler[] handlers = null;
   
   /** A call queued for handling. */
   private static class Call {
@@ -375,6 +376,13 @@
         selector.wakeup();
         Thread.yield();
       }
+      if (acceptChannel != null) {
+        try {
+          acceptChannel.socket().close();
+        } catch (IOException e) {
+            LOG.info(getName() + ":Exception in closing listener socket. " + e);
+        }
+      }
     }
   }
 
@@ -629,10 +637,11 @@
   /** Starts the service.  Must be called before any calls will be handled. */
   public synchronized void start() throws IOException {
     listener.start();
+    handlers = new Handler[handlerCount];
     
     for (int i = 0; i < handlerCount; i++) {
-      Handler handler = new Handler(i);
-      handler.start();
+      handlers[i] = new Handler(i);
+      handlers[i].start();
     }
   }
 
@@ -640,6 +649,14 @@
   public synchronized void stop() {
     LOG.info("Stopping server on " + port);
     running = false;
+    if (handlers != null) {
+      for (int i = 0; i < handlerCount; i++) {
+        if (handlers[i] != null) {
+          handlers[i].interrupt();
+        }
+      }
+    }
+    listener.interrupt();
     listener.doStop();
     notifyAll();
   }



Mime
View raw message