Search in sources :

Example 31 with CmdletInfo

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

Example 32 with CmdletInfo

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

Example 33 with CmdletInfo

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

Example 34 with CmdletInfo

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

Example 35 with CmdletInfo

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);
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.model.ActionInfo) IOException(java.io.IOException) FileInfo(org.smartdata.model.FileInfo) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CmdletInfo(org.smartdata.model.CmdletInfo)

Aggregations

CmdletInfo (org.smartdata.model.CmdletInfo)37 Test (org.junit.Test)18 ActionInfo (org.smartdata.model.ActionInfo)16 ArrayList (java.util.ArrayList)11 IOException (java.io.IOException)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 HashMap (java.util.HashMap)4 MetaStore (org.smartdata.metastore.MetaStore)3 CmdletDescriptor (org.smartdata.model.CmdletDescriptor)3 CmdletState (org.smartdata.model.CmdletState)3 RuleInfo (org.smartdata.model.RuleInfo)3 CmdletStatus (org.smartdata.protocol.message.CmdletStatus)3 ServiceException (com.google.protobuf.ServiceException)2 ParseException (java.text.ParseException)2 SmartAdmin (org.smartdata.admin.SmartAdmin)2 QueueFullException (org.smartdata.exception.QueueFullException)2 MetaStoreException (org.smartdata.metastore.MetaStoreException)2 FileInfo (org.smartdata.model.FileInfo)2 CmdletInfoProto (org.smartdata.protocol.AdminServerProto.CmdletInfoProto)2 ActionStatus (org.smartdata.protocol.message.ActionStatus)2