Search in sources :

Example 1 with ActionInfo

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

the class ClientSmartProtocolServerSideTranslatorPB 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(PBHelper.convert(a));
        }
        return ListActionInfoOfLastActionsResponseProto.newBuilder().addAllActionInfoList(protoList).build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : ActionInfoProto(org.smartdata.common.protocol.AdminServerProto.ActionInfoProto) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.common.actions.ActionInfo) IOException(java.io.IOException)

Example 2 with ActionInfo

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

the class CommandExecutor method getActionInfo.

public ActionInfo getActionInfo(long actionID) {
    SmartAction smartAction = actionPool.get(actionID);
    ActionStatus status = smartAction.getActionStatus();
    return new ActionInfo(status.getId(), 0, smartAction.getName(), smartAction.getArguments(), status.getResultPrintStream().toString(), status.getLogPrintStream().toString(), status.isSuccessful(), status.getStartTime(), status.isSuccessful(), status.getRunningTime(), status.getPercentage());
}
Also used : SmartAction(org.smartdata.actions.SmartAction) ActionInfo(org.smartdata.common.actions.ActionInfo) ActionStatus(org.smartdata.actions.ActionStatus)

Example 3 with ActionInfo

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

the class CommandExecutor method listNewCreatedActions.

public List<ActionInfo> listNewCreatedActions(int maxNumActions) throws IOException {
    ArrayList<ActionInfo> actionInfos = new ArrayList<>();
    boolean flag = true;
    for (Command cmd : commandPool.getcommands()) {
        long cmdId = cmd.getId();
        for (SmartAction smartAction : cmd.getActions()) {
            ActionStatus status = smartAction.getActionStatus();
            actionInfos.add(new ActionInfo(status.getId(), cmdId, smartAction.getName(), smartAction.getArguments(), status.getResultPrintStream().toString(), status.getLogPrintStream().toString(), status.isSuccessful(), status.getStartTime(), status.isSuccessful(), status.getRunningTime(), status.getPercentage()));
        }
    }
    // Sort and get top maxNumActions
    Collections.sort(actionInfos, new ActionInfoComparator());
    if (maxNumActions >= actionInfos.size()) {
        return actionInfos;
    } else {
        return actionInfos.subList(0, maxNumActions);
    }
}
Also used : ActionInfoComparator(org.smartdata.common.actions.ActionInfoComparator) ArrayList(java.util.ArrayList) SmartAction(org.smartdata.actions.SmartAction) ActionInfo(org.smartdata.common.actions.ActionInfo) ActionStatus(org.smartdata.actions.ActionStatus)

Example 4 with ActionInfo

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

the class SmartAdminProtocolAdminSideTranslatorPB method listActionInfoOfLastActions.

@Override
public List<ActionInfo> listActionInfoOfLastActions(int maxNumActions) throws IOException {
    ListActionInfoOfLastActionsRequestProto req = ListActionInfoOfLastActionsRequestProto.newBuilder().setMaxNumActions(maxNumActions).build();
    try {
        List<ActionInfoProto> protoslist = rpcProxy.listActionInfoOfLastActions(null, req).getActionInfoListList();
        if (protoslist == null) {
            return new ArrayList<>();
        }
        List<ActionInfo> list = new ArrayList<>();
        for (ActionInfoProto infoProto : protoslist) {
            list.add(PBHelper.convert(infoProto));
        }
        return list;
    } catch (ServiceException e) {
        throw PBHelper.getRemoteException(e);
    }
}
Also used : ListActionInfoOfLastActionsRequestProto(org.smartdata.common.protocol.AdminServerProto.ListActionInfoOfLastActionsRequestProto) ActionInfoProto(org.smartdata.common.protocol.AdminServerProto.ActionInfoProto) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) ActionInfo(org.smartdata.common.actions.ActionInfo)

Aggregations

ActionInfo (org.smartdata.common.actions.ActionInfo)4 ArrayList (java.util.ArrayList)3 ServiceException (com.google.protobuf.ServiceException)2 ActionStatus (org.smartdata.actions.ActionStatus)2 SmartAction (org.smartdata.actions.SmartAction)2 ActionInfoProto (org.smartdata.common.protocol.AdminServerProto.ActionInfoProto)2 IOException (java.io.IOException)1 ActionInfoComparator (org.smartdata.common.actions.ActionInfoComparator)1 ListActionInfoOfLastActionsRequestProto (org.smartdata.common.protocol.AdminServerProto.ListActionInfoOfLastActionsRequestProto)1