当前位置: 首页>>代码示例>>Java>>正文


Java Lease类代码示例

本文整理汇总了Java中org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease的典型用法代码示例。如果您正苦于以下问题:Java Lease类的具体用法?Java Lease怎么用?Java Lease使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Lease类属于org.apache.hadoop.hdfs.server.namenode.LeaseManager包,在下文中一共展示了Lease类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRandomFileStats

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * 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();
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:31,代码来源:FSDirectory.java

示例2: internalReleaseLease

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:22,代码来源:FSNamesystem.java

示例3: saveFilesUnderConstruction

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * 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);
      }
    }
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:26,代码来源:FSNamesystem.java

示例4: getRandomFileStats

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * 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, file.getBlocks(), holder));
    }
    return stats;
  } finally {
    readUnlock();
  }
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:24,代码来源:FSDirectory.java

示例5: getLeaseRenewalTime

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * @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();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:NameNodeAdapter.java

示例6: getLeaseForPath

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
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);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:11,代码来源:NameNodeAdapter.java

示例7: reassignLease

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
private Lease reassignLease(Lease lease, String src, 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(), src, newHolder);
  return reassignLeaseInternal(lease, src, newHolder, pendingFile);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:10,代码来源:FSNamesystem.java

示例8: getOpenFiles

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
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());
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:14,代码来源:FSNamesystem.java

示例9: reassignLease

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
Lease reassignLease(Lease lease, String src, String newHolder,
                    INodeFileUnderConstruction pendingFile) {
  if(newHolder == null)
    return lease;
  pendingFile.setClientName(newHolder);
  return leaseManager.reassignLease(lease, src, newHolder);
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:8,代码来源:FSNamesystem.java

示例10: reassignLease

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
private Lease reassignLease(Lease lease, String src, String newHolder,
    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(), src, newHolder);
  return reassignLeaseInternal(lease, src, newHolder, pendingFile);
}
 
开发者ID:ict-carch,项目名称:hadoop-plus,代码行数:10,代码来源:FSNamesystem.java

示例11: getCompleteBlocksTotal

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * 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();
  }
}
 
开发者ID:yncxcw,项目名称:FlexMap,代码行数:34,代码来源:FSNamesystem.java

示例12: internalReleaseLease

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * 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) 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, p);
    }
  } else {
    internalReleaseLeaseOne(lease, src);
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:19,代码来源:FSNamesystem.java

示例13: reassignLease

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
private Lease reassignLease(Lease lease, String src, String newHolder,
                    INodeFileUnderConstruction pendingFile) {
  if(newHolder == null)
    return lease;
  pendingFile.setClientName(newHolder);
  return leaseManager.reassignLease(lease, src, newHolder);
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:8,代码来源:FSNamesystem.java

示例14: saveFilesUnderConstruction

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * 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, cons, path);
      }
    }
  }
}
 
开发者ID:cumulusyebl,项目名称:cumulus,代码行数:31,代码来源:FSNamesystem.java

示例15: saveFilesUnderConstruction

import org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease; //导入依赖的package包/类
/**
 * 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);
      }
    }
  }
}
 
开发者ID:iVCE,项目名称:RDFS,代码行数:30,代码来源:FSNamesystem.java


注:本文中的org.apache.hadoop.hdfs.server.namenode.LeaseManager.Lease类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。