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

项目:hadoop-2.6.0-cdh5.4.3    文件:INodeFile.java   
@Override
public final Quota.Counts computeQuotaUsage(Quota.Counts counts,
    boolean useCache, int lastSnapshotId) {
  long nsDelta = 1;
  final long dsDelta;
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf != null) {
    FileDiffList fileDiffList = sf.getDiffs();
    int last = fileDiffList.getLastSnapshotId();

    if (lastSnapshotId == Snapshot.CURRENT_STATE_ID
        || last == Snapshot.CURRENT_STATE_ID) {
      dsDelta = diskspaceConsumed();
    } else if (last < lastSnapshotId) {
      dsDelta = computeFileSize(true, false) * getFileReplication();
    } else {      
      int sid = fileDiffList.getSnapshotById(lastSnapshotId);
      dsDelta = diskspaceConsumed(sid);
    }
  } else {
    dsDelta = diskspaceConsumed();
  }
  counts.add(Quota.NAMESPACE, nsDelta);
  counts.add(Quota.DISKSPACE, dsDelta);
  return counts;
}
项目:hadoop-2.6.0-cdh5.4.3    文件: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
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf != null) {
    final FileDiffList diffs = sf.getDiffs();
    final int n = diffs.asList().size();
    counts.add(Content.FILE, n);
    if (n > 0 && sf.isCurrentFileDeleted()) {
      counts.add(Content.LENGTH, diffs.getLast().getFileSize());
    }

    if (sf.isCurrentFileDeleted()) {
      final long lastFileSize = diffs.getLast().getFileSize();
      counts.add(Content.DISKSPACE, lastFileSize * getBlockReplication());
    }
  }
}
项目:FlexMap    文件: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
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf != null) {
    final FileDiffList diffs = sf.getDiffs();
    final int n = diffs.asList().size();
    counts.add(Content.FILE, n);
    if (n > 0 && sf.isCurrentFileDeleted()) {
      counts.add(Content.LENGTH, diffs.getLast().getFileSize());
    }

    if (sf.isCurrentFileDeleted()) {
      final long lastFileSize = diffs.getLast().getFileSize();
      counts.add(Content.DISKSPACE, lastFileSize * getBlockReplication());
    }
  }
}
项目:hadoop-on-lustre2    文件: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
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf != null) {
    final FileDiffList diffs = sf.getDiffs();
    final int n = diffs.asList().size();
    counts.add(Content.FILE, n);
    if (n > 0 && sf.isCurrentFileDeleted()) {
      counts.add(Content.LENGTH, diffs.getLast().getFileSize());
    }

    if (sf.isCurrentFileDeleted()) {
      final long lastFileSize = diffs.getLast().getFileSize();
      counts.add(Content.DISKSPACE, lastFileSize * getBlockReplication());
    }
  }
}
项目:hadoop    文件:INodeFile.java   
public FileWithSnapshotFeature addSnapshotFeature(FileDiffList diffs) {
  Preconditions.checkState(!isWithSnapshot(), 
      "File is already with snapshot");
  FileWithSnapshotFeature sf = new FileWithSnapshotFeature(diffs);
  this.addFeature(sf);
  return sf;
}
项目:hadoop    文件:INodeFile.java   
public FileDiffList getDiffs() {
  FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature();
  if (sf != null) {
    return sf.getDiffs();
  }
  return null;
}
项目:hadoop    文件:INodeFile.java   
@Override
public final ContentSummaryComputationContext computeContentSummary(
    final ContentSummaryComputationContext summary) {
  final ContentCounts counts = summary.getCounts();
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  long fileLen = 0;
  if (sf == null) {
    fileLen = computeFileSize();
    counts.addContent(Content.FILE, 1);
  } else {
    final FileDiffList diffs = sf.getDiffs();
    final int n = diffs.asList().size();
    counts.addContent(Content.FILE, n);
    if (n > 0 && sf.isCurrentFileDeleted()) {
      fileLen =  diffs.getLast().getFileSize();
    } else {
      fileLen = computeFileSize();
    }
  }
  counts.addContent(Content.LENGTH, fileLen);
  counts.addContent(Content.DISKSPACE, storagespaceConsumed());

  if (getStoragePolicyID() != ID_UNSPECIFIED){
    BlockStoragePolicy bsp = summary.getBlockStoragePolicySuite().
        getPolicy(getStoragePolicyID());
    List<StorageType> storageTypes = bsp.chooseStorageTypes(getFileReplication());
    for (StorageType t : storageTypes) {
      if (!t.supportTypeQuota()) {
        continue;
      }
      counts.addTypeSpace(t, fileLen);
    }
  }
  return summary;
}
项目:aliyun-oss-hadoop-fs    文件:INodeFile.java   
public FileWithSnapshotFeature addSnapshotFeature(FileDiffList diffs) {
  Preconditions.checkState(!isWithSnapshot(), 
      "File is already with snapshot");
  FileWithSnapshotFeature sf = new FileWithSnapshotFeature(diffs);
  this.addFeature(sf);
  return sf;
}
项目:aliyun-oss-hadoop-fs    文件:INodeFile.java   
public FileDiffList getDiffs() {
  FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature();
  if (sf != null) {
    return sf.getDiffs();
  }
  return null;
}
项目:aliyun-oss-hadoop-fs    文件:TestTruncateQuotaUpdate.java   
private static void addSnapshotFeature(INodeFile file, BlockInfo[] blocks) {
  FileDiff diff = mock(FileDiff.class);
  when(diff.getBlocks()).thenReturn(blocks);
  FileDiffList diffList = new FileDiffList();
  @SuppressWarnings("unchecked")
  ArrayList<FileDiff> diffs = ((ArrayList<FileDiff>)Whitebox.getInternalState
      (diffList, "diffs"));
  diffs.add(diff);
  FileWithSnapshotFeature sf = new FileWithSnapshotFeature(diffList);
  file.addFeature(sf);
}
项目:big-c    文件:INodeFile.java   
public FileWithSnapshotFeature addSnapshotFeature(FileDiffList diffs) {
  Preconditions.checkState(!isWithSnapshot(), 
      "File is already with snapshot");
  FileWithSnapshotFeature sf = new FileWithSnapshotFeature(diffs);
  this.addFeature(sf);
  return sf;
}
项目:big-c    文件:INodeFile.java   
public FileDiffList getDiffs() {
  FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature();
  if (sf != null) {
    return sf.getDiffs();
  }
  return null;
}
项目:big-c    文件:INodeFile.java   
@Override
public final ContentSummaryComputationContext computeContentSummary(
    final ContentSummaryComputationContext summary) {
  final ContentCounts counts = summary.getCounts();
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  long fileLen = 0;
  if (sf == null) {
    fileLen = computeFileSize();
    counts.addContent(Content.FILE, 1);
  } else {
    final FileDiffList diffs = sf.getDiffs();
    final int n = diffs.asList().size();
    counts.addContent(Content.FILE, n);
    if (n > 0 && sf.isCurrentFileDeleted()) {
      fileLen =  diffs.getLast().getFileSize();
    } else {
      fileLen = computeFileSize();
    }
  }
  counts.addContent(Content.LENGTH, fileLen);
  counts.addContent(Content.DISKSPACE, storagespaceConsumed());

  if (getStoragePolicyID() != ID_UNSPECIFIED){
    BlockStoragePolicy bsp = summary.getBlockStoragePolicySuite().
        getPolicy(getStoragePolicyID());
    List<StorageType> storageTypes = bsp.chooseStorageTypes(getFileReplication());
    for (StorageType t : storageTypes) {
      if (!t.supportTypeQuota()) {
        continue;
      }
      counts.addTypeSpace(t, fileLen);
    }
  }
  return summary;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:INodeFile.java   
public FileWithSnapshotFeature addSnapshotFeature(FileDiffList diffs) {
  Preconditions.checkState(!isWithSnapshot(), 
      "File is already with snapshot");
  FileWithSnapshotFeature sf = new FileWithSnapshotFeature(diffs);
  this.addFeature(sf);
  return sf;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:INodeFile.java   
public FileDiffList getDiffs() {
  FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature();
  if (sf != null) {
    return sf.getDiffs();
  }
  return null;
}
项目:FlexMap    文件:INodeFile.java   
public FileWithSnapshotFeature addSnapshotFeature(FileDiffList diffs) {
  Preconditions.checkState(!isWithSnapshot(), 
      "File is already with snapshot");
  FileWithSnapshotFeature sf = new FileWithSnapshotFeature(diffs);
  this.addFeature(sf);
  return sf;
}
项目:FlexMap    文件:INodeFile.java   
public FileDiffList getDiffs() {
  FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature();
  if (sf != null) {
    return sf.getDiffs();
  }
  return null;
}
项目:FlexMap    文件:INodeFile.java   
@Override
public final Quota.Counts computeQuotaUsage(Quota.Counts counts,
    boolean useCache, int lastSnapshotId) {
  long nsDelta = 1;
  final long dsDelta;
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf != null) {
    FileDiffList fileDiffList = sf.getDiffs();
    int last = fileDiffList.getLastSnapshotId();
    List<FileDiff> diffs = fileDiffList.asList();

    if (lastSnapshotId == Snapshot.CURRENT_STATE_ID
        || last == Snapshot.CURRENT_STATE_ID) {
      nsDelta += diffs.size();
      dsDelta = diskspaceConsumed();
    } else if (last < lastSnapshotId) {
      dsDelta = computeFileSize(true, false) * getFileReplication();
    } else {      
      int sid = fileDiffList.getSnapshotById(lastSnapshotId);
      dsDelta = diskspaceConsumed(sid);
    }
  } else {
    dsDelta = diskspaceConsumed();
  }
  counts.add(Quota.NAMESPACE, nsDelta);
  counts.add(Quota.DISKSPACE, dsDelta);
  return counts;
}
项目:hadoop-on-lustre2    文件:INodeFile.java   
public FileWithSnapshotFeature addSnapshotFeature(FileDiffList diffs) {
  Preconditions.checkState(!isWithSnapshot(), 
      "File is already with snapshot");
  FileWithSnapshotFeature sf = new FileWithSnapshotFeature(diffs);
  this.addFeature(sf);
  return sf;
}
项目:hadoop-on-lustre2    文件:INodeFile.java   
public FileDiffList getDiffs() {
  FileWithSnapshotFeature sf = this.getFileWithSnapshotFeature();
  if (sf != null) {
    return sf.getDiffs();
  }
  return null;
}
项目:hadoop-on-lustre2    文件:INodeFile.java   
@Override
public final Quota.Counts computeQuotaUsage(Quota.Counts counts,
    boolean useCache, int lastSnapshotId) {
  long nsDelta = 1;
  final long dsDelta;
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf != null) {
    FileDiffList fileDiffList = sf.getDiffs();
    int last = fileDiffList.getLastSnapshotId();
    List<FileDiff> diffs = fileDiffList.asList();

    if (lastSnapshotId == Snapshot.CURRENT_STATE_ID
        || last == Snapshot.CURRENT_STATE_ID) {
      nsDelta += diffs.size();
      dsDelta = diskspaceConsumed();
    } else if (last < lastSnapshotId) {
      dsDelta = computeFileSize(true, false) * getFileReplication();
    } else {      
      int sid = fileDiffList.getSnapshotById(lastSnapshotId);
      dsDelta = diskspaceConsumed(sid);
    }
  } else {
    dsDelta = diskspaceConsumed();
  }
  counts.add(Quota.NAMESPACE, nsDelta);
  counts.add(Quota.DISKSPACE, dsDelta);
  return counts;
}
项目:hadoop    文件:INodeFile.java   
public INodeFile(INodeFile that, FileDiffList diffs) {
  this(that);
  Preconditions.checkArgument(!that.isWithSnapshot());
  this.addSnapshotFeature(diffs);
}
项目:hadoop    文件:INodeFile.java   
@Override
public final QuotaCounts computeQuotaUsage(
    BlockStoragePolicySuite bsps, byte blockStoragePolicyId,
    QuotaCounts counts, boolean useCache,
    int lastSnapshotId) {
  long nsDelta = 1;
  final long ssDeltaNoReplication;
  short replication;
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf != null) {
    FileDiffList fileDiffList = sf.getDiffs();
    int last = fileDiffList.getLastSnapshotId();

    if (lastSnapshotId == Snapshot.CURRENT_STATE_ID
        || last == Snapshot.CURRENT_STATE_ID) {
      ssDeltaNoReplication = storagespaceConsumedNoReplication();
      replication = getBlockReplication();
    } else if (last < lastSnapshotId) {
      ssDeltaNoReplication = computeFileSize(true, false);
      replication = getFileReplication();
    } else {
      int sid = fileDiffList.getSnapshotById(lastSnapshotId);
      ssDeltaNoReplication = storagespaceConsumedNoReplication(sid);
      replication = getReplication(sid);
    }
  } else {
    ssDeltaNoReplication = storagespaceConsumedNoReplication();
    replication = getBlockReplication();
  }
  counts.addNameSpace(nsDelta);
  counts.addStorageSpace(ssDeltaNoReplication * replication);

  if (blockStoragePolicyId != ID_UNSPECIFIED){
    BlockStoragePolicy bsp = bsps.getPolicy(blockStoragePolicyId);
    List<StorageType> storageTypes = bsp.chooseStorageTypes(replication);
    for (StorageType t : storageTypes) {
      if (!t.supportTypeQuota()) {
        continue;
      }
      counts.addTypeSpace(t, ssDeltaNoReplication);
    }
  }
  return counts;
}
项目:aliyun-oss-hadoop-fs    文件:INodeFile.java   
public INodeFile(INodeFile that, FileDiffList diffs) {
  this(that);
  Preconditions.checkArgument(!that.isWithSnapshot());
  this.addSnapshotFeature(diffs);
}
项目:aliyun-oss-hadoop-fs    文件:INodeFile.java   
@Override
public final QuotaCounts computeQuotaUsage(BlockStoragePolicySuite bsps,
    byte blockStoragePolicyId, boolean useCache, int lastSnapshotId) {
  final QuotaCounts counts = new QuotaCounts.Builder().nameSpace(1).build();

  final BlockStoragePolicy bsp = (blockStoragePolicyId ==
      BLOCK_STORAGE_POLICY_ID_UNSPECIFIED) ? null :
      bsps.getPolicy(blockStoragePolicyId);
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf == null) {
    counts.add(storagespaceConsumed(bsp));
    return counts;
  }

  FileDiffList fileDiffList = sf.getDiffs();
  int last = fileDiffList.getLastSnapshotId();

  if (lastSnapshotId == Snapshot.CURRENT_STATE_ID
      || last == Snapshot.CURRENT_STATE_ID) {
    counts.add(storagespaceConsumed(bsp));
    return counts;
  }

  final long ssDeltaNoReplication;
  short replication;
  if (isStriped()) {
    return computeQuotaUsageWithStriped(bsp, counts);
  }

  if (last < lastSnapshotId) {
    ssDeltaNoReplication = computeFileSize(true, false);
    replication = getFileReplication();
  } else {
    int sid = fileDiffList.getSnapshotById(lastSnapshotId);
    ssDeltaNoReplication = computeFileSize(sid);
    replication = getFileReplication(sid);
  }

  counts.addStorageSpace(ssDeltaNoReplication * replication);
  if (bsp != null) {
    List<StorageType> storageTypes = bsp.chooseStorageTypes(replication);
    for (StorageType t : storageTypes) {
      if (!t.supportTypeQuota()) {
        continue;
      }
      counts.addTypeSpace(t, ssDeltaNoReplication);
    }
  }
  return counts;
}
项目:big-c    文件:INodeFile.java   
public INodeFile(INodeFile that, FileDiffList diffs) {
  this(that);
  Preconditions.checkArgument(!that.isWithSnapshot());
  this.addSnapshotFeature(diffs);
}
项目:big-c    文件:INodeFile.java   
@Override
public final QuotaCounts computeQuotaUsage(
    BlockStoragePolicySuite bsps, byte blockStoragePolicyId,
    QuotaCounts counts, boolean useCache,
    int lastSnapshotId) {
  long nsDelta = 1;
  final long ssDeltaNoReplication;
  short replication;
  FileWithSnapshotFeature sf = getFileWithSnapshotFeature();
  if (sf != null) {
    FileDiffList fileDiffList = sf.getDiffs();
    int last = fileDiffList.getLastSnapshotId();

    if (lastSnapshotId == Snapshot.CURRENT_STATE_ID
        || last == Snapshot.CURRENT_STATE_ID) {
      ssDeltaNoReplication = storagespaceConsumedNoReplication();
      replication = getBlockReplication();
    } else if (last < lastSnapshotId) {
      ssDeltaNoReplication = computeFileSize(true, false);
      replication = getFileReplication();
    } else {
      int sid = fileDiffList.getSnapshotById(lastSnapshotId);
      ssDeltaNoReplication = storagespaceConsumedNoReplication(sid);
      replication = getReplication(sid);
    }
  } else {
    ssDeltaNoReplication = storagespaceConsumedNoReplication();
    replication = getBlockReplication();
  }
  counts.addNameSpace(nsDelta);
  counts.addStorageSpace(ssDeltaNoReplication * replication);

  if (blockStoragePolicyId != ID_UNSPECIFIED){
    BlockStoragePolicy bsp = bsps.getPolicy(blockStoragePolicyId);
    List<StorageType> storageTypes = bsp.chooseStorageTypes(replication);
    for (StorageType t : storageTypes) {
      if (!t.supportTypeQuota()) {
        continue;
      }
      counts.addTypeSpace(t, ssDeltaNoReplication);
    }
  }
  return counts;
}
项目:hadoop-2.6.0-cdh5.4.3    文件:INodeFile.java   
public INodeFile(INodeFile that, FileDiffList diffs) {
  this(that);
  Preconditions.checkArgument(!that.isWithSnapshot());
  this.addSnapshotFeature(diffs);
}
项目:FlexMap    文件:INodeFile.java   
public INodeFile(INodeFile that, FileDiffList diffs) {
  this(that);
  Preconditions.checkArgument(!that.isWithSnapshot());
  this.addSnapshotFeature(diffs);
}
项目:hadoop-on-lustre2    文件:INodeFile.java   
public INodeFile(INodeFile that, FileDiffList diffs) {
  this(that);
  Preconditions.checkArgument(!that.isWithSnapshot());
  this.addSnapshotFeature(diffs);
}