Search in sources :

Example 1 with ActionInfo

use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.

the class ServerProtocolsServerSideTranslator method listActionInfoOfLastActions.

@Override
public ListActionInfoOfLastActionsResponseProto listActionInfoOfLastActions(RpcController controller, ListActionInfoOfLastActionsRequestProto request) throws ServiceException {
    try {
        List<ActionInfo> list = server.listActionInfoOfLastActions(request.getMaxNumActions());
        if (list == null) {
            return ListActionInfoOfLastActionsResponseProto.newBuilder().build();
        }
        List<ActionInfoProto> protoList = new ArrayList<>();
        for (ActionInfo a : list) {
            protoList.add(ProtoBufferHelper.convert(a));
        }
        return ListActionInfoOfLastActionsResponseProto.newBuilder().addAllActionInfoList(protoList).build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : ActionInfoProto(org.smartdata.protocol.AdminServerProto.ActionInfoProto) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.model.ActionInfo) IOException(java.io.IOException)

Example 2 with ActionInfo

use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.

the class MetaStore method listFileActions.

public List<DetailedFileAction> listFileActions(long rid, long start, long offset) throws MetaStoreException {
    if (mapStoragePolicyIdName == null) {
        updateCache();
    }
    List<ActionInfo> actionInfos = getActions(rid, start, offset);
    List<DetailedFileAction> detailedFileActions = new ArrayList<>();
    for (ActionInfo actionInfo : actionInfos) {
        DetailedFileAction detailedFileAction = new DetailedFileAction(actionInfo);
        String filePath = actionInfo.getArgs().get("-file");
        FileInfo fileInfo = getFile(filePath);
        if (fileInfo == null) {
            // LOG.debug("Namespace is not sync! File {} not in file table!", filePath);
            // Add a mock fileInfo
            fileInfo = new FileInfo(filePath, 0L, 0L, false, (short) 0, 0L, 0L, 0L, (short) 0, "root", "root", (byte) 0, (byte) 0);
        }
        detailedFileAction.setFileLength(fileInfo.getLength());
        detailedFileAction.setFilePath(filePath);
        if (actionInfo.getActionName().contains("allssd") || actionInfo.getActionName().contains("onessd") || actionInfo.getActionName().contains("archive") || actionInfo.getActionName().contains("alldisk") || actionInfo.getActionName().contains("onedisk") || actionInfo.getActionName().contains("ramdisk")) {
            detailedFileAction.setTarget(actionInfo.getActionName());
            detailedFileAction.setSrc(mapStoragePolicyIdName.get((int) fileInfo.getStoragePolicy()));
        } else {
            detailedFileAction.setSrc(actionInfo.getArgs().get("-src"));
            detailedFileAction.setTarget(actionInfo.getArgs().get("-dest"));
        }
        detailedFileActions.add(detailedFileAction);
    }
    return detailedFileActions;
}
Also used : FileInfo(org.smartdata.model.FileInfo) DetailedFileAction(org.smartdata.model.DetailedFileAction) ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.model.ActionInfo)

Example 3 with ActionInfo

use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.

the class MetaStore method markActionFailed.

/**
 * Mark action {aid} as failed.
 *
 * @param aid
 * @throws MetaStoreException
 */
public void markActionFailed(long aid) throws MetaStoreException {
    ActionInfo actionInfo = getActionById(aid);
    if (actionInfo != null) {
        // Finished
        actionInfo.setFinished(true);
        // Failed
        actionInfo.setSuccessful(false);
        // 100 % progress
        actionInfo.setProgress(1);
        // Finish time equals to create time
        actionInfo.setFinishTime(actionInfo.getCreateTime());
        updateAction(actionInfo);
    }
}
Also used : ActionInfo(org.smartdata.model.ActionInfo)

Example 4 with ActionInfo

use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.

the class MetaStore method getActions.

public List<ActionInfo> getActions(long rid, int size) throws MetaStoreException {
    if (size <= 0) {
        size = Integer.MAX_VALUE;
    }
    List<CmdletInfo> cmdletInfos = cmdletDao.getByRid(rid);
    List<ActionInfo> runningActions = new ArrayList<>();
    List<ActionInfo> finishedActions = new ArrayList<>();
    int total = 0;
    for (CmdletInfo cmdletInfo : cmdletInfos) {
        if (total >= size) {
            break;
        }
        List<Long> aids = cmdletInfo.getAids();
        for (Long aid : aids) {
            if (total >= size) {
                break;
            }
            ActionInfo actionInfo = getActionById(aid);
            if (actionInfo != null && actionInfo.isFinished()) {
                finishedActions.add(actionInfo);
            } else {
                runningActions.add(actionInfo);
            }
            total++;
        }
    }
    runningActions.addAll(finishedActions);
    return runningActions;
}
Also used : ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.model.ActionInfo) CmdletInfo(org.smartdata.model.CmdletInfo)

Example 5 with ActionInfo

use of org.smartdata.model.ActionInfo in project SSM by Intel-bigdata.

the class TestCmdletManager method testReloadCmdletsInDB.

@Test(timeout = 40000)
public void testReloadCmdletsInDB() throws Exception {
    waitTillSSMExitSafeMode();
    CmdletManager cmdletManager = ssm.getCmdletManager();
    // Stop cmdletmanager
    // cmdletManager.stop();
    cmdletManager.setTimeout(1000);
    MetaStore metaStore = ssm.getMetaStore();
    String cmd = "write -file /test -length 1024; read -file /test";
    CmdletDescriptor cmdletDescriptor = generateCmdletDescriptor(cmd);
    long submitTime = System.currentTimeMillis();
    CmdletInfo cmdletInfo0 = new CmdletInfo(0, cmdletDescriptor.getRuleId(), CmdletState.DISPATCHED, cmdletDescriptor.getCmdletString(), submitTime, submitTime);
    CmdletInfo cmdletInfo1 = new CmdletInfo(1, cmdletDescriptor.getRuleId(), CmdletState.PENDING, cmdletDescriptor.getCmdletString(), submitTime, submitTime);
    List<ActionInfo> actionInfos0 = cmdletManager.createActionInfos(cmdletDescriptor, cmdletInfo0.getCid());
    flushToDB(metaStore, actionInfos0, cmdletInfo0);
    List<ActionInfo> actionInfos1 = cmdletManager.createActionInfos(cmdletDescriptor, cmdletInfo1.getCid());
    flushToDB(metaStore, actionInfos1, cmdletInfo1);
    // init cmdletmanager
    cmdletManager.init();
    // cmdletManager.start();
    CmdletInfo cmdlet0 = cmdletManager.getCmdletInfo(cmdletInfo0.getCid());
    CmdletInfo cmdlet1 = cmdletManager.getCmdletInfo(cmdletInfo1.getCid());
    while (cmdlet0.getState() != CmdletState.FAILED && cmdlet1.getState() != CmdletState.DONE) {
        Thread.sleep(100);
    }
}
Also used : CmdletDescriptor(org.smartdata.model.CmdletDescriptor) MetaStore(org.smartdata.metastore.MetaStore) ActionInfo(org.smartdata.model.ActionInfo) CmdletInfo(org.smartdata.model.CmdletInfo) 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