DistCpOptions { public boolean shouldPreserve(FileAttribute attribute) { return preserveStatus.contains(attribute); } private  DistCpOptions(Builder builder); Path getSourceFileListing(); List<Path> getSourcePaths(); Path getTargetPath(); boolean shouldAtomicCommit(); Path getAtomicWorkPath(); boolean shouldSyncFolder(); boolean shouldDeleteMissing(); boolean shouldIgnoreFailures(); boolean shouldOverwrite(); boolean shouldAppend(); boolean shouldSkipCRC(); boolean shouldBlock(); boolean shouldUseDiff(); boolean shouldUseRdiff(); boolean shouldUseSnapshotDiff(); String getFromSnapshot(); String getToSnapshot(); String getFiltersFile(); Path getLogPath(); String getCopyStrategy(); int getNumListstatusThreads(); int getMaxMaps(); float getMapBandwidth(); Set<FileAttribute> getPreserveAttributes(); boolean shouldPreserve(FileAttribute attribute); int getBlocksPerChunk(); int getCopyBufferSize(); boolean shouldVerboseLog(); Path getTrackPath(); void appendToConf(Configuration conf); @Override String toString(); static final int MAX_NUM_LISTSTATUS_THREADS; }
@Test public void testPreserve() { DistCpOptions options = new DistCpOptions.Builder( new Path("hdfs: new Path("hdfs: .build(); Assert.assertFalse(options.shouldPreserve(FileAttribute.BLOCKSIZE)); Assert.assertFalse(options.shouldPreserve(FileAttribute.REPLICATION)); Assert.assertFalse(options.shouldPreserve(FileAttribute.PERMISSION)); Assert.assertFalse(options.shouldPreserve(FileAttribute.USER)); Assert.assertFalse(options.shouldPreserve(FileAttribute.GROUP)); Assert.assertFalse(options.shouldPreserve(FileAttribute.CHECKSUMTYPE)); options = new DistCpOptions.Builder( new Path("hdfs: new Path("hdfs: .preserve(FileAttribute.ACL) .build(); Assert.assertFalse(options.shouldPreserve(FileAttribute.BLOCKSIZE)); Assert.assertFalse(options.shouldPreserve(FileAttribute.REPLICATION)); Assert.assertFalse(options.shouldPreserve(FileAttribute.PERMISSION)); Assert.assertFalse(options.shouldPreserve(FileAttribute.USER)); Assert.assertFalse(options.shouldPreserve(FileAttribute.GROUP)); Assert.assertFalse(options.shouldPreserve(FileAttribute.CHECKSUMTYPE)); Assert.assertTrue(options.shouldPreserve(FileAttribute.ACL)); options = new DistCpOptions.Builder( new Path("hdfs: new Path("hdfs: .preserve(FileAttribute.BLOCKSIZE) .preserve(FileAttribute.REPLICATION) .preserve(FileAttribute.PERMISSION) .preserve(FileAttribute.USER) .preserve(FileAttribute.GROUP) .preserve(FileAttribute.CHECKSUMTYPE) .build(); Assert.assertTrue(options.shouldPreserve(FileAttribute.BLOCKSIZE)); Assert.assertTrue(options.shouldPreserve(FileAttribute.REPLICATION)); Assert.assertTrue(options.shouldPreserve(FileAttribute.PERMISSION)); Assert.assertTrue(options.shouldPreserve(FileAttribute.USER)); Assert.assertTrue(options.shouldPreserve(FileAttribute.GROUP)); Assert.assertTrue(options.shouldPreserve(FileAttribute.CHECKSUMTYPE)); Assert.assertFalse(options.shouldPreserve(FileAttribute.XATTR)); }