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

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


    }
   
    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


        // the latest snapshot if lastComp is true. In case of the operation is
        // a modification operation, we do a similar check in corresponding
        // recordModification method.
        if (!existing.isSnapshot()) {
          int dstSnapshotId = curNode.asReference().getDstSnapshotId();
          Snapshot latest = existing.getLatestSnapshot();
          if (latest == null ||  // no snapshot in dst tree of rename
              dstSnapshotId >= latest.getId()) { // the above scenario
            Snapshot lastSnapshot = null;
            if (curNode.isDirectory()
                && curNode.asDirectory() instanceof INodeDirectoryWithSnapshot) {
              lastSnapshot = ((INodeDirectoryWithSnapshot) curNode
                  .asDirectory()).getLastSnapshot();
            }
            existing.setSnapshot(lastSnapshot);
          }
        }
      }
      if (curNode.isSymlink() && (!lastComp || (lastComp && resolveLink))) {
        final String path = constructPath(components, 0, components.length);
        final String preceding = constructPath(components, 0, count);
        final String remainder =
          constructPath(components, count + 1, components.length);
        final String link = DFSUtil.bytes2String(components[count]);
        final String target = curNode.asSymlink().getSymlinkString();
        if (LOG.isDebugEnabled()) {
          LOG.debug("UnresolvedPathException " +
            " path: " + path + " preceding: " + preceding +
            " count: " + count + " link: " + link + " target: " + target +
            " remainder: " + remainder);
        }
        throw new UnresolvedPathException(path, preceding, remainder, target);
      }
      if (lastComp || !isDir) {
        break;
      }
      final byte[] childName = components[count + 1];
     
      // check if the next byte[] in components is for ".snapshot"
      if (isDotSnapshotDir(childName)
          && isDir && dir instanceof INodeDirectorySnapshottable) {
        // skip the ".snapshot" in components
        count++;
        index++;
        existing.isSnapshot = true;
        if (index >= 0) { // decrease the capacity by 1 to account for .snapshot
          existing.capacity--;
        }
        // check if ".snapshot" is the last element of components
        if (count == components.length - 1) {
          break;
        }
        // Resolve snapshot root
        final Snapshot s = ((INodeDirectorySnapshottable)dir).getSnapshot(
            components[count + 1]);
        if (s == null) {
          //snapshot not found
          curNode = null;
        } else {
          curNode = s.getRoot();
          existing.setSnapshot(s);
        }
        if (index >= -1) {
          existing.snapshotRootIndex = existing.numNonNull;
        }
View Full Code Here

      boolean useCache, int lastSnapshotId) {
    long nsDelta = 1;
    final long dsDelta;
    if (this instanceof FileWithSnapshot) {
      FileDiffList fileDiffList = ((FileWithSnapshot) this).getDiffs();
      Snapshot last = fileDiffList.getLastSnapshot();
      List<FileDiff> diffs = fileDiffList.asList();

      if (lastSnapshotId == Snapshot.INVALID_ID || last == null) {
        nsDelta += diffs.size();
        dsDelta = diskspaceConsumed();
      } else if (last.getId() < lastSnapshotId) {
        dsDelta = computeFileSize(true, false) * getFileReplication();
      } else {     
        Snapshot s = fileDiffList.getSnapshotById(lastSnapshotId);
        dsDelta = diskspaceConsumed(s);
      }
    } else {
      dsDelta = diskspaceConsumed();
    }
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

      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

    try {
      if (srcs.endsWith(HdfsConstants.SEPARATOR_DOT_SNAPSHOT_DIR)) {
        return getSnapshotsListing(srcs, startAfter);
      }
      final INodesInPath inodesInPath = rootDir.getLastINodeInPath(srcs, true);
      final Snapshot snapshot = inodesInPath.getPathSnapshot();
      final INode targetNode = inodesInPath.getINode(0);
      if (targetNode == null)
        return null;
     
      if (!targetNode.isDirectory()) {
View Full Code Here

TOP

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

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.