Java 类org.apache.hadoop.hdfs.server.namenode.snapshot.FileWithSnapshot.FileDiffList 实例源码

项目:hadoop-plus    文件:INodeFile.java   
@Override
public final Quota.Counts computeQuotaUsage(Quota.Counts counts,
    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();
  }
  counts.add(Quota.NAMESPACE, nsDelta);
  counts.add(Quota.DISKSPACE, dsDelta);
  return counts;
}
项目:hadoop-plus    文件:INodeFile.java   
private void computeContentSummary4Snapshot(final Content.Counts counts) {
  // file length and diskspace only counted for the latest state of the file
  // i.e. either the current state or the last snapshot
  if (this instanceof FileWithSnapshot) {
    final FileWithSnapshot withSnapshot = (FileWithSnapshot)this;
    final FileDiffList diffs = withSnapshot.getDiffs();
    final int n = diffs.asList().size();
    counts.add(Content.FILE, n);
    if (n > 0 && withSnapshot.isCurrentFileDeleted()) {
      counts.add(Content.LENGTH, diffs.getLast().getFileSize());
    }

    if (withSnapshot.isCurrentFileDeleted()) {
      final long lastFileSize = diffs.getLast().getFileSize();
      counts.add(Content.DISKSPACE, lastFileSize * getBlockReplication());
    }
  }
}
项目:hadoop-plus    文件:SnapshotFSImageFormat.java   
public static FileDiffList loadFileDiffList(DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (size == -1) {
    return null;
  } else {
    final FileDiffList diffs = new FileDiffList();
    FileDiff posterior = null;
    for(int i = 0; i < size; i++) {
      final FileDiff d = loadFileDiff(posterior, in, loader);
      diffs.addFirst(d);
      posterior = d;
    }
    return diffs;
  }
}
项目:hadoop-TCP    文件:INodeFile.java   
@Override
public final Quota.Counts computeQuotaUsage(Quota.Counts counts,
    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();
  }
  counts.add(Quota.NAMESPACE, nsDelta);
  counts.add(Quota.DISKSPACE, dsDelta);
  return counts;
}
项目:hadoop-TCP    文件:INodeFile.java   
private void computeContentSummary4Snapshot(final Content.Counts counts) {
  // file length and diskspace only counted for the latest state of the file
  // i.e. either the current state or the last snapshot
  if (this instanceof FileWithSnapshot) {
    final FileWithSnapshot withSnapshot = (FileWithSnapshot)this;
    final FileDiffList diffs = withSnapshot.getDiffs();
    final int n = diffs.asList().size();
    counts.add(Content.FILE, n);
    if (n > 0 && withSnapshot.isCurrentFileDeleted()) {
      counts.add(Content.LENGTH, diffs.getLast().getFileSize());
    }

    if (withSnapshot.isCurrentFileDeleted()) {
      final long lastFileSize = diffs.getLast().getFileSize();
      counts.add(Content.DISKSPACE, lastFileSize * getBlockReplication());
    }
  }
}
项目:hadoop-TCP    文件:SnapshotFSImageFormat.java   
public static FileDiffList loadFileDiffList(DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (size == -1) {
    return null;
  } else {
    final FileDiffList diffs = new FileDiffList();
    FileDiff posterior = null;
    for(int i = 0; i < size; i++) {
      final FileDiff d = loadFileDiff(posterior, in, loader);
      diffs.addFirst(d);
      posterior = d;
    }
    return diffs;
  }
}
项目:hardfs    文件:INodeFile.java   
@Override
public final Quota.Counts computeQuotaUsage(Quota.Counts counts,
    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();
  }
  counts.add(Quota.NAMESPACE, nsDelta);
  counts.add(Quota.DISKSPACE, dsDelta);
  return counts;
}
项目:hardfs    文件:INodeFile.java   
private void computeContentSummary4Snapshot(final Content.Counts counts) {
  // file length and diskspace only counted for the latest state of the file
  // i.e. either the current state or the last snapshot
  if (this instanceof FileWithSnapshot) {
    final FileWithSnapshot withSnapshot = (FileWithSnapshot)this;
    final FileDiffList diffs = withSnapshot.getDiffs();
    final int n = diffs.asList().size();
    counts.add(Content.FILE, n);
    if (n > 0 && withSnapshot.isCurrentFileDeleted()) {
      counts.add(Content.LENGTH, diffs.getLast().getFileSize());
    }

    if (withSnapshot.isCurrentFileDeleted()) {
      final long lastFileSize = diffs.getLast().getFileSize();
      counts.add(Content.DISKSPACE, lastFileSize * getBlockReplication());
    }
  }
}
项目:hardfs    文件:SnapshotFSImageFormat.java   
public static FileDiffList loadFileDiffList(DataInput in,
    FSImageFormat.Loader loader) throws IOException {
  final int size = in.readInt();
  if (size == -1) {
    return null;
  } else {
    final FileDiffList diffs = new FileDiffList();
    FileDiff posterior = null;
    for(int i = 0; i < size; i++) {
      final FileDiff d = loadFileDiff(posterior, in, loader);
      diffs.addFirst(d);
      posterior = d;
    }
    return diffs;
  }
}