接口控制数据画布能力启停

操作步骤

  • 步骤1:创建一个能力的虚拟分组

  • 步骤2:查询已创建能力分组对应的groupid

  • 步骤3:启动指定groupid下的所有数据画布能力

  • 步骤4:查询指定groupid下的所有能力状态

  • 步骤5:查询队列中剩余数据量

视频讲解

  • 第一步:调用数据画布能力的接口说明
  • 第二步:如何找到接口所需参数
  • 第三步:如何在应用画布上配置调用接口
  • 第四步:实战讲解

最下方附应用画布的整体源代码,可直接拷贝复用。

能力群控的接口设计

userId+projectId+groupName需要唯一

1. 创建一个能力分组 createComponentGroup

URI /innerApp/ctrlApi/processor/command

Request

{

  "userId":userid ,          *//**用户**id*

  "projectId":projectId,        *//projectId*

  "option":"createComponentGroup",  *//**功能名称*

  "params":{

​    " groupName ":"xxxxxx",        *//*

​    "nifiHost": 'nifiIp:port',         *//nifi**的**ip**和端口*

​    "data":[               *//**数据*

​      {

​        'componentId': '11111',   *//**能力**id*

​        'name':'xxxxx',       *//**名称*

​        'type':'processor',     *//**类型**,**可以不填写**,**目前都是**processor*

​        'info':'msg'        *//**描述信息*

​      },

​      {

​        'componentId': '11111',

​        'name':'xxxxx'

​        'info':'msg'        *//**描述信息*

​      }

​    ]   

  }

}

response

{

 "status": 0, 

 "msg": "",

 "data": {



 }

}

2. 删除能力组

URI /innerApp/ctrlApi/processor/command

Request

{

  "userId":userid ,          //用户id

  "projectId":projectId,        //projectId

  "option":"removeComponentGroup",  //功能名称

  "params":{

​    "groupId":[1,2,3],         //分组id,

  }

}

response

{

 "status": 0, 

 "msg": "",

 "data": {

  无

 }

}

3. 修改能力组

URI /innerApp/ctrlApi/processor/command

request

{

  "userId":userid ,

  "projectId":projectId,        *//projectId*

  "option":"modifyComponentGroup",

  "params":{

​    "groupId":gid,        *//**输入**,**指定**,**输入的内容会覆盖原值**,data**会全部修改*

​    " groupName ":"xxxxxx",        *//*

​    "nifiHost": 'nifiIp:port',         *//nifi**的**ip*

​    "data":[               *//**数据*

​      {

​        'componentId': '11111',   *//**能力**id*

​        'name':'xxxxx',       *//**名称*

​        'type':'processor',

​        'info':'msg'        *//**描述信息*

​      },

​      {

​        'componentId': '11111',

​        'name':'xxxxx'

​        'info':'msg'        *//**描述信息*

​      }

​    ]     

  }

}

response

{

 "status": 0, 

 "msg": "",

 "data": {

  无

 }

}

4. 查询分组的信息

URI /innerApp/ctrlApi/processor/query

request

{

  "userId":userid ,

  "projectId":projectId,

  "option":"queryProcessorsGroup",

  "params":{

​    'groupId': [1,2,3]       //不填写时返回全部

  }

}

response

{

  "status": 0,

  "msg":"xxx"

  "data":{

​    "rows": [

​      {

​        "id":gid,              *//**分组的**id(groupId)*

​        "userId":userid,

​        "projectId":projectId,

​        "groupName":"xxxxxx",        *//*

​        "nifiHost": 'nifiHost',       *//nifi**的**ip*

​        "data":[              *//**数据*

​          {

​            'componentId': '11111',   *//**能力**id*

​            'name':'xxxxx',       *//**名称*

​            'info':'msg'        *//**描述信息*

​          },

​          {

​            'componentId': '11111',

​            'name':'xxxxx'

​            'info':'msg'        *//**描述信息*

​          }

​        ]      

​      },

​      {

​        ...

​      }

​    ]

  }

}

5. 获得能力分组的全部状态

URI /innerApp/ctrlApi/processor/query

request

{

  "userId":userid ,

  "projectId":projectId,

  "option":"queryGroupStatus",

  "params":{

​    "groupId":[1,2]       //需要指定,

  }

}

response

{

  "status": 0,

  "msg":"xxx",

  "data":{

​    rows: [

​      {

​        'componentId':'xxx-xxx-xxx-xxxx',

​        'name':'xxxx',

​        'type':'processor',

​        'status': RUNNING 或 STOPPED 或 DISABLED 

​      }

​    ]

  }

}

6.分组执行

URI /innerApp/ctrlApi/processor/command

request

{

  "userId":userid ,

  "projectId":projectId,

  "option":"runGroupStatus",

  "params":{

​    "groupId":[1,2,3],

​    "status": RUNNING 或 STOPPED 或 DISABLED

  }

}

response

{

  "status": 0,

  "msg":"xxx",

  'data':{

​    //无

  }

}

7.获取分组中队列组建的数量

URI /innerApp/ctrlApi/processor/query

request

{
   "userId":userid ,
   "projectId":projectId,
   "option":"queryQueueSize",
   "params":{
       "groupId":[1,2,3],
   }
}

response

{
   "status": 0,
   "msg":"xxx",
   'data':{
        rows: [
            {
                'componentId':'xxx-xxx-xxx-xxxx',
                'name':'xxxx',
                'type':'connection',
                'queuedCount':"300"
            }
       ]
   }
}

可拷贝源码


{

 "type": "tabs",

 "tabs": [

  {

   "title": "创建组",

   "body": [

​    {

​     "name": "校园安全",

​     "api": {

​      "method": "post",

​      "data": {

​       "params": {

​        "nifiHost": "${nifiHost}",

​        "groupName": "${groupName}",

​        "data": "${data}"

​       },

​       "userId": "${userId}",

​       "projectId": "${projectId}",

​       "option": "createComponentGroup"

​      },

​      "url": "/innerApp/ctrlApi/processor/command"

​     },

​     "type": "form",

​     "title": "表单",

​     "body": [

​      {

​       "name": "userId",

​       "description": "userId+projectId+groupName需要唯一",

​       "label": "userId",

​       "type": "input-text"

​      },

​      {

​       "name": "projectId",

​       "label": "projectId",

​       "type": "input-text"

​      },

​      {

​       "name": "groupName",

​       "label": "groupName",

​       "type": "input-text"

​      },

​      {

​       "name": "nifiHost",

​       "label": "nifiHost",

​       "type": "input-text"

​      },

​      {

​       "name": "data",

​       "label": "data",

​       "type": "input-text",

​       "value": "[{'componentId': '填写能力id','name':'填写能力名称','type':'processor','info':'填写描述信息'},{'componentId': '填写能力id','name':'填写能力名称','type':'processor','info':'填写描述信息'}]"

​      }

​     ]

​    }

   ]

  },

  {

   "title": "查询组信息",

   "body": [

​    {

​     "perPageAvailable": [

​      10

​     ],

​     "columns": [

​      {

​       "name": "id",

​       "label": "id",

​       "placeholder": "-",

​       "sortable": true,

​       "type": "text"

​      },

​      {

​       "name": "data",

​       "label": "data",

​       "placeholder": "-",

​       "type": "json"

​      },

​      {

​       "buttons": [],

​       "name": "userId",

​       "label": "userId",

​       "placeholder": "-",

​       "type": "text"

​      },

​      {

​       "buttons": [],

​       "name": "projectId",

​       "label": "projectId",

​       "placeholder": "-",

​       "type": "text"

​      },

​      {

​       "buttons": [],

​       "name": "nifiHost",

​       "label": "nifiHost",

​       "placeholder": "-",

​       "type": "text"

​      },

​      {

​       "buttons": [],

​       "name": "groupName",

​       "label": "groupName",

​       "placeholder": "-",

​       "type": "text"

​      }

​     ],

​     "itemActions": [],

​     "type": "crud",

​     "perPageField": "perPage",

​     "filter": {

​      "title": "查询条件",

​      "body": [

​       {

​        "mode": "inline",

​        "name": "userId",

​        "label": "userId",

​        "type": "input-text"

​       },

​       {

​        "mode": "inline",

​        "name": "projectId",

​        "label": "projectId",

​        "type": "input-text"

​       }

​      ]

​     },

​     "features": [

​      "filter"

​     ],

​     "perPage": 50,

​     "name": "校园安全",

​     "bulkActions": [],

​     "messages": {},

​     "api": {

​      "method": "post",

​      "data": {

​       "params": {

​        "groupId": []

​       },

​       "userId": "${userId}",

​       "projectId": "${projectId}",

​       "option": "queryProcessorsGroup"

​      },

​      "url": "/innerApp/ctrlApi/processor/query"

​     },

​     "headerToolbar": [

​      {

​       "type": "bulk-actions"

​      },

​      {

​       "type": "pagination"

​      },

​      {

​       "tpl": "内容",

​       "type": "statistics"

​      }

​     ]

​    }

   ]

  },

  {

   "title": "删除组",

   "body": [

​    {

​     "name": "校园安全",

​     "api": {

​      "method": "post",

​      "data": {

​       "params": "{'groupId':[${groupId}]}",

​       "userId": "${userid}",

​       "projectId": "${projectId}",

​       "option": "removeComponentGroup"

​      },

​      "url": "/innerApp/ctrlApi/processor/command"

​     },

​     "type": "form",

​     "title": "删除",

​     "body": [

​      {

​       "mode": "inline",

​       "name": "userid",

​       "label": "userid",

​       "type": "input-text"

​      },

​      {

​       "mode": "inline",

​       "name": "projectId",

​       "label": "projectId",

​       "type": "input-text"

​      },

​      {

​       "mode": "inline",

​       "name": "groupId",

​       "description": "",

​       "remark": {

​        "icon": "fa fa-question-circle",

​        "className": "Remark--warning",

​        "trigger": [

​         "hover",

​         "focus"

​        ],

​        "content": "例:1,2,3 注:空着为全部删除"

​       },

​       "label": "groupId",

​       "type": "input-text"

​      }

​     ]

​    }

   ]

  },

  {

   "title": "修改组",

   "body": [

​    {

​     "name": "校园安全",

​     "api": {

​      "method": "post",

​      "data": {

​       "params": {

​        "groupId": "${groupId}",

​        "nifiHost": "${nifiHost}",

​        "groupName": "${groupName}",

​        "data": "${data}"

​       },

​       "userId": "${userId}",

​       "projectId": "${projectId}",

​       "option": "modifyComponentGroup"

​      },

​      "url": "/innerApp/ctrlApi/processor/command"

​     },

​     "type": "form",

​     "title": "表单",

​     "body": [

​      {

​       "name": "userId",

​       "description": "userId+projectId+groupName需要唯一",

​       "label": "userId",

​       "type": "input-text"

​      },

​      {

​       "name": "projectId",

​       "label": "projectId",

​       "type": "input-text"

​      },

​      {

​       "name": "groupId",

​       "label": "groupId",

​       "type": "input-text"

​      },

​      {

​       "name": "groupName",

​       "label": "groupName",

​       "type": "input-text"

​      },

​      {

​       "name": "nifiHost",

​       "label": "nifiHost",

​       "type": "input-text"

​      },

​      {

​       "name": "data",

​       "label": "data",

​       "type": "input-text",

​       "value": "[{'componentId': '填写能力id','name':'填写能力名称','type':'processor','info':'填写描述信息'},{'componentId': '填写能力id','name':'填写能力名称','type':'processor','info':'填写描述信息'}]"

​      }

​     ]

​    }

   ]

  },

  {

   "title": "启停组",

   "body": [

​    {

​     "name": "校园安全",

​     "api": {

​      "method": "post",

​      "data": {

​       "params": {

​        "groupId": "[${groupId}]",

​        "status": "RUNNING"

​       },

​       "userId": "${userId}",

​       "projectId": "${projectId}",

​       "option": "queryGroupStatus"

​      },

​      "url": "/innerApp/ctrlApi/processor/query"

​     },

​     "type": "crud",

​     "filter": {

​      "affixFooter": false,

​      "name": "校园安全",

​      "api": {

​       "method": "get",

​       "data": {

​        "params": {

​         "groupId": "[${groupId}]"

​        },

​        "userId": "${userId}",

​        "projectId": "${projectId}",

​        "option": "queryGroupStatus"

​       },

​       "url": "/innerApp/ctrlApi/processor/query"

​      },

​      "title": "查询能力状态",

​      "body": [

​       {

​        "name": "userId",

​        "label": "userId",

​        "type": "input-text"

​       },

​       {

​        "name": "projectId",

​        "label": "projectId",

​        "type": "input-text"

​       },

​       {

​        "name": "groupId",

​        "label": "groupId",

​        "type": "input-text",

​        "value": ""

​       }

​      ],

​      "actions": [

​       {

​        "actionType": "ajax",

​        "dialog": {

​         "title": "系统提示",

​         "body": "对你点击了"

​        },

​        "level": "warning",

​        "label": "启动",

​        "api": {

​         "method": "post",

​         "data": {

​          "params": {

​           "groupId": "[${groupId}]",

​           "status": "RUNNING"

​          },

​          "userId": "${userId}",

​          "projectId": "${projectId}",

​          "option": "runGroupStatus"

​         },

​         "url": "/innerApp/ctrlApi/processor/command"

​        },

​        "type": "button"

​       },

​       {

​        "level": "primary",

​        "label": "查询",

​        "type": "submit"

​       }

​      ]

​     },

​     "features": [

​      "filter"

​     ],

​     "perPage": 50,

​     "perPageAvailable": [

​      10

​     ],

​     "columns": [

​      {

​       "name": "id",

​       "label": "ID",

​       "type": "text"

​      },

​      {

​       "name": "data",

​       "label": "data",

​       "placeholder": "-",

​       "type": "json"

​      },

​      {

​       "name": "groupName",

​       "label": "groupName",

​       "placeholder": "-",

​       "type": "text"

​      },

​      {

​       "name": "nifiHost",

​       "label": "nifiHost",

​       "placeholder": "-",

​       "type": "text"

​      }

​     ],

​     "itemActions": [],

​     "bulkActions": [],

​     "messages": {}

​    }

   ]

  }

 ]

}

问题没有解决?请留言提问

results matching ""

    No results matching ""