use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class TestMetaStore method testMoveSyncRules.
@Test
public void testMoveSyncRules() throws Exception {
String pathString = "/src/1";
long length = 123L;
boolean isDir = false;
int blockReplication = 1;
long blockSize = 128 * 1024L;
long modTime = 123123123L;
long accessTime = 123123120L;
String owner = "root";
String group = "admin";
long fileId = 56L;
byte storagePolicy = 0;
byte erasureCodingPolicy = 0;
FileInfo fileInfo = new FileInfo(pathString, fileId, length, isDir, (short) blockReplication, blockSize, modTime, accessTime, (short) 1, owner, group, storagePolicy, erasureCodingPolicy);
metaStore.insertFile(fileInfo);
Map<String, String> args = new HashMap();
args.put("-file", "/src/1");
String rule = "file : accessCount(10m) > 20 \n\n" + "and length() > 3 | ";
long submitTime = System.currentTimeMillis();
RuleInfo ruleInfo = new RuleInfo(0, submitTime, rule + "sync -dest /dest/", RuleState.ACTIVE, 0, 0, 0);
metaStore.insertNewRule(ruleInfo);
metaStore.insertBackUpInfo(new BackUpInfo(ruleInfo.getId(), "/src/", "/dest/", 100));
metaStore.insertNewRule(new RuleInfo(1, submitTime, rule + "allssd", RuleState.ACTIVE, 0, 0, 0));
metaStore.insertNewRule(new RuleInfo(2, submitTime, rule + "archive", RuleState.ACTIVE, 0, 0, 0));
metaStore.insertNewRule(new RuleInfo(2, submitTime, rule + "onessd", RuleState.ACTIVE, 0, 0, 0));
metaStore.insertNewRule(new RuleInfo(2, submitTime, rule + "cache", RuleState.ACTIVE, 0, 0, 0));
Assert.assertTrue(metaStore.listMoveRules().size() == 3);
Assert.assertTrue(metaStore.listSyncRules().size() == 1);
CmdletInfo cmdletInfo = new CmdletInfo(1, ruleInfo.getId(), CmdletState.EXECUTING, "test", 123123333L, 232444444L);
cmdletInfo.setAids(Collections.singletonList(1L));
metaStore.insertCmdlet(cmdletInfo);
metaStore.insertAction(new ActionInfo(1, 1, "allssd", args, "Test", "Test", true, 123213213L, true, 123123L, 100));
Assert.assertTrue(metaStore.listFileActions(ruleInfo.getId(), 0).size() >= 0);
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class TestActionDao method testInsertGetAction.
@Test
public void testInsertGetAction() throws Exception {
Map<String, String> args = new HashMap<>();
ActionInfo actionInfo = new ActionInfo(1, 1, "cache", args, "Test", "Test", false, 123213213L, true, 123123L, 100);
actionDao.insert(new ActionInfo[] { actionInfo });
ActionInfo dbActionInfo = actionDao.getById(1L);
Assert.assertTrue(actionInfo.equals(dbActionInfo));
// Get wrong id
expectedException.expect(EmptyResultDataAccessException.class);
actionDao.getById(100L);
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class TestActionDao method testGetLatestActionListByFinish.
@Test
public void testGetLatestActionListByFinish() {
Map<String, String> args = new HashMap<>();
ActionInfo actionInfo = new ActionInfo(1, 1, "cache", args, "Test", "Test", false, 123213213L, true, 123123L, 100);
List<ActionInfo> actionInfoList = actionDao.getLatestActions("cache", 0);
// Get from empty table
Assert.assertTrue(actionInfoList.size() == 0);
actionDao.insert(actionInfo);
actionInfo.setActionId(2);
actionDao.insert(actionInfo);
actionInfoList = actionDao.getLatestActions("cache", 0, true);
Assert.assertTrue(actionInfoList.size() == 2);
actionInfoList = actionDao.getByIds(Arrays.asList(1L, 2L));
Assert.assertTrue(actionInfoList.size() == 2);
actionInfoList = actionDao.getLatestActions("cache", 1, true);
Assert.assertTrue(actionInfoList.size() == 1);
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class TestActionDao method testGetAPageOfAction.
@Test
public void testGetAPageOfAction() {
Map<String, String> args = new HashMap<>();
// ActionInfo's result and log queried from Metastore will be discarded
// and they are set by "".
ActionInfo actionInfo = new ActionInfo(1, 1, "cache", args, "", "", false, 123213213L, true, 123123L, 100);
ActionInfo actionInfo1 = new ActionInfo(2, 1, "cache", args, "", "", false, 123213213L, true, 123123L, 100);
ActionInfo actionInfo2 = new ActionInfo(3, 1, "cache", args, "", "", false, 123213213L, true, 123123L, 100);
ActionInfo actionInfo3 = new ActionInfo(4, 1, "cache", args, "", "", false, 123213213L, true, 123123L, 100);
actionDao.insert(new ActionInfo[] { actionInfo, actionInfo1, actionInfo2, actionInfo3 });
List<String> order = new ArrayList<>();
order.add("aid");
List<Boolean> desc = new ArrayList<>();
desc.add(false);
Assert.assertTrue(actionDao.getAPageOfAction(2, 1, order, desc).get(0).equals(actionInfo2));
}
use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.
the class TestActionDao method testGetLatestActionListBySuccess.
@Test
public void testGetLatestActionListBySuccess() {
Map<String, String> args = new HashMap<>();
ActionInfo actionInfo = new ActionInfo(1, 1, "cache", args, "Test", "Test", false, 123213213L, true, 123123L, 100);
List<ActionInfo> actionInfoList = actionDao.getLatestActions("cache", false, 0);
// Get from empty table
Assert.assertTrue(actionInfoList.size() == 0);
actionDao.insert(actionInfo);
actionInfo.setActionId(2);
actionDao.insert(actionInfo);
actionInfoList = actionDao.getLatestActions("cache", false, 0);
Assert.assertTrue(actionInfoList.size() == 2);
actionInfoList = actionDao.getByIds(Arrays.asList(1L, 2L));
Assert.assertTrue(actionInfoList.size() == 2);
actionInfoList = actionDao.getLatestActions("cache", false, 1);
Assert.assertTrue(actionInfoList.size() == 1);
}
Aggregations