Package org.apache.hadoop.hdfs.server.datanode.FSDataset

Examples of org.apache.hadoop.hdfs.server.datanode.FSDataset.ActiveFile


   */
  void copyOngoingCreates(int namespaceId, Block block) throws CloneNotSupportedException {
    checkBlock(block);
    synchronized(this){
      Map<Block, ActiveFile> m = ongoingCreates.get(namespaceId);
      ActiveFile af = m.get(block);
      if (af == null) {
        return;
      }
     
      m.put(block, af.getClone());
    }
  }
View Full Code Here


  public void finalizeBlockInternal(int namespaceId, Block b, boolean reFinalizeOk)
    throws IOException {
    lock.writeLock().lock();
    DatanodeBlockInfo replicaInfo = volumeMap.get(namespaceId, b);
    try {
      ActiveFile activeFile = volumeMap.getOngoingCreates(namespaceId, b);
      if (activeFile == null) {
        if (reFinalizeOk) {
          return;
        } else {
          throw new IOException("Block " + b + " is already finalized.");
        }
      }
      File f = activeFile.file;
      if (f == null || !f.exists()) {
        throw new IOException("No temporary file " + f + " for block " + b);
      }
      FSVolume v = replicaInfo.getVolume();
      if (v == null) {
        throw new IOException("No volume for temporary file " + f +
                              " for block " + b);
      }
         
      File dest = null;
      dest = v.addBlock(namespaceId, b, f);
      volumeMap.add(namespaceId, b,
          new DatanodeBlockInfo(v, dest, activeFile.getBytesOnDisk()));
      volumeMap.removeOngoingCreates(namespaceId, b);
    } finally {
      lock.writeLock().unlock();
    }
  }
View Full Code Here

    FSVolume v = blockInfo.getVolume();
    if (v == null) {
      DataNode.LOG.warn("No volume for block " + b);
      return false; // block is not finalized
    }
    ActiveFile activeFile = volumeMap.getOngoingCreates(namespaceId, b);
    if (activeFile != null) {
      if (validate) {
        File f = activeFile.file;
        if (f == null || !f.exists()) {
          // we should never get into this position.
View Full Code Here

   */
  public void unfinalizeBlock(int namespaceId, Block b) throws IOException {
    lock.writeLock().lock();
    try {
      // remove the block from in-memory data structure
      ActiveFile activefile = volumeMap.removeOngoingCreates(namespaceId, b);
      if (activefile == null) {
        return;
      }
      volumeMap.remove(namespaceId, b);
     
View Full Code Here

      if (stored == null) {
        return null;
      }

      ActiveFile activeFile = volumeMap.getOngoingCreates(namespaceId, stored);
      boolean isRecovery = (activeFile != null) && activeFile.wasRecoveredOnStartup;


      BlockRecoveryInfo info = new BlockRecoveryInfo(stored, isRecovery);
      if (DataNode.LOG.isDebugEnabled()) {
View Full Code Here

    List<Thread> threads = null;
    // We do not want to create a BBW, hence treat this as a replication
    // request.
    File dstBlockFile = createTmpFile(dstNamespaceId, dstVol, dstBlock, true);
    volumeMap.addOngoingCreates(dstNamespaceId, dstBlock,
        new ActiveFile(dstBlockFile, threads));
    return dstBlockFile;
  }
View Full Code Here

     * of this constructor is.
     * @throws IOException
     */
    public static ActiveFile createStartupRecoveryFile(File f)
        throws IOException {
      return new ActiveFile(f, true, UNKNOWN_SIZE);
    }
View Full Code Here

  public File findBlockFile(int namespaceId, long blockId) {
    lock.readLock().lock();
    try {
      final Block eb = new Block(blockId);
      File blockfile = null;
      ActiveFile activefile = volumeMap.getOngoingCreates(namespaceId, eb);
      if (activefile != null) {
        blockfile = activefile.file;
      }
      if (blockfile == null) {
        blockfile = getFile(namespaceId, eb);
View Full Code Here

    return info.getFinalizedSize();
  }

  @Override
  public long getOnDiskLength(int namespaceId, Block b) throws IOException {
    ActiveFile activeFile = volumeMap.getOngoingCreates(namespaceId, b);

    if (activeFile != null) {
      return activeFile.getBytesOnDisk();
    } else {
      return getFinalizedBlockLength(namespaceId, b);
    }
  }
View Full Code Here

    }
  }

  @Override
  public long getVisibleLength(int namespaceId, Block b) throws IOException {
    ActiveFile activeFile = volumeMap.getOngoingCreates(namespaceId, b);

    if (activeFile != null) {
      return activeFile.getBytesAcked();
    } else {
      return getFinalizedBlockLength(namespaceId, b);
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.datanode.FSDataset.ActiveFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.