hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r550952 - in /lucene/hadoop/trunk: ./ src/java/org/apache/hadoop/dfs/ src/java/org/apache/hadoop/mapred/ src/java/org/apache/hadoop/util/
Date Tue, 26 Jun 2007 21:08:46 GMT
Author: cutting
Date: Tue Jun 26 14:08:45 2007
New Revision: 550952

URL: http://svn.apache.org/viewvc?view=rev&rev=550952
Log:
HADOOP-1028.  Add log messages for server startup and shutdown.  Contributed by Tsz Wo Sze.

Modified:
    lucene/hadoop/trunk/CHANGES.txt
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/SecondaryNameNode.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java
    lucene/hadoop/trunk/src/java/org/apache/hadoop/util/StringUtils.java

Modified: lucene/hadoop/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/CHANGES.txt?view=diff&rev=550952&r1=550951&r2=550952
==============================================================================
--- lucene/hadoop/trunk/CHANGES.txt (original)
+++ lucene/hadoop/trunk/CHANGES.txt Tue Jun 26 14:08:45 2007
@@ -261,6 +261,9 @@
      new FsShell commands "touchz", "test" and "stat".
      (Chris Douglas via cutting)
 
+ 80. HADOOP-1028.  Add log messages for server startup and shutdown.
+     (Tsz Wo Sze via cutting)
+
 
 Release 0.13.0 - 2007-06-08
 

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java?view=diff&rev=550952&r1=550951&r2=550952
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DataNode.java Tue Jun 26 14:08:45 2007
@@ -289,7 +289,6 @@
         } catch (InterruptedException ie) {}
       }
     }
-    String errorMsg = null;
     return nsInfo;
   }
 
@@ -1103,8 +1102,8 @@
    * Only stop when "shouldRun" is turned off (which can only happen at shutdown).
    */
   public void run() {
-    LOG.info("Starting DataNode in: "+data);
-        
+    LOG.info("In DataNode.run, data = " + data);
+
     // start dataXceiveServer
     dataXceiveServer.start();
         
@@ -1324,6 +1323,7 @@
    */
   public static void main(String args[]) {
     try {
+      StringUtils.startupShutdownMessage(DataNode.class, args, LOG);
       DataNode datanode = createDataNode(args, null);
       if (datanode != null)
         datanode.join();

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=550952&r1=550951&r2=550952
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/NameNode.java Tue Jun 26 14:08:45 2007
@@ -818,6 +818,7 @@
    */
   public static void main(String argv[]) throws Exception {
     try {
+      StringUtils.startupShutdownMessage(NameNode.class, argv, LOG);
       NameNode namenode = createNameNode(argv, null);
       if (namenode != null)
         namenode.join();

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/SecondaryNameNode.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/SecondaryNameNode.java?view=diff&rev=550952&r1=550951&r2=550952
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/SecondaryNameNode.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/SecondaryNameNode.java Tue Jun 26 14:08:45
2007
@@ -461,6 +461,7 @@
    * @exception Exception if the filesystem does not exist.
    */
   public static void main(String[] argv) throws Exception {
+    StringUtils.startupShutdownMessage(SecondaryNameNode.class, argv, LOG);
     Configuration tconf = new Configuration();
     if (argv.length >= 1) {
       SecondaryNameNode secondary = new SecondaryNameNode(tconf);

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java?view=diff&rev=550952&r1=550951&r2=550952
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/JobTracker.java Tue Jun 26 14:08:45
2007
@@ -1719,6 +1719,7 @@
    * JobTracker should be run as part of the DFS Namenode process.
    */
   public static void main(String argv[]) throws IOException, InterruptedException {
+    StringUtils.startupShutdownMessage(JobTracker.class, argv, LOG);
     if (argv.length != 0) {
       System.out.println("usage: JobTracker");
       System.exit(-1);

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java?view=diff&rev=550952&r1=550951&r2=550952
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/mapred/TaskTracker.java Tue Jun 26 14:08:45
2007
@@ -1804,6 +1804,7 @@
    * Start the TaskTracker, point toward the indicated JobTracker
    */
   public static void main(String argv[]) throws Exception {
+    StringUtils.startupShutdownMessage(TaskTracker.class, argv, LOG);
     if (argv.length != 0) {
       System.out.println("usage: TaskTracker");
       System.exit(-1);

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/util/StringUtils.java
URL: http://svn.apache.org/viewvc/lucene/hadoop/trunk/src/java/org/apache/hadoop/util/StringUtils.java?view=diff&rev=550952&r1=550951&r2=550952
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/util/StringUtils.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/util/StringUtils.java Tue Jun 26 14:08:45
2007
@@ -20,11 +20,14 @@
 
 import java.io.PrintWriter;
 import java.io.StringWriter;
+import java.net.InetAddress;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.net.UnknownHostException;
 import java.text.DateFormat;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -265,5 +268,52 @@
       values.add(tokenizer.nextToken());
     }
     return (String[])values.toArray(new String[values.size()]);
+  }
+
+  /**
+   * Return hostname without throwing exception.
+   * @return hostname
+   */
+  public static String getHostname() {
+    try {return "" + InetAddress.getLocalHost();}
+    catch(UnknownHostException uhe) {return "" + uhe;}
+  }
+
+  /**
+   * Return a message for logging.
+   * @param prefix prefix keyword for the message
+   * @param msg content of the message
+   * @return a message for logging
+   */
+  private static String toStartupShutdownString(String prefix, String [] msg) {
+    StringBuffer b = new StringBuffer(prefix);
+    b.append("\n/************************************************************");
+    for(String s : msg)
+      b.append("\n" + prefix + s);
+    b.append("\n************************************************************/");
+    return b.toString();
+  }
+
+  /**
+   * Print a log message for starting up and shutting down
+   * @param clazz the class of the server
+   * @param args arguments
+   * @param LOG the target log object
+   */
+  public static void startupShutdownMessage(Class clazz, String[] args,
+                                     final org.apache.commons.logging.Log LOG) {
+    final String hostname = getHostname();
+    final String classname = clazz.getSimpleName();
+    LOG.info(toStartupShutdownString("STARTUP_MSG: ", new String[]{
+      "Starting " + classname,
+      "  host = " + hostname,
+      "  args = " + Arrays.asList(args)}));
+
+    Runtime.getRuntime().addShutdownHook(new Thread() {
+      public void run() {
+        LOG.info(toStartupShutdownString("SHUTDOWN_MSG: ", new String[]{
+          "Shutting down " + classname + " at " + hostname}));
+      }
+    });
   }
 }



Mime
View raw message