Search in sources :

Example 1 with CmdletInfoProto

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

the class AdminProtocolClientSideTranslator method listCmdletInfo.

@Override
public List<CmdletInfo> listCmdletInfo(long rid, CmdletState cmdletState) throws IOException {
    ListCmdletInfoRequestProto req = ListCmdletInfoRequestProto.newBuilder().setRuleID(rid).setCmdletState(cmdletState.getValue()).build();
    try {
        List<CmdletInfoProto> protoslist = rpcProxy.listCmdletInfo(null, req).getCmdletInfosList();
        if (protoslist == null) {
            return new ArrayList<>();
        }
        List<CmdletInfo> list = new ArrayList<>();
        for (CmdletInfoProto infoProto : protoslist) {
            list.add(ProtoBufferHelper.convert(infoProto));
        }
        return list;
    } catch (ServiceException e) {
        throw ProtoBufferHelper.getRemoteException(e);
    }
}
Also used : ListCmdletInfoRequestProto(org.smartdata.protocol.AdminServerProto.ListCmdletInfoRequestProto) ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) CmdletInfoProto(org.smartdata.protocol.AdminServerProto.CmdletInfoProto) CmdletInfo(org.smartdata.model.CmdletInfo)

Example 2 with CmdletInfoProto

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

the class ServerProtocolsServerSideTranslator method listCmdletInfo.

@Override
public ListCmdletInfoResponseProto listCmdletInfo(RpcController controller, ListCmdletInfoRequestProto req) throws ServiceException {
    try {
        List<CmdletInfo> list = server.listCmdletInfo(req.getRuleID(), CmdletState.fromValue(req.getCmdletState()));
        if (list == null) {
            return ListCmdletInfoResponseProto.newBuilder().build();
        }
        List<CmdletInfoProto> protoList = new ArrayList<>();
        for (CmdletInfo info : list) {
            protoList.add(ProtoBufferHelper.convert(info));
        }
        return ListCmdletInfoResponseProto.newBuilder().addAllCmdletInfos(protoList).build();
    } catch (IOException e) {
        throw new ServiceException(e);
    }
}
Also used : ServiceException(com.google.protobuf.ServiceException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CmdletInfoProto(org.smartdata.protocol.AdminServerProto.CmdletInfoProto) CmdletInfo(org.smartdata.model.CmdletInfo)

Aggregations

ServiceException (com.google.protobuf.ServiceException)2 ArrayList (java.util.ArrayList)2 CmdletInfo (org.smartdata.model.CmdletInfo)2 CmdletInfoProto (org.smartdata.protocol.AdminServerProto.CmdletInfoProto)2 IOException (java.io.IOException)1 ListCmdletInfoRequestProto (org.smartdata.protocol.AdminServerProto.ListCmdletInfoRequestProto)1