Skip to content

Commit 70f6603

Browse files
committed
Rebased to latest trunk and added snapshotTrashRoot config check.
1 parent 6d5c151 commit 70f6603

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSDirSnapshotOp.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,10 @@ static void checkUnderSameSnapshottableRoot(FSDirectory fsd,
363363
INodesInPath srcIIP, INodesInPath dstIIP) throws IOException {
364364
// Ensure rename out of a snapshottable root is not permitted if ordered
365365
// snapshot deletion feature is enabled
366-
if (fsd.isSnapshotDeletionOrdered()) {
367-
SnapshotManager snapshotManager = fsd.getFSNamesystem().
368-
getSnapshotManager();
366+
SnapshotManager snapshotManager = fsd.getFSNamesystem().
367+
getSnapshotManager();
368+
if (snapshotManager.isSnapshotDeletionOrdered() && fsd.getFSNamesystem()
369+
.isSnapshotTrashRootEnabled()) {
369370
String errMsg = "Source " + srcIIP.getPath() +
370371
" and dest " + dstIIP.getPath() + " are not under " +
371372
"the same snapshot root.";

hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,10 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
384384
.getLogger(FSNamesystem.class.getName());
385385

386386
// The following are private configurations
387-
static final String DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED =
387+
public static final String DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED =
388388
"dfs.namenode.snapshot.trashroot.enabled";
389-
static final boolean DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED_DEFAULT = false;
389+
public static final boolean DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED_DEFAULT
390+
= false;
390391

391392
private final MetricsRegistry registry = new MetricsRegistry("FSNamesystem");
392393
@Metric final MutableRatesWithAggregation detailedLockHoldTimeMetrics =
@@ -468,6 +469,7 @@ private void logAuditEvent(boolean succeeded,
468469
private final UserGroupInformation fsOwner;
469470
private final String supergroup;
470471
private final boolean standbyShouldCheckpoint;
472+
private final boolean isSnapshotTrashRootEnabled;
471473
private final int snapshotDiffReportLimit;
472474
private final int blockDeletionIncrement;
473475

@@ -882,6 +884,9 @@ static FSNamesystem loadFromDisk(Configuration conf) throws IOException {
882884
// Get the checksum type from config
883885
String checksumTypeStr = conf.get(DFS_CHECKSUM_TYPE_KEY,
884886
DFS_CHECKSUM_TYPE_DEFAULT);
887+
this.isSnapshotTrashRootEnabled = conf.getBoolean(
888+
DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED,
889+
DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED_DEFAULT);
885890
DataChecksum.Type checksumType;
886891
try {
887892
checksumType = DataChecksum.Type.valueOf(checksumTypeStr);
@@ -909,8 +914,7 @@ static FSNamesystem loadFromDisk(Configuration conf) throws IOException {
909914
CommonConfigurationKeysPublic.HADOOP_SECURITY_KEY_PROVIDER_PATH,
910915
""),
911916
blockManager.getStoragePolicySuite().getDefaultPolicy().getId(),
912-
conf.getBoolean(DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED,
913-
DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED_DEFAULT));
917+
isSnapshotTrashRootEnabled);
914918

915919
this.maxFsObjects = conf.getLong(DFS_NAMENODE_MAX_OBJECTS_KEY,
916920
DFS_NAMENODE_MAX_OBJECTS_DEFAULT);
@@ -1054,6 +1058,10 @@ public int getMaxListOpenFilesResponses() {
10541058
return maxListOpenFilesResponses;
10551059
}
10561060

1061+
boolean isSnapshotTrashRootEnabled() {
1062+
return isSnapshotTrashRootEnabled;
1063+
}
1064+
10571065
void lockRetryCache() {
10581066
if (retryCache != null) {
10591067
retryCache.lock();
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* See the License for the specific language governing permissions and
1616
* limitations under the License.
1717
*/
18-
package org.apache.hadoop.hdfs.server.namenode;
18+
package org.apache.hadoop.hdfs.server.namenode.snapshot;
1919

2020
import org.apache.hadoop.conf.Configuration;
2121
import org.apache.hadoop.fs.Path;
@@ -30,9 +30,8 @@
3030

3131
import java.io.IOException;
3232

33-
import static org.apache.hadoop.hdfs.DFSConfigKeys.
34-
DFS_NAMENODE_SNAPSHOT_DELETION_ORDERED;
35-
33+
import static org.apache.hadoop.hdfs.server.namenode.snapshot.SnapshotManager.DFS_NAMENODE_SNAPSHOT_DELETION_ORDERED;
34+
import static org.apache.hadoop.hdfs.server.namenode.FSNamesystem.DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED;
3635
/**
3736
* Test Rename with ordered snapshot deletion.
3837
*/
@@ -46,6 +45,7 @@ public class TestRenameWithOrderedSnapshotDeletion {
4645
public void setUp() throws Exception {
4746
final Configuration conf = new Configuration();
4847
conf.setBoolean(DFS_NAMENODE_SNAPSHOT_DELETION_ORDERED, true);
48+
conf.setBoolean(DFS_NAMENODE_SNAPSHOT_TRASHROOT_ENABLED, true);
4949

5050
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0).build();
5151
cluster.waitActive();

0 commit comments

Comments
 (0)