use of org.apache.hadoop.hdfs.protocol.SnapshotDiffReport in project hadoop by apache.
the class TestDistCpSync method testSync4.
/**
* Test a case where multiple level dirs are renamed.
*/
@Test
public void testSync4() throws Exception {
initData4(source);
initData4(target);
enableAndCreateFirstSnapshot();
// make changes under source
changeData4(source);
dfs.createSnapshot(source, "s2");
SnapshotDiffReport report = dfs.getSnapshotDiffReport(source, "s1", "s2");
System.out.println(report);
syncAndVerify();
}
use of org.apache.hadoop.hdfs.protocol.SnapshotDiffReport in project hadoop by apache.
the class TestDistCpSyncReverseBase method testSync3.
/**
* Test a case where there are multiple source files with the same name.
*/
@Test
public void testSync3() throws Exception {
if (isSrcNotSameAsTgt) {
initData3(source);
}
initData3(target);
enableAndCreateFirstSnapshot();
// make changes under target
changeData3(target);
createSecondSnapshotAtTarget();
SnapshotDiffReport report = dfs.getSnapshotDiffReport(target, "s2", "s1");
System.out.println(report);
syncAndVerify();
}
use of org.apache.hadoop.hdfs.protocol.SnapshotDiffReport in project hadoop by apache.
the class TestDistCpSyncReverseBase method testSync.
/**
* Test the basic functionality.
*/
@Test
public void testSync() throws Exception {
if (isSrcNotSameAsTgt) {
initData(source);
}
initData(target);
enableAndCreateFirstSnapshot();
final FsShell shell = new FsShell(conf);
lsrSource("Before source: ", shell, source);
lsr("Before target: ", shell, target);
// make changes under target
int numDeletedModified = changeData(target);
createSecondSnapshotAtTarget();
SnapshotDiffReport report = dfs.getSnapshotDiffReport(target, "s2", "s1");
System.out.println(report);
DistCpSync distCpSync = new DistCpSync(options, conf);
lsr("Before sync target: ", shell, target);
// do the sync
Assert.assertTrue(distCpSync.sync());
lsr("After sync target: ", shell, target);
// make sure the source path has been updated to the snapshot path
final Path spath = new Path(source, HdfsConstants.DOT_SNAPSHOT_DIR + Path.SEPARATOR + "s1");
Assert.assertEquals(spath, options.getSourcePaths().get(0));
// build copy listing
final Path listingPath = new Path("/tmp/META/fileList.seq");
CopyListing listing = new SimpleCopyListing(conf, new Credentials(), distCpSync);
listing.buildListing(listingPath, options);
Map<Text, CopyListingFileStatus> copyListing = getListing(listingPath);
CopyMapper copyMapper = new CopyMapper();
StubContext stubContext = new StubContext(conf, null, 0);
Mapper<Text, CopyListingFileStatus, Text, Text>.Context<Text, CopyListingFileStatus, Text, Text> context = stubContext.getContext();
// Enable append
context.getConfiguration().setBoolean(DistCpOptionSwitch.APPEND.getConfigLabel(), true);
copyMapper.setup(context);
for (Map.Entry<Text, CopyListingFileStatus> entry : copyListing.entrySet()) {
copyMapper.map(entry.getKey(), entry.getValue(), context);
}
lsrSource("After mapper source: ", shell, source);
lsr("After mapper target: ", shell, target);
// verify that we only list modified and created files/directories
Assert.assertEquals(numDeletedModified, copyListing.size());
// verify that we only copied new appended data of f2 and the new file f1
Assert.assertEquals(blockSize * 3, stubContext.getReporter().getCounter(CopyMapper.Counter.BYTESCOPIED).getValue());
// verify the source and target now has the same structure
verifyCopy(dfs.getFileStatus(spath), dfs.getFileStatus(target), false);
}
use of org.apache.hadoop.hdfs.protocol.SnapshotDiffReport in project hadoop by apache.
the class TestDistCpSyncReverseBase method testSync2.
@Test
public void testSync2() throws Exception {
if (isSrcNotSameAsTgt) {
initData2(source);
}
initData2(target);
enableAndCreateFirstSnapshot();
// make changes under target
changeData2(target);
createSecondSnapshotAtTarget();
SnapshotDiffReport report = dfs.getSnapshotDiffReport(target, "s2", "s1");
System.out.println(report);
syncAndVerify();
}
use of org.apache.hadoop.hdfs.protocol.SnapshotDiffReport in project hadoop by apache.
the class TestDistCpSync method testSync3.
/**
* Test a case where there are multiple source files with the same name.
*/
@Test
public void testSync3() throws Exception {
initData3(source);
initData3(target);
enableAndCreateFirstSnapshot();
// make changes under source
changeData3(source);
dfs.createSnapshot(source, "s2");
SnapshotDiffReport report = dfs.getSnapshotDiffReport(source, "s1", "s2");
System.out.println(report);
syncAndVerify();
}
Aggregations