Search in sources :

Example 1 with CommandInfoProto

use of org.smartdata.common.protocol.AdminServerProto.CommandInfoProto in project SSM by Intel-bigdata.

the class ClientSmartProtocolServerSideTranslatorPB method listCommandInfo.

@Override
public ListCommandInfoResponseProto listCommandInfo(RpcController controller, ListCommandInfoRequestProto req) throws ServiceException {
    try {
        List<CommandInfo> list = server.listCommandInfo(req.getRuleID(), CommandState.fromValue(req.getCommandState()));
        if (list == null)
            return ListCommandInfoResponseProto.newBuilder().build();
        List<CommandInfoProto> protoList = new ArrayList<>();
        for (CommandInfo info : list) {
            protoList.add(PBHelper.convert(info));
        }
        return ListCommandInfoResponseProto.newBuilder().addAllCommandInfos(protoList).build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : CommandInfo(org.smartdata.common.command.CommandInfo) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) CommandInfoProto(org.smartdata.common.protocol.AdminServerProto.CommandInfoProto) IOException(java.io.IOException)

Example 2 with CommandInfoProto

use of org.smartdata.common.protocol.AdminServerProto.CommandInfoProto in project SSM by Intel-bigdata.

the class SmartAdminProtocolAdminSideTranslatorPB method listCommandInfo.

@Override
public List<CommandInfo> listCommandInfo(long rid, CommandState commandState) throws IOException {
    ListCommandInfoRequestProto req = ListCommandInfoRequestProto.newBuilder().setRuleID(rid).setCommandState(commandState.getValue()).build();
    try {
        List<CommandInfoProto> protoslist = rpcProxy.listCommandInfo(null, req).getCommandInfosList();
        if (protoslist == null)
            return new ArrayList<>();
        List<CommandInfo> list = new ArrayList<>();
        for (CommandInfoProto infoProto : protoslist) {
            list.add(PBHelper.convert(infoProto));
        }
        return list;
    } catch (ServiceException e) {
        throw PBHelper.getRemoteException(e);
    }
}
Also used : CommandInfo(org.smartdata.common.command.CommandInfo) ListCommandInfoRequestProto(org.smartdata.common.protocol.AdminServerProto.ListCommandInfoRequestProto) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) CommandInfoProto(org.smartdata.common.protocol.AdminServerProto.CommandInfoProto)

Aggregations

ServiceException (com.google.protobuf.ServiceException)2 ArrayList (java.util.ArrayList)2 CommandInfo (org.smartdata.common.command.CommandInfo)2 CommandInfoProto (org.smartdata.common.protocol.AdminServerProto.CommandInfoProto)2 IOException (java.io.IOException)1 ListCommandInfoRequestProto (org.smartdata.common.protocol.AdminServerProto.ListCommandInfoRequestProto)1