Package org.apache.hadoop.hdfs.server.namenode.snapshot

Examples of org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot


      }
    }
   
    private Snapshot getSelfSnapshot() {
      INode referred = getReferredINode().asReference().getReferredINode();
      Snapshot snapshot = null;
      if (referred instanceof FileWithSnapshot) {
        snapshot = ((FileWithSnapshot) referred).getDiffs().getPrior(
            lastSnapshotId);
      } else if (referred instanceof INodeDirectoryWithSnapshot) {
        snapshot = ((INodeDirectoryWithSnapshot) referred).getDiffs().getPrior(
View Full Code Here


        getReferredINode().destroyAndCollectBlocks(collectedBlocks,
            removedINodes);
      } else {
        // we will clean everything, including files, directories, and
        // snapshots, that were created after this prior snapshot
        Snapshot prior = getPriorSnapshot(this);
        // prior must be non-null, otherwise we do not have any previous
        // WithName nodes, and the reference number will be 0.
        Preconditions.checkState(prior != null);
        // identify the snapshot created after prior
        Snapshot snapshot = getSelfSnapshot(prior);
       
        INode referred = getReferredINode().asReference().getReferredINode();
        if (referred instanceof FileWithSnapshot) {
          // if referred is a file, it must be a FileWithSnapshot since we did
          // recordModification before the rename
View Full Code Here

    }
   
    private Snapshot getSelfSnapshot(final Snapshot prior) {
      WithCount wc = (WithCount) getReferredINode().asReference();
      INode referred = wc.getReferredINode();
      Snapshot lastSnapshot = null;
      if (referred instanceof FileWithSnapshot) {
        lastSnapshot = ((FileWithSnapshot) referred).getDiffs()
            .getLastSnapshot();
      } else if (referred instanceof INodeDirectoryWithSnapshot) {
        lastSnapshot = ((INodeDirectoryWithSnapshot) referred)
            .getLastSnapshot();
      }
      if (lastSnapshot != null && !lastSnapshot.equals(prior)) {
        return lastSnapshot;
      } else {
        return null;
      }
    }
View Full Code Here

    // in case of deletion snapshot, since this call happens after we modify
    // the diff list, the snapshot to be deleted has been combined or renamed
    // to its latest previous snapshot. (besides, we also need to consider nodes
    // created after prior but before snapshot. this will be done in
    // INodeDirectoryWithSnapshot#cleanSubtree)
    Snapshot s = snapshot != null && prior != null ? prior : snapshot;
    for (INode child : getChildrenList(s)) {
      if (snapshot != null && excludedNodes != null
          && excludedNodes.containsKey(child)) {
        continue;
      } else {
View Full Code Here

          + ", resolveLink=" + resolveLink);
    }
    // check if (parentAccess != null) && file exists, then check sb
    // If resolveLink, the check is performed on the link target.
    final INodesInPath inodesInPath = root.getINodesInPath(path, resolveLink);
    final Snapshot snapshot = inodesInPath.getPathSnapshot();
    final INode[] inodes = inodesInPath.getINodes();
    int ancestorIndex = inodes.length - 2;
    for(; ancestorIndex >= 0 && inodes[ancestorIndex] == null;
        ancestorIndex--);
    checkTraverse(inodes, ancestorIndex, snapshot);
View Full Code Here

      if (withCount == null) {
        srcChild.setLocalName(dstChildName);
        toDst = srcChild;
      } else {
        withCount.getReferredINode().setLocalName(dstChildName);
        Snapshot dstSnapshot = dstIIP.getLatestSnapshot();
        final INodeReference.DstReference ref = new INodeReference.DstReference(
            dstParent.asDirectory(), withCount,
            dstSnapshot == null ? Snapshot.INVALID_ID : dstSnapshot.getId());
        toDst = ref;
      }
     
      added = addLastINodeNoQuotaCheck(dstIIP, toDst);
      if (added) {
View Full Code Here

      if (withCount == null) {
        srcChild.setLocalName(dstChildName);
        toDst = srcChild;
      } else {
        withCount.getReferredINode().setLocalName(dstChildName);
        Snapshot dstSnapshot = dstIIP.getLatestSnapshot();
        final INodeReference.DstReference ref = new INodeReference.DstReference(
            dstIIP.getINode(-2).asDirectory(), withCount,
            dstSnapshot == null ? Snapshot.INVALID_ID : dstSnapshot.getId());
        toDst = ref;
      }

      // add src as dst to complete rename
      if (addLastINodeNoQuotaCheck(dstIIP, toDst)) {
View Full Code Here

   
    final INodesInPath trgIIP = rootDir.getINodesInPath4Write(target, true);
    final INode[] trgINodes = trgIIP.getINodes();
    final INodeFile trgInode = trgIIP.getLastINode().asFile();
    INodeDirectory trgParent = trgINodes[trgINodes.length-2].asDirectory();
    final Snapshot trgLatestSnapshot = trgIIP.getLatestSnapshot();
   
    final INodeFile [] allSrcInodes = new INodeFile[srcs.length];
    for(int i = 0; i < srcs.length; i++) {
      final INodesInPath iip = getINodesInPath4Write(srcs[i]);
      final Snapshot latest = iip.getLatestSnapshot();
      final INode inode = iip.getLastINode();

      // check if the file in the latest snapshot
      if (inode.isInLatestSnapshot(latest)) {
        throw new SnapshotException("Concat: the source file " + srcs[i]
View Full Code Here

      final INode inode = inodesInPath.getINode(0);
      if (inode == null || !inode.isDirectory()) {
        //not found or not a directory
        return false;
      }
      final Snapshot s = inodesInPath.getPathSnapshot();
      return !inode.asDirectory().getChildrenList(s).isEmpty();
    } finally {
      readUnlock();
    }
  }
View Full Code Here

    if (targetNode == null) {
      return -1;
    }

    // record modification
    final Snapshot latestSnapshot = iip.getLatestSnapshot();
    targetNode = targetNode.recordModification(latestSnapshot, inodeMap);
    iip.setLastINode(targetNode);

    // Remove the node from the namespace
    long removed = removeLastINode(iip);
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hdfs.server.namenode.snapshot.Snapshot

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.