/** * Changes the replication level of directory or file with the path specified in args. * * @param path The {@link AlluxioURI} path as the input of the command * @param replicationMax the max replicas, null if not to set * @param replicationMin the min replicas, null if not to set * @param recursive Whether change the permission recursively * @throws AlluxioException when Alluxio exception occurs * @throws IOException when non-Alluxio exception occurs */ private void setReplication(AlluxioURI path, Integer replicationMax, Integer replicationMin, boolean recursive) throws AlluxioException, IOException { SetAttributePOptions.Builder optionsBuilder = SetAttributePOptions.newBuilder().setRecursive(recursive); String message = "Changed the replication level of " + path + "\n"; if (replicationMax != null) { optionsBuilder.setReplicationMax(replicationMax); message += "replicationMax was set to " + replicationMax + "\n"; } if (replicationMin != null) { optionsBuilder.setReplicationMin(replicationMin); message += "replicationMin was set to " + replicationMin + "\n"; } mFileSystem.setAttribute(path, optionsBuilder.build()); System.out.println(message); }
@Override public boolean setReplication(Path path, short replication) throws IOException { AlluxioURI uri = new AlluxioURI(HadoopUtils.getPathWithoutScheme(path)); try { if (!mFileSystem.exists(uri) || mFileSystem.getStatus(uri).isFolder()) { return false; } mFileSystem.setAttribute(uri, (SetAttributePOptions) SetAttributePOptions.newBuilder() .setReplicationMin(replication).build()); return true; } catch (AlluxioException e) { throw new IOException(e); } }
setReplicationMin(other.getReplicationMin());