Search in sources :

Example 16 with ActionInfo

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);
}
Also used : FileInfo(org.smartdata.model.FileInfo) HashMap(java.util.HashMap) BackUpInfo(org.smartdata.model.BackUpInfo) ActionInfo(org.smartdata.model.ActionInfo) RuleInfo(org.smartdata.model.RuleInfo) CmdletInfo(org.smartdata.model.CmdletInfo) Test(org.junit.Test)

Example 17 with ActionInfo

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);
}
Also used : HashMap(java.util.HashMap) ActionInfo(org.smartdata.model.ActionInfo) Test(org.junit.Test)

Example 18 with ActionInfo

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);
}
Also used : HashMap(java.util.HashMap) ActionInfo(org.smartdata.model.ActionInfo) Test(org.junit.Test)

Example 19 with ActionInfo

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));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.model.ActionInfo) Test(org.junit.Test)

Example 20 with ActionInfo

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);
}
Also used : HashMap(java.util.HashMap) ActionInfo(org.smartdata.model.ActionInfo) Test(org.junit.Test)

Aggregations

ActionInfo (org.smartdata.model.ActionInfo)48 Test (org.junit.Test)23 HashMap (java.util.HashMap)16 CmdletInfo (org.smartdata.model.CmdletInfo)16 ArrayList (java.util.ArrayList)12 IOException (java.io.IOException)7 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 SmartAdmin (org.smartdata.admin.SmartAdmin)5 MetaStore (org.smartdata.metastore.MetaStore)5 Path (org.apache.hadoop.fs.Path)4 DistributedFileSystem (org.apache.hadoop.hdfs.DistributedFileSystem)4 MetaStoreException (org.smartdata.metastore.MetaStoreException)4 FileInfo (org.smartdata.model.FileInfo)4 CmdletDescriptor (org.smartdata.model.CmdletDescriptor)3 ActionScheduler (org.smartdata.model.action.ActionScheduler)3 ServiceException (com.google.protobuf.ServiceException)2 ParseException (java.text.ParseException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 QueueFullException (org.smartdata.exception.QueueFullException)2 DetailedFileAction (org.smartdata.model.DetailedFileAction)2