|
@@ -18,12 +18,14 @@
|
|
|
|
|
|
package org.apache.hadoop.hdfs;
|
|
package org.apache.hadoop.hdfs;
|
|
|
|
|
|
-
|
|
|
|
import org.apache.hadoop.ipc.RpcNoSuchMethodException;
|
|
import org.apache.hadoop.ipc.RpcNoSuchMethodException;
|
|
-import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
|
|
|
|
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
|
|
import org.apache.hadoop.thirdparty.com.google.common.base.Preconditions;
|
|
import org.apache.hadoop.thirdparty.com.google.common.collect.Lists;
|
|
import org.apache.hadoop.thirdparty.com.google.common.collect.Lists;
|
|
import org.apache.commons.collections.list.TreeList;
|
|
import org.apache.commons.collections.list.TreeList;
|
|
|
|
+import org.apache.hadoop.fs.LeaseRecoverable;
|
|
|
|
+import org.apache.hadoop.fs.SafeMode;
|
|
|
|
+
|
|
|
|
+import org.apache.hadoop.classification.VisibleForTesting;
|
|
import org.apache.hadoop.HadoopIllegalArgumentException;
|
|
import org.apache.hadoop.HadoopIllegalArgumentException;
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.classification.InterfaceAudience;
|
|
import org.apache.hadoop.classification.InterfaceStability;
|
|
import org.apache.hadoop.classification.InterfaceStability;
|
|
@@ -63,6 +65,7 @@ import org.apache.hadoop.fs.Path;
|
|
import org.apache.hadoop.fs.PathFilter;
|
|
import org.apache.hadoop.fs.PathFilter;
|
|
import org.apache.hadoop.fs.QuotaUsage;
|
|
import org.apache.hadoop.fs.QuotaUsage;
|
|
import org.apache.hadoop.fs.RemoteIterator;
|
|
import org.apache.hadoop.fs.RemoteIterator;
|
|
|
|
+import org.apache.hadoop.fs.SafeModeAction;
|
|
import org.apache.hadoop.fs.StorageStatistics;
|
|
import org.apache.hadoop.fs.StorageStatistics;
|
|
import org.apache.hadoop.fs.StorageType;
|
|
import org.apache.hadoop.fs.StorageType;
|
|
import org.apache.hadoop.fs.UnresolvedLinkException;
|
|
import org.apache.hadoop.fs.UnresolvedLinkException;
|
|
@@ -97,7 +100,6 @@ import org.apache.hadoop.hdfs.protocol.HdfsConstants;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.DatanodeReportType;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.ReencryptAction;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.ReencryptAction;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.RollingUpgradeAction;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsConstants.RollingUpgradeAction;
|
|
-import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction;
|
|
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsPathHandle;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsPathHandle;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsLocatedFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsLocatedFileStatus;
|
|
@@ -145,7 +147,7 @@ import static org.apache.hadoop.fs.impl.PathCapabilitiesSupport.validatePathCapa
|
|
@InterfaceAudience.LimitedPrivate({ "MapReduce", "HBase" })
|
|
@InterfaceAudience.LimitedPrivate({ "MapReduce", "HBase" })
|
|
@InterfaceStability.Unstable
|
|
@InterfaceStability.Unstable
|
|
public class DistributedFileSystem extends FileSystem
|
|
public class DistributedFileSystem extends FileSystem
|
|
- implements KeyProviderTokenIssuer, BatchListingOperations {
|
|
|
|
|
|
+ implements KeyProviderTokenIssuer, BatchListingOperations, LeaseRecoverable, SafeMode {
|
|
private Path workingDir;
|
|
private Path workingDir;
|
|
private URI uri;
|
|
private URI uri;
|
|
|
|
|
|
@@ -307,6 +309,7 @@ public class DistributedFileSystem extends FileSystem
|
|
* @return true if the file is already closed
|
|
* @return true if the file is already closed
|
|
* @throws IOException if an error occurs
|
|
* @throws IOException if an error occurs
|
|
*/
|
|
*/
|
|
|
|
+ @Override
|
|
public boolean recoverLease(final Path f) throws IOException {
|
|
public boolean recoverLease(final Path f) throws IOException {
|
|
Path absF = fixRelativePart(f);
|
|
Path absF = fixRelativePart(f);
|
|
return new FileSystemLinkResolver<Boolean>() {
|
|
return new FileSystemLinkResolver<Boolean>() {
|
|
@@ -1634,6 +1637,63 @@ public class DistributedFileSystem extends FileSystem
|
|
* @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setSafeMode(
|
|
* @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setSafeMode(
|
|
* HdfsConstants.SafeModeAction,boolean)
|
|
* HdfsConstants.SafeModeAction,boolean)
|
|
*/
|
|
*/
|
|
|
|
+ @Override
|
|
|
|
+ public boolean setSafeMode(SafeModeAction action)
|
|
|
|
+ throws IOException {
|
|
|
|
+ return setSafeMode(action, false);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Enter, leave or get safe mode.
|
|
|
|
+ *
|
|
|
|
+ * @param action
|
|
|
|
+ * One of SafeModeAction.ENTER, SafeModeAction.LEAVE and
|
|
|
|
+ * SafeModeAction.GET.
|
|
|
|
+ * @param isChecked
|
|
|
|
+ * If true check only for Active NNs status, else check first NN's
|
|
|
|
+ * status.
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @SuppressWarnings("deprecation")
|
|
|
|
+ public boolean setSafeMode(SafeModeAction action, boolean isChecked)
|
|
|
|
+ throws IOException {
|
|
|
|
+ return this.setSafeMode(convertToClientProtocolSafeModeAction(action), isChecked);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Translating the {@link SafeModeAction} into {@link HdfsConstants.SafeModeAction}
|
|
|
|
+ * that is used by {@link DFSClient#setSafeMode(HdfsConstants.SafeModeAction, boolean)}.
|
|
|
|
+ *
|
|
|
|
+ * @param action any supported action listed in {@link SafeModeAction}.
|
|
|
|
+ * @return the converted {@link HdfsConstants.SafeModeAction}.
|
|
|
|
+ * @throws UnsupportedOperationException if the provided {@link SafeModeAction} cannot be
|
|
|
|
+ * translated.
|
|
|
|
+ */
|
|
|
|
+ private static HdfsConstants.SafeModeAction convertToClientProtocolSafeModeAction(
|
|
|
|
+ SafeModeAction action) {
|
|
|
|
+ switch (action) {
|
|
|
|
+ case ENTER:
|
|
|
|
+ return HdfsConstants.SafeModeAction.SAFEMODE_ENTER;
|
|
|
|
+ case LEAVE:
|
|
|
|
+ return HdfsConstants.SafeModeAction.SAFEMODE_LEAVE;
|
|
|
|
+ case FORCE_EXIT:
|
|
|
|
+ return HdfsConstants.SafeModeAction.SAFEMODE_FORCE_EXIT;
|
|
|
|
+ case GET:
|
|
|
|
+ return HdfsConstants.SafeModeAction.SAFEMODE_GET;
|
|
|
|
+ default:
|
|
|
|
+ throw new UnsupportedOperationException("Unsupported safe mode action " + action);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Enter, leave or get safe mode.
|
|
|
|
+ *
|
|
|
|
+ * @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setSafeMode(HdfsConstants.SafeModeAction,
|
|
|
|
+ * boolean)
|
|
|
|
+ *
|
|
|
|
+ * @deprecated please instead use {@link #setSafeMode(SafeModeAction)}.
|
|
|
|
+ */
|
|
|
|
+ @Deprecated
|
|
public boolean setSafeMode(HdfsConstants.SafeModeAction action)
|
|
public boolean setSafeMode(HdfsConstants.SafeModeAction action)
|
|
throws IOException {
|
|
throws IOException {
|
|
return setSafeMode(action, false);
|
|
return setSafeMode(action, false);
|
|
@@ -1644,12 +1704,18 @@ public class DistributedFileSystem extends FileSystem
|
|
*
|
|
*
|
|
* @param action
|
|
* @param action
|
|
* One of SafeModeAction.ENTER, SafeModeAction.LEAVE and
|
|
* One of SafeModeAction.ENTER, SafeModeAction.LEAVE and
|
|
- * SafeModeAction.GET
|
|
|
|
|
|
+ * SafeModeAction.GET.
|
|
* @param isChecked
|
|
* @param isChecked
|
|
* If true check only for Active NNs status, else check first NN's
|
|
* If true check only for Active NNs status, else check first NN's
|
|
- * status
|
|
|
|
- * @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setSafeMode(SafeModeAction, boolean)
|
|
|
|
|
|
+ * status.
|
|
|
|
+ *
|
|
|
|
+ * @see org.apache.hadoop.hdfs.protocol.ClientProtocol#setSafeMode(HdfsConstants.SafeModeAction,
|
|
|
|
+ * boolean)
|
|
|
|
+ *
|
|
|
|
+ * @deprecated please instead use
|
|
|
|
+ * {@link DistributedFileSystem#setSafeMode(SafeModeAction, boolean)}.
|
|
*/
|
|
*/
|
|
|
|
+ @Deprecated
|
|
public boolean setSafeMode(HdfsConstants.SafeModeAction action,
|
|
public boolean setSafeMode(HdfsConstants.SafeModeAction action,
|
|
boolean isChecked) throws IOException {
|
|
boolean isChecked) throws IOException {
|
|
return dfs.setSafeMode(action, isChecked);
|
|
return dfs.setSafeMode(action, isChecked);
|
|
@@ -1686,7 +1752,7 @@ public class DistributedFileSystem extends FileSystem
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * enable/disable/check restoreFaileStorage
|
|
|
|
|
|
+ * enable/disable/check restoreFaileStorage.
|
|
*
|
|
*
|
|
* @see org.apache.hadoop.hdfs.protocol.ClientProtocol#restoreFailedStorage(String arg)
|
|
* @see org.apache.hadoop.hdfs.protocol.ClientProtocol#restoreFailedStorage(String arg)
|
|
*/
|
|
*/
|
|
@@ -2049,7 +2115,7 @@ public class DistributedFileSystem extends FileSystem
|
|
* when there is an issue communicating with the NameNode
|
|
* when there is an issue communicating with the NameNode
|
|
*/
|
|
*/
|
|
public boolean isInSafeMode() throws IOException {
|
|
public boolean isInSafeMode() throws IOException {
|
|
- return setSafeMode(SafeModeAction.SAFEMODE_GET, true);
|
|
|
|
|
|
+ return setSafeMode(HdfsConstants.SafeModeAction.SAFEMODE_GET, true);
|
|
}
|
|
}
|
|
|
|
|
|
/** @see org.apache.hadoop.hdfs.client.HdfsAdmin#allowSnapshot(Path) */
|
|
/** @see org.apache.hadoop.hdfs.client.HdfsAdmin#allowSnapshot(Path) */
|
|
@@ -2390,6 +2456,7 @@ public class DistributedFileSystem extends FileSystem
|
|
* @throws FileNotFoundException if the file does not exist.
|
|
* @throws FileNotFoundException if the file does not exist.
|
|
* @throws IOException If an I/O error occurred
|
|
* @throws IOException If an I/O error occurred
|
|
*/
|
|
*/
|
|
|
|
+ @Override
|
|
public boolean isFileClosed(final Path src) throws IOException {
|
|
public boolean isFileClosed(final Path src) throws IOException {
|
|
Path absF = fixRelativePart(src);
|
|
Path absF = fixRelativePart(src);
|
|
return new FileSystemLinkResolver<Boolean>() {
|
|
return new FileSystemLinkResolver<Boolean>() {
|
|
@@ -3648,6 +3715,7 @@ public class DistributedFileSystem extends FileSystem
|
|
// (yet/ever) in the WebHDFS API.
|
|
// (yet/ever) in the WebHDFS API.
|
|
switch (validatePathCapabilityArgs(path, capability)) {
|
|
switch (validatePathCapabilityArgs(path, capability)) {
|
|
case CommonPathCapabilities.FS_EXPERIMENTAL_BATCH_LISTING:
|
|
case CommonPathCapabilities.FS_EXPERIMENTAL_BATCH_LISTING:
|
|
|
|
+ case CommonPathCapabilities.LEASE_RECOVERABLE:
|
|
return true;
|
|
return true;
|
|
default:
|
|
default:
|
|
// fall through
|
|
// fall through
|