use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.
the class TestCmdletDao method testGetByCondition.
@Test
public void testGetByCondition() throws Exception {
CmdletInfo command1 = new CmdletInfo(0, 1, CmdletState.EXECUTING, "test", 123123333L, 232444444L);
CmdletInfo command2 = new CmdletInfo(1, 78, CmdletState.PAUSED, "tt", 123178333L, 232444994L);
cmdletDao.insert(new CmdletInfo[] { command1, command2 });
List<CmdletInfo> commandInfos = cmdletDao.getByCondition(null, null, null);
Assert.assertTrue(commandInfos.size() == 2);
commandInfos = cmdletDao.getByCondition(null, null, CmdletState.PAUSED);
Assert.assertTrue(commandInfos.size() == 1);
}
use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.
the class TestCmdletDao method testInsertGetCmdlet.
@Test
public void testInsertGetCmdlet() throws Exception {
CmdletInfo cmdlet1 = new CmdletInfo(0, 1, CmdletState.EXECUTING, "test", 123123333L, 232444444L);
CmdletInfo cmdlet2 = new CmdletInfo(1, 78, CmdletState.PAUSED, "tt", 123178333L, 232444994L);
cmdletDao.insert(new CmdletInfo[] { cmdlet1, cmdlet2 });
List<CmdletInfo> cmdlets = cmdletDao.getAll();
Assert.assertTrue(cmdlets.size() == 2);
}
use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.
the class TestCmdletDao method testDeleteACmdlet.
@Test
public void testDeleteACmdlet() throws Exception {
CmdletInfo cmdlet1 = new CmdletInfo(0, 1, CmdletState.EXECUTING, "test", 123123333L, 232444444L);
CmdletInfo cmdlet2 = new CmdletInfo(1, 78, CmdletState.PAUSED, "tt", 123178333L, 232444994L);
cmdletDao.insert(new CmdletInfo[] { cmdlet1, cmdlet2 });
cmdletDao.delete(1);
List<CmdletInfo> cmdlets = cmdletDao.getAll();
Assert.assertTrue(cmdlets.size() == 1);
}
use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.
the class TestMetaStore method testInsertCmdletsTable.
@Test
public void testInsertCmdletsTable() throws Exception {
CmdletInfo command1 = new CmdletInfo(0, 1, CmdletState.EXECUTING, "test", 123123333L, 232444444L);
metaStore.insertCmdlet(command1);
CmdletInfo command2 = new CmdletInfo(1, 78, CmdletState.PAUSED, "tt", 123178333L, 232444994L);
metaStore.insertCmdlet(command2);
Assert.assertTrue(metaStore.getCmdletById(command1.getCid()).equals(command1));
Assert.assertTrue(metaStore.getCmdletById(command2.getCid()).equals(command2));
metaStore.updateCmdlet(command1.getCid(), "TestParameter", CmdletState.DRYRUN);
Assert.assertTrue(metaStore.getCmdletById(command1.getCid()).getParameters().equals("TestParameter"));
Assert.assertTrue(metaStore.getCmdletById(command1.getCid()).getState().equals(CmdletState.DRYRUN));
}
use of org.smartdata.model.CmdletInfo in project SSM by Intel-bigdata.
the class SmallFilePlugin method updateContainerFileInfoCache.
/**
* Update container file info cache based on containerFileSizeThreshold
* and cmdlet.
*/
private void updateContainerFileInfoCache(RuleInfo ruleInfo, Map<String, FileInfo> containerFileInfoMap) {
if (!containerFileInfoMap.isEmpty()) {
// Remove container file whose size is greater than containerFileSizeThreshold
for (Map.Entry<String, FileInfo> entry : containerFileInfoMap.entrySet()) {
if (entry.getValue().getLength() >= containerFileSizeThreshold) {
containerFileInfoMap.remove(entry.getKey());
}
}
// Remove container file which is being used
try {
List<Long> aids = new ArrayList<>();
List<CmdletInfo> list = cmdletManager.listCmdletsInfo(ruleInfo.getId());
for (CmdletInfo cmdletInfo : list) {
if (!CmdletState.isTerminalState(cmdletInfo.getState())) {
aids.addAll(cmdletInfo.getAids());
}
}
List<ActionInfo> actionInfos = cmdletManager.getActions(aids);
for (ActionInfo actionInfo : actionInfos) {
Map<String, String> args = actionInfo.getArgs();
if (args.containsKey(SmallFileCompactAction.CONTAINER_FILE)) {
containerFileInfoMap.remove(args.get(SmallFileCompactAction.CONTAINER_FILE));
}
}
} catch (IOException e) {
LOG.error("Failed to get cmdlet and action info.", e);
}
}
containerFileInfoCache.put(ruleInfo, containerFileInfoMap);
}
Aggregations