DistCpProcedure extends BalanceProcedure { void disableWrite() throws IOException { if (useMountReadOnly) { String mount = context.getMount(); MountTableProcedure.disableWrite(mount, conf); } else { FileStatus status = srcFs.getFileStatus(src); fPerm = status.getPermission(); acl = srcFs.getAclStatus(src); srcFs.setPermission(src, FsPermission.createImmutable((short) 0)); } updateStage(Stage.FINAL_DISTCP); } DistCpProcedure();  DistCpProcedure(String name, String nextProcedure, long delayDuration,
      FedBalanceContext context); @Override boolean execute(); @Override void write(DataOutput out); @Override void readFields(DataInput in); static final Logger LOG; }
@Test(timeout = 30000) public void testDisableWrite() throws Exception { String testRoot = nnUri + "/user/foo/testdir." + getMethodName(); DistributedFileSystem fs = (DistributedFileSystem) FileSystem.get(URI.create(nnUri), conf); createFiles(fs, testRoot, srcfiles); Path src = new Path(testRoot, SRCDAT); Path dst = new Path(testRoot, DSTDAT); FedBalanceContext context = buildContext(src, dst, MOUNT); DistCpProcedure dcProcedure = new DistCpProcedure("distcp-procedure", null, 1000, context); assertNotEquals(0, fs.getFileStatus(src).getPermission().toShort()); executeProcedure(dcProcedure, Stage.FINAL_DISTCP, () -> dcProcedure.disableWrite()); assertEquals(0, fs.getFileStatus(src).getPermission().toShort()); cleanup(fs, new Path(testRoot)); }