@Test public void testLocalMetadataChange() throws IOException { final String srcPath = "/test"; final String file = "file"; dfs.mkdirs(new Path(srcPath)); FSDataOutputStream out = dfs.create(new Path(srcPath + "/" + file)); out.close(); MetaDataAction metaFileAction = new MetaDataAction(); metaFileAction.setDfsClient(dfsClient); metaFileAction.setContext(smartContext); Map<String, String> args = new HashMap<>(); args.put(MetaDataAction.FILE_PATH, srcPath + "/" + file); args.put(MetaDataAction.OWNER_NAME, "test"); args.put(MetaDataAction.PERMISSION, "777"); metaFileAction.init(args); metaFileAction.run(); Assert.assertTrue(metaFileAction.getExpectedAfterRun()); Assert.assertTrue(dfs.getFileStatus(new Path(srcPath + "/" + file)).getOwner().equals("test")); Assert.assertTrue(dfs.getFileStatus(new Path(srcPath + "/" + file)).getPermission().toString().equals("rwxrwxrwx")); }
@Override public void init(Map<String, String> args) { super.init(args); srcPath = args.get(FILE_PATH); ownerName = null; groupName = null; replication = -1; permission = -1; aTime = -1; mTime = -1; if (args.containsKey(OWNER_NAME)) { this.ownerName = args.get(OWNER_NAME); } if (args.containsKey(GROUP_NAME)) { this.groupName = args.get(GROUP_NAME); } if (args.containsKey(BLOCK_REPLICATION)) { this.replication = Short.parseShort(args.get(BLOCK_REPLICATION)); } if (args.containsKey(PERMISSION)) { FsPermission fsPermission = new FsPermission(args.get(PERMISSION)); this.permission = fsPermission.toShort(); } if (args.containsKey(MTIME)) { this.mTime = Long.parseLong(args.get(MTIME)); } if (args.containsKey(ATIME)) { this.aTime = Long.parseLong(args.get(ATIME)); } }
MetaDataAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); srcPath = args.get(FILE_PATH); ownerName = null; groupName = null; replication = -1; permission = -1; aTime = -1; mTime = -1; if (args.containsKey(OWNER_NAME)) { this.ownerName = args.get(OWNER_NAME); } if (args.containsKey(GROUP_NAME)) { this.groupName = args.get(GROUP_NAME); } if (args.containsKey(BLOCK_REPLICATION)) { this.replication = Short.parseShort(args.get(BLOCK_REPLICATION)); } if (args.containsKey(PERMISSION)) { FsPermission fsPermission = new FsPermission(args.get(PERMISSION)); this.permission = fsPermission.toShort(); } if (args.containsKey(MTIME)) { this.mTime = Long.parseLong(args.get(MTIME)); } if (args.containsKey(ATIME)) { this.aTime = Long.parseLong(args.get(ATIME)); } } }
MetaDataAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); srcPath = args.get(FILE_PATH); ownerName = null; groupName = null; replication = -1; permission = -1; aTime = -1; mTime = -1; if (args.containsKey(OWNER_NAME)) { this.ownerName = args.get(OWNER_NAME); } if (args.containsKey(GROUP_NAME)) { this.groupName = args.get(GROUP_NAME); } if (args.containsKey(BLOCK_REPLICATION)) { this.replication = Short.parseShort(args.get(BLOCK_REPLICATION)); } if (args.containsKey(PERMISSION)) { FsPermission fsPermission = new FsPermission(args.get(PERMISSION)); this.permission = fsPermission.toShort(); } if (args.containsKey(MTIME)) { this.mTime = Long.parseLong(args.get(MTIME)); } if (args.containsKey(ATIME)) { this.aTime = Long.parseLong(args.get(ATIME)); } }  }
MetaDataAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); srcPath = args.get(FILE_PATH); ownerName = null; groupName = null; replication = -1; permission = -1; aTime = -1; mTime = -1; if (args.containsKey(OWNER_NAME)) { this.ownerName = args.get(OWNER_NAME); } if (args.containsKey(GROUP_NAME)) { this.groupName = args.get(GROUP_NAME); } if (args.containsKey(BLOCK_REPLICATION)) { this.replication = Short.parseShort(args.get(BLOCK_REPLICATION)); } if (args.containsKey(PERMISSION)) { FsPermission fsPermission = new FsPermission(args.get(PERMISSION)); this.permission = fsPermission.toShort(); } if (args.containsKey(MTIME)) { this.mTime = Long.parseLong(args.get(MTIME)); } if (args.containsKey(ATIME)) { this.aTime = Long.parseLong(args.get(ATIME)); } }  @Override void init(Map<String, String> args); }
MetaDataAction extends HdfsAction { @Override public void init(Map<String, String> args) { super.init(args); srcPath = args.get(FILE_PATH); ownerName = null; groupName = null; replication = -1; permission = -1; aTime = -1; mTime = -1; if (args.containsKey(OWNER_NAME)) { this.ownerName = args.get(OWNER_NAME); } if (args.containsKey(GROUP_NAME)) { this.groupName = args.get(GROUP_NAME); } if (args.containsKey(BLOCK_REPLICATION)) { this.replication = Short.parseShort(args.get(BLOCK_REPLICATION)); } if (args.containsKey(PERMISSION)) { FsPermission fsPermission = new FsPermission(args.get(PERMISSION)); this.permission = fsPermission.toShort(); } if (args.containsKey(MTIME)) { this.mTime = Long.parseLong(args.get(MTIME)); } if (args.containsKey(ATIME)) { this.aTime = Long.parseLong(args.get(ATIME)); } }  @Override void init(Map<String, String> args); static final String OWNER_NAME; static final String GROUP_NAME; static final String BLOCK_REPLICATION; static final String PERMISSION; static final String MTIME; static final String ATIME; }