use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.
the class TestCompressDecompress method waitTillActionDone.
private void waitTillActionDone(long cmdId) throws Exception {
int n = 0;
while (true) {
Thread.sleep(1000);
CmdletManager cmdletManager = ssm.getCmdletManager();
CmdletInfo info = cmdletManager.getCmdletInfo(cmdId);
if (info == null) {
continue;
}
CmdletState state = info.getState();
if (state == CmdletState.DONE) {
return;
} else if (state == CmdletState.FAILED) {
// Reasonably assume that there is only one action wrapped by a given cmdlet.
long aid = cmdletManager.getCmdletInfo(cmdId).getAids().get(0);
Assert.fail("Action failed. " + cmdletManager.getActionInfo(aid).getLog());
} else {
System.out.println(state);
}
// Wait for 20s.
if (++n == 20) {
throw new Exception("Time out in waiting for cmdlet: " + cmdletManager.getCmdletInfo(cmdId).toString());
}
}
}
use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.
the class TestMoverScheduler method testScheduler.
@Test(timeout = 40000)
public void testScheduler() throws Exception {
waitTillSSMExitSafeMode();
String file = "/testfile";
Path filePath = new Path(file);
int numBlocks = 2;
DistributedFileSystem fs = cluster.getFileSystem();
DFSTestUtil.createFile(fs, filePath, numBlocks * DEFAULT_BLOCK_SIZE, (short) 3, 100);
fs.setStoragePolicy(filePath, "ALL_SSD");
CmdletManager cmdletManager = ssm.getCmdletManager();
long cmdId = cmdletManager.submitCmdlet("allssd -file /testfile");
while (true) {
Thread.sleep(1000);
CmdletState state = cmdletManager.getCmdletInfo(cmdId).getState();
if (state == CmdletState.DONE) {
return;
} else if (state == CmdletState.FAILED) {
Assert.fail("Mover failed.");
} else {
System.out.println(state);
}
}
}
use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.
the class CmdletManager method onCmdletStatusUpdate.
public void onCmdletStatusUpdate(CmdletStatus status) throws IOException {
if (status == null) {
return;
}
long cmdletId = status.getCmdletId();
CmdletInfo cmdletInfo = idToCmdlets.get(cmdletId);
if (cmdletInfo != null) {
synchronized (cmdletInfo) {
if (CmdletState.isTerminalState(cmdletInfo.getState())) {
return;
}
CmdletState state = status.getCurrentState();
cmdletInfo.setState(state);
cmdletInfo.setStateChangedTime(status.getStateUpdateTime());
if (CmdletState.isTerminalState(state)) {
cmdletFinished(cmdletId);
} else if (state == CmdletState.DISPATCHED) {
flushCmdletInfo(cmdletInfo);
}
}
}
}
use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.
the class TestSmallFileScheduler method testScheduler.
@Test(timeout = 180000)
public void testScheduler() throws Exception {
waitTillSSMExitSafeMode();
Thread.sleep(2000);
CmdletManager cmdletManager = ssm.getCmdletManager();
long cmdId = cmdletManager.submitCmdlet("compact -file " + "['/test/small_files/file_0','/test/small_files/file_1'] " + "-containerFile /test/small_files/container_file_2");
while (true) {
Thread.sleep(3000);
CmdletState state = cmdletManager.getCmdletInfo(cmdId).getState();
if (state == CmdletState.DONE) {
long containerFileLen = dfsClient.getFileInfo("/test/small_files/container_file_2").getLen();
Assert.assertEquals(sumFileLen, containerFileLen);
Assert.assertEquals(0, dfsClient.getFileInfo("/test/small_files/file_1").getLen());
return;
} else if (state == CmdletState.FAILED) {
Assert.fail("Compact failed.");
} else {
System.out.println(state);
}
}
}
use of org.smartdata.model.CmdletState in project SSM by Intel-bigdata.
the class TestCmdletManager method testSubmitAPI.
@Test
public void testSubmitAPI() throws Exception {
waitTillSSMExitSafeMode();
DistributedFileSystem dfs = cluster.getFileSystem();
Path dir = new Path("/testMoveFile");
dfs.mkdirs(dir);
// Move to SSD
dfs.setStoragePolicy(dir, "HOT");
FSDataOutputStream out1 = dfs.create(new Path("/testMoveFile/file1"), true, 1024);
out1.writeChars("/testMoveFile/file1");
out1.close();
Path dir3 = new Path("/testCacheFile");
dfs.mkdirs(dir3);
Assert.assertTrue(ActionRegistry.supportedActions().size() > 0);
CmdletManager cmdletManager = ssm.getCmdletManager();
long cmdId = cmdletManager.submitCmdlet("allssd -file /testMoveFile/file1 ; cache -file /testCacheFile ; " + "write -file /test -length 1024");
Thread.sleep(1200);
List<ActionInfo> actionInfos = cmdletManager.listNewCreatedActions(10);
Assert.assertTrue(actionInfos.size() > 0);
while (true) {
CmdletState state = cmdletManager.getCmdletInfo(cmdId).getState();
if (state == CmdletState.DONE) {
break;
}
Assert.assertFalse(CmdletState.isTerminalState(state));
System.out.printf("Cmdlet still running.\n");
Thread.sleep(1000);
}
List<CmdletInfo> com = ssm.getMetaStore().getCmdlets(null, null, CmdletState.DONE);
Assert.assertTrue(com.size() >= 1);
List<ActionInfo> result = ssm.getMetaStore().getActions(null, null);
Assert.assertTrue(result.size() == 3);
}
Aggregations