@Override public FSDataOutputStream create(Path path, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { this.acquirePermit("create " + path); return super.create(path, permission, overwrite, bufferSize, replication, blockSize, progress); }
@Override public boolean mkdirs(Path f, FsPermission permission) throws IOException { FsPermission realPermission = getPermAtPathFromMetadataIfPresent(permission, f); return super.mkdirs(f, realPermission); }
@Override public FSDataOutputStream append(Path path, int bufferSize, Progressable progress) throws IOException { this.acquirePermit("append " + path); return super.append(path, bufferSize, progress); }
@Override public FileStatus[] listStatus(Path path) throws IOException { FileStatus[] statuses = super.listStatus(path); if (statuses == null) { acquirePermit("listStatus " + path); } else { acquirePermits(statuses.length / LISTING_FILES_PER_PERMIT + 1, "listStatus " + path); } return statuses; }
@Override public FileStatus[] globStatus(Path pathPattern) throws IOException { FileStatus[] statuses = super.globStatus(pathPattern); if (statuses == null) { acquirePermit("globStatus " + pathPattern); } else { acquirePermits(statuses.length / LISTING_FILES_PER_PERMIT + 1, "globStatus " + pathPattern); } return statuses; }
@Override public void run() { if (!FileSystemInstrumentation.this.closed) { onClose(); } } });
@Override public boolean delete(Path path, boolean recursive) throws IOException { this.acquirePermit("delete " + path); return super.delete(path, recursive); }
@Override public void close() throws IOException { super.close(); // Should print out statistics here }
@Override public FSDataInputStream open(Path path, int bufferSize) throws IOException { this.acquirePermit("open " + path); return super.open(path, bufferSize); }
@Override public FileStatus getFileStatus(Path path) throws IOException { this.acquirePermit("getFileStatus " + path); return super.getFileStatus(path); }
@Override public FileStatus[] listStatus(Path path, PathFilter filter) throws IOException { CountingPathFilterDecorator decoratedFilter = new CountingPathFilterDecorator(filter); FileStatus[] statuses = super.listStatus(path, decoratedFilter); if (statuses == null) { acquirePermit("listStatus " + path); } else { acquirePermits(decoratedFilter.getPathsProcessed().get() / LISTING_FILES_PER_PERMIT + 1, "listStatus " + path); } return statuses; }
/** * Add timer metrics to {@link DistributedFileSystem#globStatus(Path)} */ public FileStatus[] globStatus(Path pathPattern) throws IOException { try (TimerContextWithLog context = new TimerContextWithLog(globStatusTimer.time(), "globStatus", pathPattern)) { FileStatus[] statuses = super.globStatus(pathPattern); context.setResult(statuses); return statuses; } }
@Override public synchronized void close() throws IOException { if (!this.closed) { onClose(); this.closed = true; } super.close(); }
/** * Add timer metrics to {@link DistributedFileSystem#delete(Path, boolean)} */ public boolean delete (Path f, boolean recursive) throws IOException { try (Closeable context = new TimerContextWithLog(deleteTimer.time(), "delete", f, recursive)) { return super.delete (f, recursive); } }
@Override public void close() throws IOException { getRateLimiter().stop(); super.close(); }
/** * Add timer metrics to {@link DistributedFileSystem#open(Path, int)} */ public FSDataInputStream open(Path f, int bufferSize) throws IOException { try (Closeable context = new TimerContextWithLog(this.openTimer.time(), "open", f, bufferSize)) { return super.open(f, bufferSize); } }
/** * Add timer metrics to {@link DistributedFileSystem#getFileStatus(Path)} */ public FileStatus getFileStatus (Path f) throws IOException { try (Closeable context = new TimerContextWithLog(this.getFileStatusTimer.time(), "getFileStatus", f)) { return super.getFileStatus(f); } }
@Override public boolean mkdirs(Path path, FsPermission permission) throws IOException { this.acquirePermit("mkdirs " + path); return super.mkdirs(path, permission); }
@Override public FSDataOutputStream create(Path f, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress) throws IOException { FsPermission realPermission = getPermAtPathFromMetadataIfPresent(permission, f); return super.create(f, realPermission, overwrite, bufferSize, replication, blockSize, progress); }
/** * Add timer metrics to {@link DistributedFileSystem#listStatus(Path)} */ public FileStatus[] listStatus(Path path) throws IOException { try (TimerContextWithLog context = new TimerContextWithLog(listStatusTimer.time(), "listStatus", path)) { FileStatus[] statuses = super.listStatus(path); context.setResult(statuses); return statuses; } }