HDFS-3415. Make sure all layout versions are the same for all storage directories in the Namenode. Contributed by Brandon Li
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1341676 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
23b96766ad
commit
aa80e6895d
|
@ -732,6 +732,9 @@ Release 2.0.0-alpha - UNRELEASED
|
||||||
HDFS-860. fuse-dfs truncate behavior causes issues with scp.
|
HDFS-860. fuse-dfs truncate behavior causes issues with scp.
|
||||||
(Brian Bockelman via eli)
|
(Brian Bockelman via eli)
|
||||||
|
|
||||||
|
HDFS-3415. Make sure all layout versions are the same for all storage
|
||||||
|
directories in the Namenode. (Brandon Li via szetszwo)
|
||||||
|
|
||||||
BREAKDOWN OF HDFS-1623 SUBTASKS
|
BREAKDOWN OF HDFS-1623 SUBTASKS
|
||||||
|
|
||||||
HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd)
|
HDFS-2179. Add fencing framework and mechanisms for NameNode HA. (todd)
|
||||||
|
|
|
@ -31,6 +31,7 @@ import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
@ -58,6 +59,7 @@ import org.apache.hadoop.net.DNS;
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NNStorage is responsible for management of the StorageDirectories used by
|
* NNStorage is responsible for management of the StorageDirectories used by
|
||||||
|
@ -1076,12 +1078,13 @@ public class NNStorage extends Storage implements Closeable {
|
||||||
* inspected each directory.
|
* inspected each directory.
|
||||||
*
|
*
|
||||||
* <b>Note:</b> this can mutate the storage info fields (ctime, version, etc).
|
* <b>Note:</b> this can mutate the storage info fields (ctime, version, etc).
|
||||||
* @throws IOException if no valid storage dirs are found
|
* @throws IOException if no valid storage dirs are found or no valid layout version
|
||||||
*/
|
*/
|
||||||
FSImageStorageInspector readAndInspectDirs()
|
FSImageStorageInspector readAndInspectDirs()
|
||||||
throws IOException {
|
throws IOException {
|
||||||
int minLayoutVersion = Integer.MAX_VALUE; // the newest
|
Integer layoutVersion = null;
|
||||||
int maxLayoutVersion = Integer.MIN_VALUE; // the oldest
|
boolean multipleLV = false;
|
||||||
|
StringBuilder layoutVersions = new StringBuilder();
|
||||||
|
|
||||||
// First determine what range of layout versions we're going to inspect
|
// First determine what range of layout versions we're going to inspect
|
||||||
for (Iterator<StorageDirectory> it = dirIterator();
|
for (Iterator<StorageDirectory> it = dirIterator();
|
||||||
|
@ -1092,24 +1095,29 @@ public class NNStorage extends Storage implements Closeable {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
readProperties(sd); // sets layoutVersion
|
readProperties(sd); // sets layoutVersion
|
||||||
minLayoutVersion = Math.min(minLayoutVersion, getLayoutVersion());
|
int lv = getLayoutVersion();
|
||||||
maxLayoutVersion = Math.max(maxLayoutVersion, getLayoutVersion());
|
if (layoutVersion == null) {
|
||||||
|
layoutVersion = Integer.valueOf(lv);
|
||||||
|
} else if (!layoutVersion.equals(lv)) {
|
||||||
|
multipleLV = true;
|
||||||
|
}
|
||||||
|
layoutVersions.append("(").append(sd.getRoot()).append(", ").append(lv).append(") ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minLayoutVersion > maxLayoutVersion) {
|
if (layoutVersion == null) {
|
||||||
throw new IOException("No storage directories contained VERSION information");
|
throw new IOException("No storage directories contained VERSION information");
|
||||||
}
|
}
|
||||||
assert minLayoutVersion <= maxLayoutVersion;
|
if (multipleLV) {
|
||||||
|
throw new IOException(
|
||||||
// If we have any storage directories with the new layout version
|
"Storage directories containe multiple layout versions: "
|
||||||
|
+ layoutVersions);
|
||||||
|
}
|
||||||
|
// If the storage directories are with the new layout version
|
||||||
// (ie edits_<txnid>) then use the new inspector, which will ignore
|
// (ie edits_<txnid>) then use the new inspector, which will ignore
|
||||||
// the old format dirs.
|
// the old format dirs.
|
||||||
FSImageStorageInspector inspector;
|
FSImageStorageInspector inspector;
|
||||||
if (LayoutVersion.supports(Feature.TXID_BASED_LAYOUT, minLayoutVersion)) {
|
if (LayoutVersion.supports(Feature.TXID_BASED_LAYOUT, getLayoutVersion())) {
|
||||||
inspector = new FSImageTransactionalStorageInspector();
|
inspector = new FSImageTransactionalStorageInspector();
|
||||||
if (!LayoutVersion.supports(Feature.TXID_BASED_LAYOUT, maxLayoutVersion)) {
|
|
||||||
FSImage.LOG.warn("Ignoring one or more storage directories with old layouts");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
inspector = new FSImagePreTransactionalStorageInspector();
|
inspector = new FSImagePreTransactionalStorageInspector();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue