use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class SetStoragePolicyAction method execute.
@Override
protected void execute() {
ActionStatus actionStatus = getActionStatus();
actionStatus.begin();
try {
dfsClient.setStoragePolicy(fileName, storagePolicy);
actionStatus.setSuccessful(true);
} catch (Exception e) {
actionStatus.setSuccessful(false);
throw new RuntimeException(e);
} finally {
actionStatus.end();
}
}
use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class CommandExecutor method getActionInfo.
public ActionInfo getActionInfo(long actionID) {
SmartAction smartAction = actionPool.get(actionID);
ActionStatus status = smartAction.getActionStatus();
return new ActionInfo(status.getId(), 0, smartAction.getName(), smartAction.getArguments(), status.getResultPrintStream().toString(), status.getLogPrintStream().toString(), status.isSuccessful(), status.getStartTime(), status.isSuccessful(), status.getRunningTime(), status.getPercentage());
}
use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class CommandExecutor method listNewCreatedActions.
public List<ActionInfo> listNewCreatedActions(int maxNumActions) throws IOException {
ArrayList<ActionInfo> actionInfos = new ArrayList<>();
boolean flag = true;
for (Command cmd : commandPool.getcommands()) {
long cmdId = cmd.getId();
for (SmartAction smartAction : cmd.getActions()) {
ActionStatus status = smartAction.getActionStatus();
actionInfos.add(new ActionInfo(status.getId(), cmdId, smartAction.getName(), smartAction.getArguments(), status.getResultPrintStream().toString(), status.getLogPrintStream().toString(), status.isSuccessful(), status.getStartTime(), status.isSuccessful(), status.getRunningTime(), status.getPercentage()));
}
}
// Sort and get top maxNumActions
Collections.sort(actionInfos, new ActionInfoComparator());
if (maxNumActions >= actionInfos.size()) {
return actionInfos;
} else {
return actionInfos.subList(0, maxNumActions);
}
}
use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class TestArchiveFileAction 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
ArchiveFileAction action = new ArchiveFileAction();
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.ARCHIVE == storageType);
}
}
use of org.smartdata.actions.ActionStatus in project SSM by Intel-bigdata.
the class TestReadFileAction method testExecute.
@Test
public void testExecute() throws IOException {
String filePath = "/testWriteFile/file";
int size = 66560;
writeFile(filePath, size);
String[] args = { filePath };
ReadFileAction readFileAction = new ReadFileAction();
readFileAction.setDfsClient(dfsClient);
readFileAction.setContext(smartContext);
readFileAction.init(args);
readFileAction.run();
// check results
ActionStatus actionStatus = readFileAction.getActionStatus();
Assert.assertTrue(actionStatus.isFinished());
Assert.assertTrue(actionStatus.isSuccessful());
System.out.println("Read file action running time : " + StringUtils.formatTime(actionStatus.getRunningTime()));
Assert.assertEquals(1.0f, actionStatus.getPercentage(), 0.00001f);
}
Aggregations