use of org.smartdata.hdfs.action.AllSsdFileAction in project SSM by Intel-bigdata.
the class TestMoveFileAction method testParallelMove.
@Test(timeout = 300000)
public void testParallelMove() throws Exception {
String dir = "/test";
String file1 = "/test/file1";
String file2 = "/test/file2";
dfs.mkdirs(new Path(dir));
// write to DISK
dfs.setStoragePolicy(new Path(dir), "HOT");
FSDataOutputStream out1 = dfs.create(new Path(file1));
final String str1 = "testtesttest1";
out1.writeChars(str1);
out1.close();
FSDataOutputStream out2 = dfs.create(new Path(file2));
final String str2 = "testtesttest2";
out2.writeChars(str2);
out2.close();
// move to SSD
AllSsdFileAction moveFileAction1 = new AllSsdFileAction();
moveFileAction1.setDfsClient(dfsClient);
moveFileAction1.setContext(smartContext);
Map<String, String> args1 = new HashMap();
args1.put(MoveFileAction.FILE_PATH, dir);
FileMovePlan plan1 = createPlan(file1, "SSD");
args1.put(MoveFileAction.MOVE_PLAN, plan1.toString());
AllSsdFileAction moveFileAction2 = new AllSsdFileAction();
moveFileAction2.setDfsClient(dfsClient);
moveFileAction2.setContext(smartContext);
Map<String, String> args2 = new HashMap();
args2.put(MoveFileAction.FILE_PATH, dir);
FileMovePlan plan2 = createPlan(file2, "SSD");
args2.put(MoveFileAction.MOVE_PLAN, plan2.toString());
// init and run
moveFileAction1.init(args1);
moveFileAction2.init(args2);
moveFileAction1.run();
Assert.assertTrue(moveFileAction1.getExpectedAfterRun());
moveFileAction2.run();
Assert.assertTrue(moveFileAction2.getExpectedAfterRun());
}
Aggregations