|
@@ -17,27 +17,30 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.hdfs.server.namenode;
|
|
|
|
|
|
-import org.apache.commons.logging.*;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.InetAddress;
|
|
|
+import java.net.InetSocketAddress;
|
|
|
+import java.net.URI;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.Iterator;
|
|
|
|
|
|
+import org.apache.commons.logging.Log;
|
|
|
+import org.apache.commons.logging.LogFactory;
|
|
|
+import org.apache.hadoop.conf.Configuration;
|
|
|
import org.apache.hadoop.fs.FileSystem;
|
|
|
-import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
|
|
|
-import org.apache.hadoop.hdfs.protocol.FSConstants;
|
|
|
import org.apache.hadoop.hdfs.server.common.HdfsConstants;
|
|
|
import org.apache.hadoop.hdfs.server.common.InconsistentFSStateException;
|
|
|
-import org.apache.hadoop.ipc.*;
|
|
|
-import org.apache.hadoop.conf.*;
|
|
|
-import org.apache.hadoop.util.StringUtils;
|
|
|
-import org.apache.hadoop.util.Daemon;
|
|
|
+import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocol;
|
|
|
import org.apache.hadoop.http.HttpServer;
|
|
|
-import org.apache.hadoop.net.NetUtils;
|
|
|
-
|
|
|
-import java.io.*;
|
|
|
-import java.net.*;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.Iterator;
|
|
|
-
|
|
|
+import org.apache.hadoop.ipc.RPC;
|
|
|
+import org.apache.hadoop.ipc.RemoteException;
|
|
|
import org.apache.hadoop.metrics.jvm.JvmMetrics;
|
|
|
+import org.apache.hadoop.net.NetUtils;
|
|
|
+import org.apache.hadoop.util.Daemon;
|
|
|
+import org.apache.hadoop.util.StringUtils;
|
|
|
|
|
|
/**********************************************************
|
|
|
* The Secondary NameNode is a helper to the primary NameNode.
|
|
@@ -57,6 +60,9 @@ public class SecondaryNameNode implements Runnable {
|
|
|
public static final Log LOG =
|
|
|
LogFactory.getLog(SecondaryNameNode.class.getName());
|
|
|
|
|
|
+ private final long starttime = System.currentTimeMillis();
|
|
|
+ private volatile long lastCheckpointTime = 0;
|
|
|
+
|
|
|
private String fsName;
|
|
|
private CheckpointStorage checkpointImage;
|
|
|
|
|
@@ -73,6 +79,17 @@ public class SecondaryNameNode implements Runnable {
|
|
|
private long checkpointPeriod; // in seconds
|
|
|
private long checkpointSize; // size (in MB) of current Edit Log
|
|
|
|
|
|
+ /** {@inheritDoc} */
|
|
|
+ public String toString() {
|
|
|
+ return getClass().getSimpleName() + " Status"
|
|
|
+ + "\nName Node Address : " + nameNodeAddr
|
|
|
+ + "\nStart Time : " + new Date(starttime)
|
|
|
+ + "\nLast Checkpoint Time : " + (lastCheckpointTime == 0? "--": new Date(lastCheckpointTime))
|
|
|
+ + "\nCheckpoint Period : " + checkpointPeriod + " seconds"
|
|
|
+ + "\nCheckpoint Size : " + checkpointSize + " MB"
|
|
|
+ + "\nCheckpoint Dirs : " + checkpointDirs
|
|
|
+ + "\nCheckpoint Edits Dirs: " + checkpointEditsDirs;
|
|
|
+ }
|
|
|
/**
|
|
|
* Utility class to facilitate junit test error simulation.
|
|
|
*/
|
|
@@ -159,6 +176,7 @@ public class SecondaryNameNode implements Runnable {
|
|
|
int tmpInfoPort = infoSocAddr.getPort();
|
|
|
infoServer = new HttpServer("secondary", infoBindAddress, tmpInfoPort,
|
|
|
tmpInfoPort == 0, conf);
|
|
|
+ infoServer.setAttribute("secondary.name.node", this);
|
|
|
infoServer.setAttribute("name.system.image", checkpointImage);
|
|
|
this.infoServer.setAttribute("name.conf", conf);
|
|
|
infoServer.addInternalServlet("getimage", "/getimage", GetImageServlet.class);
|
|
@@ -202,7 +220,6 @@ public class SecondaryNameNode implements Runnable {
|
|
|
// pending edit log.
|
|
|
//
|
|
|
long period = 5 * 60; // 5 minutes
|
|
|
- long lastCheckpointTime = 0;
|
|
|
if (checkpointPeriod < period) {
|
|
|
period = checkpointPeriod;
|
|
|
}
|