org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease的实例源码

项目:hadoop-EAR    文件FSDirectory.java   
/**
 * Retrieves a list of random files with some information.
 *
 * @param percent
 *          the percent of files to return
 * @return the list of files
 */
public List<FileStatusExtended> getRandomFileStats(double percent) {
  readLock();
  try {
    List<FileStatusExtended> stats = new LinkedList<FileStatusExtended>();
    for (INodeFile file : getRandomFiles(percent)) {
      try {
        String path = file.getFullPathName();
        FileStatus stat = createFileStatus(path,file);
        Lease lease = this.getFSNamesystem().leaseManager.getLeaseByPath(path);
        String holder = (lease == null) ? null : lease.getHolder();
        long hardlinkId = (file instanceof INodeHardLinkFile) ? ((INodeHardLinkFile) file)
            .getHardLinkID() : -1;
            stats.add(new FileStatusExtended(stat,file.getBlocks(),holder,hardlinkId));
      } catch (IOException ioe) {
        // the file has already been deleted; ingore it
      }
    }
    return stats;
  } finally {
    readUnlock();
  }
}
项目:hadoop-EAR    文件FSNamesystem.java   
/**
 * This is invoked when a lease expires. On lease expiry,* all the files that were written from that dfsclient should be
 * recovered.
 */
void internalReleaseLease(Lease lease,String src,INodeFileUnderConstruction pendingFile) throws IOException {
  if (lease.hasPath()) {
    // make a copy of the paths because internalReleaseLeaSEOne removes
    // pathnames from the lease record.
    String[] leasePaths = new String[lease.getPaths().size()];
    lease.getPaths().toArray(leasePaths);
    LOG.info("Recovering lease: " + lease + " for paths "
        + Arrays.toString(leasePaths));
    for (String p: leasePaths) {
      internalReleaseLeaSEOne(lease,p);
    }
  } else {
    internalReleaseLeaSEOne(lease,src,pendingFile,false);
  }
}
项目:hadoop-on-lustre    文件FSNamesystem.java   
/**
 * Serializes leases. 
 */
void saveFilesUnderConstruction(DataOutputStream out) throws IOException {
  synchronized (leaseManager) {
    out.writeInt(leaseManager.countPath()); // write the size

    for (Lease lease : leaseManager.getSortedLeases()) {
      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;
        FSImage.writeINodeUnderConstruction(out,cons,path);
      }
    }
  }
}
项目:RDFS    文件FSDirectory.java   
/**
 * Retrieves a list of random files with some information.
 * 
 * @param maxFiles
 *          the maximum number of files to return
 * @return the list of files
 */
public List<FileStatusExtended> getRandomFileStats(int maxFiles) {
  readLock();
  try {
    List<FileStatusExtended> stats = new LinkedList<FileStatusExtended>();
    for (INodeFile file : getRandomFiles(maxFiles)) {
      String path = file.getFullPathName();
      FileStatus stat = createFileStatus(path,file);
      Lease lease = this.getFSNamesystem().leaseManager.getLeaseByPath(path);
      String holder = (lease == null) ? null : lease.getHolder();
      stats.add(new FileStatusExtended(stat,holder));
    }
    return stats;
  } finally {
    readUnlock();
  }
}
项目:RDFS    文件FSNamesystem.java   
/**
 * This is invoked when a lease expires. On lease expiry,false);
  }
}
项目:hadoop-0.20    文件FSNamesystem.java   
/**
 * Serializes leases. 
 */
void saveFilesUnderConstruction(DataOutputStream out) throws IOException {
  synchronized (leaseManager) {
    out.writeInt(leaseManager.countPath()); // write the size

    for (Lease lease : leaseManager.getSortedLeases()) {
      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;
        FSImage.writeINodeUnderConstruction(out,path);
      }
    }
  }
}
项目:hortonworks-extension    文件FSNamesystem.java   
/**
 * Serializes leases. 
 */
void saveFilesUnderConstruction(DataOutputStream out) throws IOException {
  synchronized (leaseManager) {
    out.writeInt(leaseManager.countPath()); // write the size

    for (Lease lease : leaseManager.getSortedLeases()) {
      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;
        FSImage.writeINodeUnderConstruction(out,path);
      }
    }
  }
}
项目:hadoop-gpu    文件FSNamesystem.java   
/**
 * Serializes leases. 
 */
void saveFilesUnderConstruction(DataOutputStream out) throws IOException {
  synchronized (leaseManager) {
    out.writeInt(leaseManager.countPath()); // write the size

    for (Lease lease : leaseManager.getSortedLeases()) {
      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;
        FSImage.writeINodeUnderConstruction(out,path);
      }
    }
  }
}
项目:hadoop    文件NameNodeAdapter.java   
/**
 * @return the timestamp of the last renewal of the given lease,*   or -1 in the case that the lease doesn't exist.
 */
public static long getLeaserenewalTime(NameNode nn,String path) {
  LeaseManager lm = nn.getNamesystem().leaseManager;
  Lease l = lm.getLeaseByPath(path);
  if (l == null) {
    return -1;
  }
  return l.getLastUpdate();
}
项目:aliyun-oss-hadoop-fs    文件NameNodeAdapter.java   
public static Lease getLeaseForPath(NameNode nn,String path) {
  final FSNamesystem fsn = nn.getNamesystem();
  INode inode;
  try {
    inode = fsn.getFSDirectory().getINode(path,false);
  } catch (UnresolvedLinkException e) {
    throw new RuntimeException("Lease manager should not support symlinks");
  }
  return inode == null ? null : fsn.leaseManager.getLease((INodeFile) inode);
}
项目:big-c    文件NameNodeAdapter.java   
/**
 * @return the timestamp of the last renewal of the given lease,String path) {
  LeaseManager lm = nn.getNamesystem().leaseManager;
  Lease l = lm.getLeaseByPath(path);
  if (l == null) {
    return -1;
  }
  return l.getLastUpdate();
}
项目:hadoop-2.6.0-cdh5.4.3    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,String newHolder,INodeFile pendingFile) {
  assert hasWriteLock();
  if(newHolder == null)
    return lease;
  // The following transaction is not synced. Make sure it's sync'ed later.
  logReassignLease(lease.getHolder(),newHolder);
  return reassignLeaseInternal(lease,newHolder,pendingFile);
}
项目:hadoop-2.6.0-cdh5.4.3    文件NameNodeAdapter.java   
/**
 * @return the timestamp of the last renewal of the given lease,String path) {
  LeaseManager lm = nn.getNamesystem().leaseManager;
  Lease l = lm.getLeaseByPath(path);
  if (l == null) {
    return -1;
  }
  return l.getLastUpdate();
}
项目:hadoop-EAR    文件FSNamesystem.java   
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());
}
项目:hadoop-EAR    文件FSNamesystem.java   
Lease reassignLease(Lease lease,INodeFileUnderConstruction pendingFile) {
  if(newHolder == null)
    return lease;
  pendingFile.setClientName(newHolder);
  return leaseManager.reassignLease(lease,newHolder);
}
项目:hadoop-plus    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,INodeFileUnderConstruction pendingFile) {
  assert hasWriteLock();
  if(newHolder == null)
    return lease;
  // The following transaction is not synced. Make sure it's sync'ed later.
  logReassignLease(lease.getHolder(),pendingFile);
}
项目:hadoop-plus    文件NameNodeAdapter.java   
/**
 * @return the timestamp of the last renewal of the given lease,String path) {
  LeaseManager lm = nn.getNamesystem().leaseManager;
  Lease l = lm.getLeaseByPath(path);
  if (l == null) {
    return -1;
  }
  return l.getLastUpdate();
}
项目:FlexMap    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,pendingFile);
}
项目:FlexMap    文件FSNamesystem.java   
/**
 * Get the total number of COMPLETE blocks in the system.
 * For safe mode only complete blocks are counted.
 */
private long getCompleteBlocksTotal() {
  // Calculate number of blocks under construction
  long numUCBlocks = 0;
  readLock();
  try {
    for (Lease lease : leaseManager.getSortedLeases()) {
      for (String path : lease.getPaths()) {
        final INodeFile cons;
        try {
          cons = dir.getINode(path).asFile();
          Preconditions.checkState(cons.isUnderConstruction());
        } catch (UnresolvedLinkException e) {
          throw new AssertionError("Lease files should reside on this FS");
        }
        BlockInfo[] blocks = cons.getBlocks();
        if(blocks == null)
          continue;
        for(BlockInfo b : blocks) {
          if(!b.isComplete())
            numUCBlocks++;
        }
      }
    }
    LOG.info("Number of blocks under construction: " + numUCBlocks);
    return getBlocksTotal() - numUCBlocks;
  } finally {
    readUnlock();
  }
}
项目:FlexMap    文件NameNodeAdapter.java   
/**
 * @return the timestamp of the last renewal of the given lease,String path) {
  LeaseManager lm = nn.getNamesystem().leaseManager;
  Lease l = lm.getLeaseByPath(path);
  if (l == null) {
    return -1;
  }
  return l.getLastUpdate();
}
项目:hadoop-TCP    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,pendingFile);
}
项目:hadoop-TCP    文件NameNodeAdapter.java   
/**
 * @return the timestamp of the last renewal of the given lease,String path) {
  LeaseManager lm = nn.getNamesystem().leaseManager;
  Lease l = lm.getLeaseByPath(path);
  if (l == null) {
    return -1;
  }
  return l.getLastUpdate();
}
项目:hadoop-on-lustre    文件FSNamesystem.java   
/**
 * This is invoked when a lease expires. On lease expiry,String src) throws IOException {
  if (lease.hasPath()) {
    // make a copy of the paths because internalReleaseLeaSEOne removes
    // pathnames from the lease record.
    String[] leasePaths = new String[lease.getPaths().size()];
    lease.getPaths().toArray(leasePaths);
    for (String p: leasePaths) {
      internalReleaseLeaSEOne(lease,src);
  }
}
项目:hadoop-on-lustre    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,newHolder);
}
项目:hardfs    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,pendingFile);
}
项目:hardfs    文件NameNodeAdapter.java   
/**
 * @return the timestamp of the last renewal of the given lease,String path) {
  LeaseManager lm = nn.getNamesystem().leaseManager;
  Lease l = lm.getLeaseByPath(path);
  if (l == null) {
    return -1;
  }
  return l.getLastUpdate();
}
项目:hadoop-on-lustre2    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,pendingFile);
}
项目:hadoop-on-lustre2    文件FSNamesystem.java   
/**
 * Get the total number of COMPLETE blocks in the system.
 * For safe mode only complete blocks are counted.
 */
private long getCompleteBlocksTotal() {
  // Calculate number of blocks under construction
  long numUCBlocks = 0;
  readLock();
  try {
    for (Lease lease : leaseManager.getSortedLeases()) {
      for (String path : lease.getPaths()) {
        final INodeFile cons;
        try {
          cons = dir.getINode(path).asFile();
          Preconditions.checkState(cons.isUnderConstruction());
        } catch (UnresolvedLinkException e) {
          throw new AssertionError("Lease files should reside on this FS");
        }
        BlockInfo[] blocks = cons.getBlocks();
        if(blocks == null)
          continue;
        for(BlockInfo b : blocks) {
          if(!b.isComplete())
            numUCBlocks++;
        }
      }
    }
    LOG.info("Number of blocks under construction: " + numUCBlocks);
    return getBlocksTotal() - numUCBlocks;
  } finally {
    readUnlock();
  }
}
项目:hadoop-on-lustre2    文件NameNodeAdapter.java   
/**
 * @return the timestamp of the last renewal of the given lease,String path) {
  LeaseManager lm = nn.getNamesystem().leaseManager;
  Lease l = lm.getLeaseByPath(path);
  if (l == null) {
    return -1;
  }
  return l.getLastUpdate();
}
项目:cumulus    文件FSNamesystem.java   
Lease reassignLease(Lease lease,newHolder);
}
项目:cumulus    文件FSNamesystem.java   
/**
 * Serializes leases. 
 */
void saveFilesUnderConstruction(DataOutputStream out) throws IOException {
  synchronized (leaseManager) {
    out.writeInt(leaseManager.countPath()); // write the size

    for (Lease lease : leaseManager.getSortedLeases()) {
      for(String path : lease.getPaths()) {
        // verify that path exists in namespace
        INode node;
        try {
          node = dir.getFileINode(path);
        } catch (UnresolvedLinkException e) {
          throw new AssertionError("Lease files should reside on this FS");
        }
        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,path);
      }
    }
  }
}
项目:RDFS    文件FSNamesystem.java   
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,this.getGenerationStamp());
}
项目:RDFS    文件FSNamesystem.java   
Lease reassignLease(Lease lease,newHolder);
}
项目:RDFS    文件FSNamesystem.java   
/**
 * 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,path);
      }
    }
  }
}
项目:hortonworks-extension    文件FSNamesystem.java   
/**
 * This is invoked when a lease expires. On lease expiry,src);
  }
}
项目:hortonworks-extension    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,newHolder);
}
项目:hadoop    文件FSNamesystem.java   
private Lease reassignLease(Lease lease,INodeFile pendingFile) {

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...