use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class TestAllSsdFileAction method testAllSsd.
@Test
public void testAllSsd() throws Exception {
final String file = "/testAllSsd/file";
Path dir = new Path("/testAllSsd");
dfs.mkdirs(dir);
// write to DISK
dfs.setStoragePolicy(dir, "HOT");
final FSDataOutputStream out = dfs.create(new Path(file));
out.writeChars("testAllSSD");
out.close();
// schedule move to SSD
AllSsdFileAction action = new AllSsdFileAction();
action.setDfsClient(dfsClient);
action.setContext(smartContext);
action.init(file);
ActionStatus status = action.getActionStatus();
action.run();
while (!status.isFinished()) {
System.out.println("Mover running time : " + StringUtils.formatTime(status.getRunningTime()));
Thread.sleep(1000);
}
// verify after movement
Assert.assertTrue(status.isSuccessful());
LocatedBlock lb = dfsClient.getLocatedBlocks(file, 0).get(0);
StorageType[] storageTypes = lb.getStorageTypes();
for (StorageType storageType : storageTypes) {
Assert.assertTrue(StorageType.SSD == storageType);
}
}
use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class TestOneSsdFileAction method testAllSsd.
@Test
public void testAllSsd() throws Exception {
final String file = "/testArchive/file";
Path dir = new Path("/testArchive");
dfs.mkdirs(dir);
// write to DISK
dfs.setStoragePolicy(dir, "HOT");
final FSDataOutputStream out = dfs.create(new Path(file));
out.writeChars("testArchive");
out.close();
// schedule move to Archive
OneSsdFileAction action = new OneSsdFileAction();
action.setDfsClient(dfsClient);
action.setContext(smartContext);
action.init(file);
ActionStatus status = action.getActionStatus();
action.run();
while (!status.isFinished()) {
System.out.println("Mover running time : " + StringUtils.formatTime(status.getRunningTime()));
Thread.sleep(1000);
}
// verify after movement
Assert.assertTrue(status.isSuccessful());
LocatedBlock lb = dfsClient.getLocatedBlocks(file, 0).get(0);
StorageType[] storageTypes = lb.getStorageTypes();
int ssdCount = 0;
int hddCount = 0;
for (StorageType storageType : storageTypes) {
if (storageType == StorageType.SSD) {
ssdCount++;
} else if (storageType == StorageType.DISK) {
hddCount++;
}
}
Assert.assertEquals(1, ssdCount);
Assert.assertEquals(2, hddCount);
}
use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class TestMoveFileAction method testParallelMovers.
@Test(timeout = 300000)
public void testParallelMovers() throws Exception {
final String file1 = "/testParallelMovers/file1";
final String file2 = "/testParallelMovers/file2";
Path dir = new Path("/testParallelMovers");
dfs.mkdirs(dir);
// write to DISK
dfs.setStoragePolicy(dir, "HOT");
final FSDataOutputStream out1 = dfs.create(new Path(file1));
out1.writeChars("testParallelMovers1");
out1.close();
final FSDataOutputStream out2 = dfs.create(new Path(file2));
out2.writeChars("testParallelMovers2");
out2.close();
// schedule move to ARCHIVE or SSD
MoveFileAction action1 = new MoveFileAction();
action1.setDfsClient(dfsClient);
action1.setContext(smartContext);
action1.init(file1, "COLD");
MoveFileAction action2 = new MoveFileAction();
action2.setDfsClient(dfsClient);
action2.setContext(smartContext);
action2.init(file2, "ALL_SSD");
ActionStatus status1 = action1.getActionStatus();
ActionStatus status2 = action2.getActionStatus();
action1.run();
action2.run();
while (!status1.isFinished() || !status2.isFinished()) {
System.out.println("Mover 1 running time : " + StringUtils.formatTime(status1.getRunningTime()));
System.out.println("Mover 2 running time : " + StringUtils.formatTime(status2.getRunningTime()));
Thread.sleep(3000);
}
Assert.assertTrue(status1.isSuccessful());
Assert.assertTrue(status2.isSuccessful());
System.out.println("Mover 1 total running time : " + StringUtils.formatTime(status1.getRunningTime()));
System.out.println("Mover 2 total running time : " + StringUtils.formatTime(status2.getRunningTime()));
}
use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class TestMoveFileAction method scheduleMoverWithPercentage.
private void scheduleMoverWithPercentage(String dir, String storageType, long totalSize, long totolBlocks) throws Exception {
MoveFileAction moveFileAction = new MoveFileAction();
moveFileAction.setDfsClient(dfsClient);
moveFileAction.setContext(smartContext);
moveFileAction.init(dir, storageType);
ActionStatus status = moveFileAction.getActionStatus();
moveFileAction.run();
if (status instanceof MoverStatus) {
MoverStatus moverStatus = (MoverStatus) status;
while (!moverStatus.isFinished()) {
System.out.println("Mover running time : " + StringUtils.formatTime(moverStatus.getRunningTime()));
System.out.println("Moved/Total : " + moverStatus.getMovedBlocks() + "/" + moverStatus.getTotalBlocks());
System.out.println("Move percentage : " + moverStatus.getPercentage() * 100 + "%");
Assert.assertTrue(moverStatus.getPercentage() <= 1);
Thread.sleep(1000);
}
System.out.println("Mover is finished.");
Assert.assertEquals(1.0f, moverStatus.getPercentage(), 0.00001f);
Assert.assertEquals(totalSize, moverStatus.getTotalSize());
Assert.assertEquals(totolBlocks, moverStatus.getTotalBlocks());
}
}
use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class TestCheckStorageAction method testCheckStorageAction.
@Test
public void testCheckStorageAction() throws IOException {
CheckStorageAction checkStorageAction = new CheckStorageAction();
checkStorageAction.setDfsClient(dfsClient);
checkStorageAction.setContext(smartContext);
final String file = "/testParallelMovers/file1";
dfsClient.mkdirs("/testParallelMovers");
// write to HDFS
final OutputStream out = dfsClient.create(file, true);
byte[] content = ("This is a file containing two blocks" + "......................").getBytes();
out.write(content);
out.close();
// do CheckStorageAction
checkStorageAction.init(new String[] { file });
checkStorageAction.run();
ActionStatus actionStatus = checkStorageAction.getActionStatus();
System.out.println(StringUtils.formatTime(actionStatus.getRunningTime()));
Assert.assertTrue(actionStatus.isFinished());
Assert.assertTrue(actionStatus.isSuccessful());
Assert.assertEquals(1.0f, actionStatus.getPercentage(), 0.00001f);
ByteArrayOutputStream resultStream = actionStatus.getResultStream();
System.out.println(resultStream);
}
Aggregations