return; int p = getPrior(removed.getSnapshotId(), true); FileDiff earlierDiff = p == Snapshot.NO_SNAPSHOT_ID ? null : getDiffById(p); (earlierDiff == null ? new BlockInfoContiguous[]{} : earlierDiff.getBlocks()); BlockInfo[] laterBlocks = findLaterSnapshotBlocks(removed.getSnapshotId()); laterBlocks = (laterBlocks == null) ? file.getBlocks() : laterBlocks;
private void serializeFileDiffList(INodeFile file, OutputStream out) throws IOException { FileWithSnapshotFeature sf = file.getFileWithSnapshotFeature(); if (sf != null) { DiffList<FileDiff> diffList = sf.getDiffs().asList(); SnapshotDiffSection.DiffEntry entry = SnapshotDiffSection.DiffEntry .newBuilder().setInodeId(file.getId()).setType(Type.FILEDIFF) .setNumOfDiff(diffList.size()).build(); entry.writeDelimitedTo(out); for (int i = diffList.size() - 1; i >= 0; i--) { FileDiff diff = diffList.get(i); SnapshotDiffSection.FileDiff.Builder fb = SnapshotDiffSection.FileDiff .newBuilder().setSnapshotId(diff.getSnapshotId()) .setFileSize(diff.getFileSize()); if(diff.getBlocks() != null) { for(Block block : diff.getBlocks()) { fb.addBlocks(PBHelperClient.convert(block)); } } INodeFileAttributes copy = diff.snapshotINode; if (copy != null) { fb.setName(ByteString.copyFrom(copy.getLocalNameBytes())) .setSnapshotCopy(buildINodeFile(copy, parent.getSaverContext())); } fb.build().writeDelimitedTo(out); } } }
private void serializeFileDiffList(INodeFile file, OutputStream out) throws IOException { FileWithSnapshotFeature sf = file.getFileWithSnapshotFeature(); if (sf != null) { List<FileDiff> diffList = sf.getDiffs().asList(); SnapshotDiffSection.DiffEntry entry = SnapshotDiffSection.DiffEntry .newBuilder().setInodeId(file.getId()).setType(Type.FILEDIFF) .setNumOfDiff(diffList.size()).build(); entry.writeDelimitedTo(out); for (int i = diffList.size() - 1; i >= 0; i--) { FileDiff diff = diffList.get(i); SnapshotDiffSection.FileDiff.Builder fb = SnapshotDiffSection.FileDiff .newBuilder().setSnapshotId(diff.getSnapshotId()) .setFileSize(diff.getFileSize()); if(diff.getBlocks() != null) { for(Block block : diff.getBlocks()) { fb.addBlocks(PBHelper.convert(block)); } } INodeFileAttributes copy = diff.snapshotINode; if (copy != null) { fb.setName(ByteString.copyFrom(copy.getLocalNameBytes())) .setSnapshotCopy(buildINodeFile(copy, parent.getSaverContext())); } fb.build().writeDelimitedTo(out); } } }
return; int p = getPrior(removed.getSnapshotId(), true); FileDiff earlierDiff = p == Snapshot.NO_SNAPSHOT_ID ? null : getDiffById(p); (earlierDiff == null ? new BlockInfoContiguous[]{} : earlierDiff.getBlocks()); BlockInfoContiguous[] laterBlocks = findLaterSnapshotBlocks(removed.getSnapshotId()); laterBlocks = (laterBlocks==null) ? file.getBlocks() : laterBlocks;
return; int p = getPrior(removed.getSnapshotId(), true); FileDiff earlierDiff = p == Snapshot.NO_SNAPSHOT_ID ? null : getDiffById(p); (earlierDiff == null ? new BlockInfoContiguous[]{} : earlierDiff.getBlocks()); BlockInfoContiguous[] laterBlocks = findLaterSnapshotBlocks(removed.getSnapshotId()); laterBlocks = (laterBlocks==null) ? file.getBlocks() : laterBlocks;
private void serializeFileDiffList(INodeFile file, OutputStream out) throws IOException { FileWithSnapshotFeature sf = file.getFileWithSnapshotFeature(); if (sf != null) { List<FileDiff> diffList = sf.getDiffs().asList(); SnapshotDiffSection.DiffEntry entry = SnapshotDiffSection.DiffEntry .newBuilder().setInodeId(file.getId()).setType(Type.FILEDIFF) .setNumOfDiff(diffList.size()).build(); entry.writeDelimitedTo(out); for (int i = diffList.size() - 1; i >= 0; i--) { FileDiff diff = diffList.get(i); SnapshotDiffSection.FileDiff.Builder fb = SnapshotDiffSection.FileDiff .newBuilder().setSnapshotId(diff.getSnapshotId()) .setFileSize(diff.getFileSize()); if(diff.getBlocks() != null) { for(Block block : diff.getBlocks()) { fb.addBlocks(PBHelper.convert(block)); } } INodeFileAttributes copy = diff.snapshotINode; if (copy != null) { fb.setName(ByteString.copyFrom(copy.getLocalNameBytes())) .setSnapshotCopy(buildINodeFile(copy, parent.getSaverContext())); } fb.build().writeDelimitedTo(out); } } }
assertEquals(1, barDiffList.size()); FileDiff barDiff = barDiffList.get(0); assertEquals(s1.getId(), barDiff.getSnapshotId());
List<FileDiff> bar1Diffs = bar1.getDiffs().asList(); assertEquals(3, bar1Diffs.size()); assertEquals(s333.getId(), bar1Diffs.get(2).getSnapshotId()); assertEquals(s22.getId(), bar1Diffs.get(1).getSnapshotId()); assertEquals(s1.getId(), bar1Diffs.get(0).getSnapshotId()); List<FileDiff> barDiffs = bar.getDiffs().asList(); assertEquals(4, barDiffs.size()); assertEquals(s2222.getId(), barDiffs.get(3).getSnapshotId()); assertEquals(s333.getId(), barDiffs.get(2).getSnapshotId()); assertEquals(s22.getId(), barDiffs.get(1).getSnapshotId()); assertEquals(s1.getId(), barDiffs.get(0).getSnapshotId()); bar1Diffs = bar1.getDiffs().asList(); assertEquals(3, bar1Diffs.size()); assertEquals(s333.getId(), bar1Diffs.get(2).getSnapshotId()); barDiffs = bar.getDiffs().asList(); assertEquals(4, barDiffs.size()); assertEquals(s2222.getId(), barDiffs.get(3).getSnapshotId());