NamespaceInfo getNamespaceInfo() { readLock(); try { return unprotectedGetNamespaceInfo(); } finally { readUnlock("getNamespaceInfo"); } }
protected void readLock() { dir.getFSNamesystem().readLock(); dir.readLock(); }
int getNumberOfDatanodes(DatanodeReportType type) { readLock(); try { return getBlockManager().getDatanodeManager().getDatanodeListForReport( type).size(); } finally { readUnlock("getNumberOfDatanodes"); } }
/** * Get the total number of COMPLETE blocks in the system. * For safe mode only complete blocks are counted. * This is invoked only during NN startup and checkpointing. */ public long getCompleteBlocksTotal() { // Calculate number of blocks under construction long numUCBlocks = 0; readLock(); try { numUCBlocks = leaseManager.getNumUnderConstructionBlocks(); return getBlocksTotal() - numUCBlocks; } finally { readUnlock("getCompleteBlocksTotal"); } }
/** * @return All the existing block storage policies */ BlockStoragePolicy[] getStoragePolicies() throws IOException { checkOperation(OperationCategory.READ); readLock(); try { checkOperation(OperationCategory.READ); return FSDirAttrOp.getStoragePolicies(blockManager); } finally { readUnlock("getStoragePolicies"); } }
long getPreferredBlockSize(String src) throws IOException { checkOperation(OperationCategory.READ); final FSPermissionChecker pc = getPermissionChecker(); readLock(); try { checkOperation(OperationCategory.READ); return FSDirAttrOp.getPreferredBlockSize(dir, pc, src); } finally { readUnlock("getPreferredBlockSize"); } }
void endCheckpoint(NamenodeRegistration registration, CheckpointSignature sig) throws IOException { checkOperation(OperationCategory.CHECKPOINT); readLock(); try { checkOperation(OperationCategory.CHECKPOINT); checkNameNodeSafeMode("Checkpoint not ended"); LOG.info("End checkpoint for " + registration.getAddress()); getFSImage().endCheckpoint(sig); } finally { readUnlock("endCheckpoint"); } }
/** * Renew the lease(s) held by the given client */ void renewLease(String holder) throws IOException { checkOperation(OperationCategory.WRITE); readLock(); try { checkOperation(OperationCategory.WRITE); checkNameNodeSafeMode("Cannot renew lease for " + holder); leaseManager.renewLease(holder); } finally { readUnlock("renewLease"); } }
/** * Get the storage policy for a file or a directory. * * @param src * file/directory path * @return storage policy object */ BlockStoragePolicy getStoragePolicy(String src) throws IOException { checkOperation(OperationCategory.READ); final FSPermissionChecker pc = getPermissionChecker(); readLock(); try { checkOperation(OperationCategory.READ); return FSDirAttrOp.getStoragePolicy(dir, pc, blockManager, src); } finally { readUnlock("getStoragePolicy"); } }
/** * Get all erasure coding polices. */ ErasureCodingPolicyInfo[] getErasureCodingPolicies() throws IOException { final String operationName = "getErasureCodingPolicies"; boolean success = false; checkOperation(OperationCategory.READ); readLock(); try { checkOperation(OperationCategory.READ); final ErasureCodingPolicyInfo[] ret = FSDirErasureCodingOp.getErasureCodingPolicies(this); success = true; return ret; } finally { readUnlock(operationName); logAuditEvent(success, operationName, null); } }
/** * return a list of blocks & their locations on <code>datanode</code> whose * total size is <code>size</code> * * @param datanode on which blocks are located * @param size total size of blocks */ public BlocksWithLocations getBlocks(DatanodeID datanode, long size, long minimumBlockSize) throws IOException { checkOperation(OperationCategory.READ); readLock(); try { checkOperation(OperationCategory.READ); return getBlockManager().getBlocksWithLocations(datanode, size, minimumBlockSize); } finally { readUnlock("getBlocks"); } }
/** * Get available erasure coding codecs and corresponding coders. */ Map<String, String> getErasureCodingCodecs() throws IOException { final String operationName = "getErasureCodingCodecs"; boolean success = false; checkOperation(OperationCategory.READ); readLock(); try { checkOperation(OperationCategory.READ); final Map<String, String> ret = FSDirErasureCodingOp.getErasureCodingCodecs(this); success = true; return ret; } finally { readUnlock(operationName); logAuditEvent(success, operationName, null); } }
private LocatedBlocks getBlockLocations(String path, HdfsFileStatus file) throws IOException { long fileLen = file.getLen(); LocatedBlocks blocks = null; final FSNamesystem fsn = namenode.getNamesystem(); fsn.readLock(); try { blocks = FSDirStatAndListingOp.getBlockLocations( fsn.getFSDirectory(), fsn.getPermissionChecker(), path, 0, fileLen, false) .blocks; } catch (FileNotFoundException fnfe) { blocks = null; } finally { fsn.readUnlock("fsckGetBlockLocations"); } return blocks; }
/** * Returns true if the file is closed */ boolean isFileClosed(final String src) throws IOException { final String operationName = "isFileClosed"; checkOperation(OperationCategory.READ); final FSPermissionChecker pc = getPermissionChecker(); readLock(); try { checkOperation(OperationCategory.READ); return FSDirStatAndListingOp.isFileClosed(dir, pc, src); } catch (AccessControlException e) { logAuditEvent(false, operationName, src); throw e; } finally { readUnlock(operationName); } }
List<XAttr> listXAttrs(String src) throws IOException { final String operationName = "listXAttrs"; checkOperation(OperationCategory.READ); List<XAttr> fsXattrs; final FSPermissionChecker pc = getPermissionChecker(); readLock(); try { checkOperation(OperationCategory.READ); fsXattrs = FSDirXAttrOp.listXAttrs(dir, pc, src); } catch (AccessControlException e) { logAuditEvent(false, operationName, src); throw e; } finally { readUnlock(operationName); } logAuditEvent(true, operationName, src); return fsXattrs; }
AclStatus getAclStatus(String src) throws IOException { final String operationName = "getAclStatus"; checkOperation(OperationCategory.READ); final AclStatus ret; final FSPermissionChecker pc = getPermissionChecker(); readLock(); try { checkOperation(OperationCategory.READ); ret = FSDirAclOp.getAclStatus(dir, pc, src); } catch(AccessControlException ace) { logAuditEvent(false, operationName, src); throw ace; } finally { readUnlock(operationName); } logAuditEvent(true, operationName, src); return ret; }
List<XAttr> getXAttrs(final String src, List<XAttr> xAttrs) throws IOException { final String operationName = "getXAttrs"; checkOperation(OperationCategory.READ); List<XAttr> fsXattrs; final FSPermissionChecker pc = getPermissionChecker(); readLock(); try { checkOperation(OperationCategory.READ); fsXattrs = FSDirXAttrOp.getXAttrs(dir, pc, src, xAttrs); } catch (AccessControlException e) { logAuditEvent(false, operationName, src); throw e; } finally { readUnlock(operationName); } logAuditEvent(true, operationName, src); return fsXattrs; }
BatchedListEntries<CachePoolEntry> listCachePools(String prevKey) throws IOException { final String operationName = "listCachePools"; BatchedListEntries<CachePoolEntry> results; checkOperation(OperationCategory.READ); boolean success = false; cacheManager.waitForRescanIfNeeded(); readLock(); try { checkOperation(OperationCategory.READ); results = FSNDNCacheOp.listCachePools(this, cacheManager, prevKey); success = true; } catch (AccessControlException ace) { logAuditEvent(success, operationName, null, null, null); throw ace; } finally { readUnlock(operationName); } logAuditEvent(success, operationName, null, null, null); return results; }
@VisibleForTesting public ZoneReencryptionStatus getZoneStatus(final String zone) throws IOException { final FSPermissionChecker pc = dir.getPermissionChecker(); final INode inode; dir.getFSNamesystem().readLock(); dir.readLock(); try { final INodesInPath iip = dir.resolvePath(pc, zone, DirOp.READ); inode = iip.getLastINode(); if (inode == null) { return null; } return getReencryptionStatus().getZoneStatus(inode.getId()); } finally { dir.readUnlock(); dir.getFSNamesystem().readUnlock(); } }
DatanodeStorageReport[] getDatanodeStorageReport(final DatanodeReportType type ) throws IOException { String operationName = "getDatanodeStorageReport"; DatanodeStorageReport[] reports; checkSuperuserPrivilege(operationName); checkOperation(OperationCategory.UNCHECKED); readLock(); try { checkOperation(OperationCategory.UNCHECKED); final DatanodeManager dm = getBlockManager().getDatanodeManager(); reports = dm.getDatanodeStorageReport(type); } finally { readUnlock("getDatanodeStorageReport"); } logAuditEvent(true, operationName, null); return reports; }