public OpenFilesInfo getOpenFiles() throws IOException { List <FileStatusExtended> openFiles = new ArrayList <FileStatusExtended>(); for (Lease lease : leaseManager.getSortedLeases()) { for (String path : lease.getPaths()) { FileStatusExtended stat = this.getFileInfoExtended(path, lease.getHolder()); if (stat != null) { openFiles.add(stat); } } } return new OpenFilesInfo(openFiles, this.getGenerationStamp()); }
/** * Serializes leases. */ void saveFilesUnderConstruction(DataOutputStream out) throws IOException { synchronized (leaseManager) { out.writeInt(leaseManager.countPath()); // write the size for (Lease lease : leaseManager.getSortedLeases()) { Collection<StringBytesWritable> files = lease.getPaths(); for (Iterator<StringBytesWritable> i = files.iterator(); i.hasNext();){ String path = i.next().getString(); // verify that path exists in namespace INode node = dir.getFileINode(path); if (node == null) { throw new IOException("saveLeases found path " + path + " but no matching entry in namespace."); } if (!node.isUnderConstruction()) { throw new IOException("saveLeases found path " + path + " but is not under construction."); } INodeFileUnderConstruction cons = (INodeFileUnderConstruction) node; FSImage.writeINodeUnderConstruction(out, cons, path); } } } } }
/** * Serializes leases. */ void saveFilesUnderConstruction(SaveNamespaceContext ctx, DataOutputStream out) throws IOException { synchronized (leaseManager) { out.writeInt(leaseManager.countPath()); // write the size LightWeightLinkedSet<Lease> sortedLeases = leaseManager.getSortedLeases(); Iterator<Lease> itr = sortedLeases.iterator(); while (itr.hasNext()) { ctx.checkCancelled(); Lease lease = itr.next(); for (String path : lease.getPaths()) { // verify that path exists in namespace INode node = dir.getFileINode(path); if (node == null) { throw new IOException("saveLeases found path " + path + " but no matching entry in namespace."); } if (!node.isUnderConstruction()) { throw new IOException("saveLeases found path " + path + " but is not under construction."); } INodeFileUnderConstruction cons = (INodeFileUnderConstruction) node; FSImageSerialization.writeINodeUnderConstruction(out, cons, path); } } } }