4747import org .apache .hadoop .conf .Configuration ;
4848import org .apache .hadoop .fs .FileSystem ;
4949import org .apache .hadoop .fs .Path ;
50+ import org .apache .hadoop .fs .SafeModeAction ;
5051import org .apache .hadoop .fs .permission .FsAction ;
5152import org .apache .hadoop .fs .permission .FsPermission ;
5253import org .apache .hadoop .fs .permission .PermissionStatus ;
5556import org .apache .hadoop .hdfs .DistributedFileSystem ;
5657import org .apache .hadoop .hdfs .HdfsConfiguration ;
5758import org .apache .hadoop .hdfs .MiniDFSCluster ;
58- import org .apache .hadoop .hdfs .protocol .HdfsConstants . SafeModeAction ;
59+ import org .apache .hadoop .hdfs .protocol .HdfsConstants ;
5960import org .apache .hadoop .hdfs .server .blockmanagement .BlockIdManager ;
6061import org .apache .hadoop .hdfs .server .common .HdfsServerConstants .NamenodeRole ;
6162import org .apache .hadoop .hdfs .server .common .Storage .StorageDirectory ;
@@ -212,7 +213,7 @@ private void saveNamespaceWithInjectedFault(Fault fault) throws Exception {
212213 doAnEdit (fsn , 1 );
213214
214215 // Save namespace - this may fail, depending on fault injected
215- fsn .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
216+ fsn .setSafeMode (HdfsConstants . SafeModeAction .SAFEMODE_ENTER );
216217 try {
217218 fsn .saveNamespace (0 , 0 );
218219 if (shouldFail ) {
@@ -226,7 +227,7 @@ private void saveNamespaceWithInjectedFault(Fault fault) throws Exception {
226227 }
227228 }
228229
229- fsn .setSafeMode (SafeModeAction .SAFEMODE_LEAVE );
230+ fsn .setSafeMode (HdfsConstants . SafeModeAction .SAFEMODE_LEAVE );
230231 // Should still be able to perform edits
231232 doAnEdit (fsn , 2 );
232233
@@ -281,7 +282,7 @@ public void testReinsertnamedirsInSavenamespace() throws Exception {
281282
282283 try {
283284 doAnEdit (fsn , 1 );
284- fsn .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
285+ fsn .setSafeMode (HdfsConstants . SafeModeAction .SAFEMODE_ENTER );
285286
286287 // Save namespace - should mark the first storage dir as faulty
287288 // since it's not traversable.
@@ -420,7 +421,7 @@ public void doTestFailedSaveNamespace(boolean restoreStorageAfterFailure)
420421 doAnEdit (fsn , 1 );
421422
422423 // Save namespace
423- fsn .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
424+ fsn .setSafeMode (HdfsConstants . SafeModeAction .SAFEMODE_ENTER );
424425 try {
425426 fsn .saveNamespace (0 , 0 );
426427 fail ("saveNamespace did not fail even when all directories failed!" );
@@ -469,7 +470,7 @@ public void testSaveWhileEditsRolled() throws Exception {
469470 doAnEdit (fsn , 2 );
470471
471472 // Save namespace
472- fsn .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
473+ fsn .setSafeMode (HdfsConstants . SafeModeAction .SAFEMODE_ENTER );
473474 fsn .saveNamespace (0 , 0 );
474475
475476 // Now shut down and restart the NN
@@ -503,7 +504,7 @@ public void testTxIdPersistence() throws Exception {
503504 doAnEdit (fsn , 1 );
504505 assertEquals (2 , fsn .getEditLog ().getLastWrittenTxId ());
505506
506- fsn .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
507+ fsn .setSafeMode (HdfsConstants . SafeModeAction .SAFEMODE_ENTER );
507508 fsn .saveNamespace (0 , 0 );
508509
509510 // 2 more txns: END the first segment, BEGIN a new one
@@ -560,7 +561,7 @@ public void testCancelSaveNamespace() throws Exception {
560561 final Canceler canceler = new Canceler ();
561562
562563 // Save namespace
563- fsn .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
564+ fsn .setSafeMode (HdfsConstants . SafeModeAction .SAFEMODE_ENTER );
564565 try {
565566 Future <Void > saverFuture = pool .submit (new Callable <Void >() {
566567 @ Override
@@ -628,9 +629,9 @@ public void testSaveNamespaceWithRenamedLease() throws Exception {
628629 out = fs .create (new Path ("/test-source/foo" )); // don't close
629630 fs .rename (new Path ("/test-source/" ), new Path ("/test-target/" ));
630631
631- fs .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
632+ fs .setSafeMode (SafeModeAction .ENTER );
632633 cluster .getNameNodeRpc ().saveNamespace (0 , 0 );
633- fs .setSafeMode (SafeModeAction .SAFEMODE_LEAVE );
634+ fs .setSafeMode (SafeModeAction .LEAVE );
634635 } finally {
635636 IOUtils .cleanupWithLogger (LOG , out , fs );
636637 cluster .shutdown ();
@@ -646,9 +647,9 @@ public void testSaveNamespaceWithDanglingLease() throws Exception {
646647 try {
647648 cluster .getNamesystem ().leaseManager .addLease ("me" ,
648649 INodeId .ROOT_INODE_ID + 1 );
649- fs .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
650+ fs .setSafeMode (SafeModeAction .ENTER );
650651 cluster .getNameNodeRpc ().saveNamespace (0 , 0 );
651- fs .setSafeMode (SafeModeAction .SAFEMODE_LEAVE );
652+ fs .setSafeMode (SafeModeAction .LEAVE );
652653 } finally {
653654 cluster .shutdown ();
654655 }
@@ -678,9 +679,9 @@ public void testSkipSnapshotSection() throws Exception {
678679 file .getFileWithSnapshotFeature ().getDiffs () != null );
679680
680681 // saveNamespace
681- fs .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
682+ fs .setSafeMode (SafeModeAction .ENTER );
682683 cluster .getNameNodeRpc ().saveNamespace (0 , 0 );
683- fs .setSafeMode (SafeModeAction .SAFEMODE_LEAVE );
684+ fs .setSafeMode (SafeModeAction .LEAVE );
684685
685686 // restart namenode
686687 cluster .restartNameNode (true );
@@ -708,7 +709,7 @@ public void testSaveNamespaceBeforeShutdown() throws Exception {
708709 final FSImage fsimage = cluster .getNameNode ().getFSImage ();
709710 final long before = fsimage .getStorage ().getMostRecentCheckpointTxId ();
710711
711- fs .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
712+ fs .setSafeMode (SafeModeAction .ENTER );
712713 // set the timewindow to 1 hour and tx gap to 1000, which means that if
713714 // there is a checkpoint during the past 1 hour or the tx number happening
714715 // after the latest checkpoint is <= 1000, this saveNamespace request
@@ -723,14 +724,14 @@ public void testSaveNamespaceBeforeShutdown() throws Exception {
723724 // do another checkpoint. this time set the timewindow to 1s
724725 // we should see a new checkpoint
725726 cluster .getNameNodeRpc ().saveNamespace (1 , 1000 );
726- fs .setSafeMode (SafeModeAction .SAFEMODE_LEAVE );
727+ fs .setSafeMode (SafeModeAction .LEAVE );
727728
728729 after = fsimage .getStorage ().getMostRecentCheckpointTxId ();
729730 Assert .assertTrue (after > before );
730731
731732 fs .mkdirs (new Path ("/foo/bar/baz" )); // 3 new tx
732733
733- fs .setSafeMode (SafeModeAction .SAFEMODE_ENTER );
734+ fs .setSafeMode (SafeModeAction .ENTER );
734735 cluster .getNameNodeRpc ().saveNamespace (3600 , 5 ); // 3 + end/start segment
735736 long after2 = fsimage .getStorage ().getMostRecentCheckpointTxId ();
736737 // no checkpoint should be made
0 commit comments