From 88495b975814431079384ea4273a8f1bdab342f8 Mon Sep 17 00:00:00 2001 From: fuweng11 <76141879+fuweng11@users.noreply.github.com> Date: Wed, 18 Oct 2023 09:47:29 +0800 Subject: [PATCH] [INLONG-9062][Manager] Add default values for stream related interface parameters (#9063) --- .../api/inner/client/InlongStreamClient.java | 23 ++++++++++++------- .../client/api/service/InlongStreamApi.java | 12 ++++++---- .../controller/InlongStreamController.java | 8 +++---- .../openapi/OpenInLongStreamController.java | 2 +- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/inner/client/InlongStreamClient.java b/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/inner/client/InlongStreamClient.java index 1709bee4188..8085362d416 100644 --- a/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/inner/client/InlongStreamClient.java +++ b/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/inner/client/InlongStreamClient.java @@ -164,12 +164,13 @@ public List listStreamInfo(String inlongGroupId) { * * @param groupId inlong group id * @param streamId inlong stream id + * @param sync Create stream in synchronous/asynchronous way. * @return whether succeed */ - public boolean startProcess(String groupId, String streamId) { + public boolean startProcess(String groupId, String streamId, boolean sync) { Preconditions.expectNotBlank(groupId, ErrorCodeEnum.GROUP_ID_IS_EMPTY); Preconditions.expectNotBlank(streamId, ErrorCodeEnum.STREAM_ID_IS_EMPTY); - Response response = ClientUtils.executeHttpCall(inlongStreamApi.startProcess(groupId, streamId)); + Response response = ClientUtils.executeHttpCall(inlongStreamApi.startProcess(groupId, streamId, sync)); ClientUtils.assertRespSuccess(response); return response.getData(); } @@ -179,12 +180,14 @@ public boolean startProcess(String groupId, String streamId) { * * @param groupId inlong group id * @param streamId inlong stream id + * @param sync Suspend stream in synchronous/asynchronous way. * @return whether succeed */ - public boolean suspendProcess(String groupId, String streamId) { + public boolean suspendProcess(String groupId, String streamId, boolean sync) { Preconditions.expectNotBlank(groupId, ErrorCodeEnum.GROUP_ID_IS_EMPTY); Preconditions.expectNotBlank(streamId, ErrorCodeEnum.STREAM_ID_IS_EMPTY); - Response response = ClientUtils.executeHttpCall(inlongStreamApi.suspendProcess(groupId, streamId)); + Response response = + ClientUtils.executeHttpCall(inlongStreamApi.suspendProcess(groupId, streamId, sync)); ClientUtils.assertRespSuccess(response); return response.getData(); } @@ -194,12 +197,14 @@ public boolean suspendProcess(String groupId, String streamId) { * * @param groupId inlong group id * @param streamId inlong stream id + * @param sync Restart stream in synchronous/asynchronous way. * @return whether succeed */ - public boolean restartProcess(String groupId, String streamId) { + public boolean restartProcess(String groupId, String streamId, boolean sync) { Preconditions.expectNotBlank(groupId, ErrorCodeEnum.GROUP_ID_IS_EMPTY); Preconditions.expectNotBlank(streamId, ErrorCodeEnum.STREAM_ID_IS_EMPTY); - Response response = ClientUtils.executeHttpCall(inlongStreamApi.restartProcess(groupId, streamId)); + Response response = + ClientUtils.executeHttpCall(inlongStreamApi.restartProcess(groupId, streamId, sync)); ClientUtils.assertRespSuccess(response); return response.getData(); } @@ -209,12 +214,14 @@ public boolean restartProcess(String groupId, String streamId) { * * @param groupId inlong group id * @param streamId inlong stream id + * @param sync Delete stream in synchronous/asynchronous way. * @return whether succeed */ - public boolean deleteProcess(String groupId, String streamId) { + public boolean deleteProcess(String groupId, String streamId, boolean sync) { Preconditions.expectNotBlank(groupId, ErrorCodeEnum.GROUP_ID_IS_EMPTY); Preconditions.expectNotBlank(streamId, ErrorCodeEnum.STREAM_ID_IS_EMPTY); - Response response = ClientUtils.executeHttpCall(inlongStreamApi.deleteProcess(groupId, streamId)); + Response response = + ClientUtils.executeHttpCall(inlongStreamApi.deleteProcess(groupId, streamId, sync)); ClientUtils.assertRespSuccess(response); return response.getData(); } diff --git a/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/service/InlongStreamApi.java b/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/service/InlongStreamApi.java index e23e6bc5bc2..fc3f4a2fe8e 100644 --- a/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/service/InlongStreamApi.java +++ b/inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/service/InlongStreamApi.java @@ -58,16 +58,20 @@ Call> getStream(@Query("groupId") String groupId, Call>> listStream(@Body InlongStreamPageRequest request); @POST("stream/startProcess/{groupId}/{streamId}") - Call> startProcess(@Path("groupId") String groupId, @Path("streamId") String streamId); + Call> startProcess(@Path("groupId") String groupId, @Path("streamId") String streamId, + @Query("sync") boolean sync); @POST("stream/suspendProcess/{groupId}/{streamId}") - Call> suspendProcess(@Path("groupId") String groupId, @Path("streamId") String streamId); + Call> suspendProcess(@Path("groupId") String groupId, @Path("streamId") String streamId, + @Query("sync") boolean sync); @POST("stream/restartProcess/{groupId}/{streamId}") - Call> restartProcess(@Path("groupId") String groupId, @Path("streamId") String streamId); + Call> restartProcess(@Path("groupId") String groupId, @Path("streamId") String streamId, + @Query("sync") boolean sync); @POST("stream/deleteProcess/{groupId}/{streamId}") - Call> deleteProcess(@Path("groupId") String groupId, @Path("streamId") String streamId); + Call> deleteProcess(@Path("groupId") String groupId, @Path("streamId") String streamId, + @Query("sync") boolean sync); @DELETE("stream/delete") Call> delete(@Query("groupId") String groupId, @Query("streamId") String streamId); diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java index 2407cdd2831..2d21e84fe29 100644 --- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java +++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/InlongStreamController.java @@ -147,7 +147,7 @@ public Response update(@Validated(UpdateValidation.class) @RequestBody @ApiImplicitParam(name = "streamId", dataTypeClass = String.class, required = true) }) public Response startProcess(@PathVariable String groupId, @PathVariable String streamId, - @RequestParam boolean sync) { + @RequestParam(required = false, defaultValue = "false") boolean sync) { String operator = LoginUserUtils.getLoginUser().getName(); return Response.success(streamProcessOperation.startProcess(groupId, streamId, operator, sync)); } @@ -159,7 +159,7 @@ public Response startProcess(@PathVariable String groupId, @PathVariabl @ApiImplicitParam(name = "streamId", dataTypeClass = String.class, required = true) }) public Response suspendProcess(@PathVariable String groupId, @PathVariable String streamId, - @RequestParam boolean sync) { + @RequestParam(required = false, defaultValue = "false") boolean sync) { String operator = LoginUserUtils.getLoginUser().getName(); return Response.success(streamProcessOperation.suspendProcess(groupId, streamId, operator, sync)); } @@ -171,7 +171,7 @@ public Response suspendProcess(@PathVariable String groupId, @PathVaria @ApiImplicitParam(name = "streamId", dataTypeClass = String.class, required = true) }) public Response restartProcess(@PathVariable String groupId, @PathVariable String streamId, - @RequestParam boolean sync) { + @RequestParam(required = false, defaultValue = "false") boolean sync) { String operator = LoginUserUtils.getLoginUser().getName(); return Response.success(streamProcessOperation.restartProcess(groupId, streamId, operator, sync)); } @@ -183,7 +183,7 @@ public Response restartProcess(@PathVariable String groupId, @PathVaria @ApiImplicitParam(name = "streamId", dataTypeClass = String.class, required = true) }) public Response deleteProcess(@PathVariable String groupId, @PathVariable String streamId, - @RequestParam boolean sync) { + @RequestParam(required = false, defaultValue = "false") boolean sync) { String operator = LoginUserUtils.getLoginUser().getName(); return Response.success(streamProcessOperation.deleteProcess(groupId, streamId, operator, sync)); } diff --git a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/OpenInLongStreamController.java b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/OpenInLongStreamController.java index 864b2788511..7115132581d 100644 --- a/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/OpenInLongStreamController.java +++ b/inlong-manager/manager-web/src/main/java/org/apache/inlong/manager/web/controller/openapi/OpenInLongStreamController.java @@ -134,7 +134,7 @@ public Response delete(@RequestParam String groupId, @RequestParam Stri @ApiImplicitParam(name = "streamId", dataTypeClass = String.class, required = true) }) public Response startProcess(@PathVariable String groupId, @PathVariable String streamId, - @RequestParam boolean sync) { + @RequestParam(required = false, defaultValue = "false") boolean sync) { String operator = LoginUserUtils.getLoginUser().getName(); return Response.success(streamProcessOperation.startProcess(groupId, streamId, operator, sync)); }