@Test public void testMoverFailedRetry() throws Exception { final Configuration conf = new HdfsConfiguration(); conf.set(DFSConfigKeys.DFS_MOVER_RETRY_MAX_ATTEMPTS_KEY, "2"); final MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) .numDataNodes(3) .storageTypes( new StorageType[][] {{StorageType.DISK, StorageType.ARCHIVE}, {StorageType.DISK, StorageType.ARCHIVE}, {StorageType.DISK, StorageType.ARCHIVE}}).build(); try { cluster.waitActive(); final DistributedFileSystem dfs = cluster.getFileSystem(); final String file = "/testMoverFailedRetry"; final FSDataOutputStream out = dfs.create(new Path(file), (short) 2); out.writeChars("testMoverFailedRetry"); out.close(); LocatedBlock lb = dfs.getClient().getLocatedBlocks(file, 0).get(0); cluster.corruptBlockOnDataNodesByDeletingBlockFile(lb.getBlock()); dfs.setStoragePolicy(new Path(file), "COLD"); int rc = ToolRunner.run(conf, new Mover.Cli(), new String[] {"-p", file.toString()}); Assert.assertEquals("Movement should fail after some retry", ExitStatus.IO_EXCEPTION.getExitCode(), rc); } finally { cluster.shutdown(); } }
private ExitStatus run() { try { init(); boolean hasRemaining = new Processor().processNamespace(); return hasRemaining ? ExitStatus.IN_PROGRESS : ExitStatus.SUCCESS; } catch (IllegalArgumentException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.ILLEGAL_ARGUMENTS; } catch (IOException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.IO_EXCEPTION; } finally { dispatcher.shutdownNow(); } }
Mover { private ExitStatus run() { try { init(); boolean hasRemaining = new Processor().processNamespace(); return hasRemaining ? ExitStatus.IN_PROGRESS : ExitStatus.SUCCESS; } catch (IllegalArgumentException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.ILLEGAL_ARGUMENTS; } catch (IOException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.IO_EXCEPTION; } finally { dispatcher.shutdownNow(); } } }
Mover { private ExitStatus run() { try { init(); boolean hasRemaining = new Processor().processNamespace(); return hasRemaining ? ExitStatus.IN_PROGRESS : ExitStatus.SUCCESS; } catch (IllegalArgumentException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.ILLEGAL_ARGUMENTS; } catch (IOException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.IO_EXCEPTION; } finally { dispatcher.shutdownNow(); } } Mover(NameNodeConnector nnc, Configuration conf, AtomicInteger retryCount); }
Mover { private ExitStatus run() { try { init(); boolean hasRemaining = new Processor().processNamespace(); return hasRemaining ? ExitStatus.IN_PROGRESS : ExitStatus.SUCCESS; } catch (IllegalArgumentException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.ILLEGAL_ARGUMENTS; } catch (IOException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.IO_EXCEPTION; } finally { dispatcher.shutdownNow(); } } Mover(NameNodeConnector nnc, Configuration conf, AtomicInteger retryCount); static void main(String[] args); }
Mover { private ExitStatus run() { try { init(); boolean hasRemaining = new Processor().processNamespace(); return hasRemaining ? ExitStatus.IN_PROGRESS : ExitStatus.SUCCESS; } catch (IllegalArgumentException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.ILLEGAL_ARGUMENTS; } catch (IOException e) { System.out.println(e + ". Exiting ..."); return ExitStatus.IO_EXCEPTION; } finally { dispatcher.shutdownNow(); } } Mover(NameNodeConnector nnc, Configuration conf, AtomicInteger retryCount); static void main(String[] args);  }