Skip to content

Commit

Permalink
[INLONG-7490][Manager] Support paging query InLong objects info based…
Browse files Browse the repository at this point in the history
… on conditions in manager-client (#7491)
  • Loading branch information
fuweng11 authored Mar 3, 2023
1 parent fb5f65b commit 25b4221
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.inlong.manager.pojo.common.PageResult;
import org.apache.inlong.manager.pojo.node.DataNodeInfo;
import org.apache.inlong.manager.pojo.node.DataNodePageRequest;
import org.apache.inlong.manager.pojo.node.DataNodeRequest;

public interface DataNode {
Expand All @@ -42,10 +43,10 @@ public interface DataNode {
/**
* Paging query nodes according to conditions.
*
* @param request page request conditions
* @param pageRequest page request conditions
* @return node list
*/
PageResult<DataNodeInfo> list(DataNodeRequest request);
PageResult<DataNodeInfo> list(DataNodePageRequest pageRequest);

/**
* Update data node.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.inlong.manager.common.util.Preconditions;
import org.apache.inlong.manager.pojo.common.PageResult;
import org.apache.inlong.manager.pojo.node.DataNodeInfo;
import org.apache.inlong.manager.pojo.node.DataNodePageRequest;
import org.apache.inlong.manager.pojo.node.DataNodeRequest;

public class DataNodeImpl implements DataNode {
Expand Down Expand Up @@ -54,9 +55,9 @@ public DataNodeInfo get(Integer id) {
}

@Override
public PageResult<DataNodeInfo> list(DataNodeRequest request) {
Preconditions.expectNotNull(request, "request cannot be null");
return dataNodeClient.list(request);
public PageResult<DataNodeInfo> list(DataNodePageRequest pageRequest) {
Preconditions.expectNotNull(pageRequest, "request cannot be null");
return dataNodeClient.list(pageRequest);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.inlong.manager.pojo.common.Response;
import org.apache.inlong.manager.pojo.common.UpdateResult;
import org.apache.inlong.manager.pojo.node.DataNodeInfo;
import org.apache.inlong.manager.pojo.node.DataNodePageRequest;
import org.apache.inlong.manager.pojo.node.DataNodeRequest;

/**
Expand Down Expand Up @@ -75,9 +76,9 @@ public DataNodeInfo get(Integer id) {
* @param request page request conditions
* @return node list
*/
public PageResult<DataNodeInfo> list(DataNodeRequest request) {
Preconditions.expectNotNull(request, "request cannot be null");
Response<PageResult<DataNodeInfo>> response = ClientUtils.executeHttpCall(dataNodeApi.list(request));
public PageResult<DataNodeInfo> list(DataNodePageRequest pageRequest) {
Preconditions.expectNotNull(pageRequest, "request cannot be null");
Response<PageResult<DataNodeInfo>> response = ClientUtils.executeHttpCall(dataNodeApi.list(pageRequest));
ClientUtils.assertRespSuccess(response);
return response.getData();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.inlong.manager.pojo.common.PageResult;
import org.apache.inlong.manager.pojo.common.Response;
import org.apache.inlong.manager.pojo.common.UpdateResult;
import org.apache.inlong.manager.pojo.sink.SinkPageRequest;
import org.apache.inlong.manager.pojo.sink.SinkField;
import org.apache.inlong.manager.pojo.sink.SinkRequest;
import org.apache.inlong.manager.pojo.sink.StreamSink;
Expand Down Expand Up @@ -78,8 +79,20 @@ public List<StreamSink> listSinks(String groupId, String streamId) {
* List stream sinks by the specified sink type.
*/
public List<StreamSink> listSinks(String groupId, String streamId, String sinkType) {
Response<PageResult<StreamSink>> response = ClientUtils.executeHttpCall(
streamSinkApi.list(groupId, streamId, sinkType));
SinkPageRequest pageRequest = new SinkPageRequest();
pageRequest.setInlongGroupId(groupId);
pageRequest.setInlongStreamId(streamId);
pageRequest.setSinkType(sinkType);
Response<PageResult<StreamSink>> response = ClientUtils.executeHttpCall(streamSinkApi.list(pageRequest));
ClientUtils.assertRespSuccess(response);
return response.getData().getList();
}

/**
* Paging query stream sink info based on conditions.
*/
public List<StreamSink> listSinks(SinkPageRequest pageRequest) {
Response<PageResult<StreamSink>> response = ClientUtils.executeHttpCall(streamSinkApi.list(pageRequest));
ClientUtils.assertRespSuccess(response);
return response.getData().getList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.inlong.manager.common.util.Preconditions;
import org.apache.inlong.manager.pojo.common.PageResult;
import org.apache.inlong.manager.pojo.common.Response;
import org.apache.inlong.manager.pojo.source.SourcePageRequest;
import org.apache.inlong.manager.pojo.source.SourceRequest;
import org.apache.inlong.manager.pojo.source.StreamSource;

Expand Down Expand Up @@ -61,8 +62,22 @@ public List<StreamSource> listSources(String groupId, String streamId) {
* List stream sources by the specified source type.
*/
public List<StreamSource> listSources(String groupId, String streamId, String sourceType) {
SourcePageRequest pageRequest = new SourcePageRequest();
pageRequest.setInlongGroupId(groupId);
pageRequest.setInlongStreamId(streamId);
pageRequest.setSourceType(sourceType);
Response<PageResult<StreamSource>> response = ClientUtils.executeHttpCall(
streamSourceApi.listSources(groupId, streamId, sourceType));
streamSourceApi.listSources(pageRequest));
ClientUtils.assertRespSuccess(response);
return response.getData().getList();
}

/**
* Paging query stream source info based on conditions.
*/
public List<StreamSource> listSources(SourcePageRequest pageRequest) {
Response<PageResult<StreamSource>> response = ClientUtils.executeHttpCall(
streamSourceApi.listSources(pageRequest));
ClientUtils.assertRespSuccess(response);
return response.getData().getList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.apache.inlong.manager.pojo.common.Response;
import org.apache.inlong.manager.pojo.common.UpdateResult;
import org.apache.inlong.manager.pojo.node.DataNodeInfo;
import org.apache.inlong.manager.pojo.node.DataNodePageRequest;
import org.apache.inlong.manager.pojo.node.DataNodeRequest;
import retrofit2.Call;
import retrofit2.http.Body;
Expand All @@ -39,7 +40,7 @@ public interface DataNodeApi {
Call<Response<DataNodeInfo>> get(@Path("id") Integer id);

@POST("node/list")
Call<Response<PageResult<DataNodeInfo>>> list(@Body DataNodeRequest request);
Call<Response<PageResult<DataNodeInfo>>> list(@Body DataNodePageRequest pageRequest);

@POST("node/update")
Call<Response<Boolean>> update(@Body DataNodeRequest request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.inlong.manager.pojo.common.PageResult;
import org.apache.inlong.manager.pojo.common.Response;
import org.apache.inlong.manager.pojo.common.UpdateResult;
import org.apache.inlong.manager.pojo.sink.SinkPageRequest;
import org.apache.inlong.manager.pojo.sink.SinkField;
import org.apache.inlong.manager.pojo.sink.SinkRequest;
import org.apache.inlong.manager.pojo.sink.StreamSink;
Expand Down Expand Up @@ -54,9 +55,8 @@ Call<Response<Boolean>> deleteByKey(@Query("groupId") String groupId, @Query("st
@GET("sink/get/{id}")
Call<Response<StreamSink>> get(@Path("id") Integer sinkId);

@GET("sink/list")
Call<Response<PageResult<StreamSink>>> list(@Query("inlongGroupId") String groupId,
@Query("inlongStreamId") String streamId, @Query("sinkType") String sinkType);
@POST("sink/list")
Call<Response<PageResult<StreamSink>>> list(@Body SinkPageRequest request);

@POST("sink/parseFields")
Call<Response<List<SinkField>>> parseFields(@Body String fieldsJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.inlong.manager.pojo.common.PageResult;
import org.apache.inlong.manager.pojo.common.Response;
import org.apache.inlong.manager.pojo.source.SourcePageRequest;
import org.apache.inlong.manager.pojo.source.SourceRequest;
import org.apache.inlong.manager.pojo.source.StreamSource;
import retrofit2.Call;
Expand All @@ -37,9 +38,8 @@ public interface StreamSourceApi {
@POST("source/update")
Call<Response<Boolean>> updateSource(@Body SourceRequest request);

@GET("source/list")
Call<Response<PageResult<StreamSource>>> listSources(@Query("inlongGroupId") String groupId,
@Query("inlongStreamId") String streamId, @Query("sourceType") String sourceType);
@POST("source/list")
Call<Response<PageResult<StreamSource>>> listSources(@Body SourcePageRequest pageRequest);

@DELETE("source/delete/{id}")
Call<Response<Boolean>> deleteSource(@Path("id") Integer sourceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.apache.inlong.manager.pojo.group.pulsar.InlongPulsarRequest;
import org.apache.inlong.manager.pojo.group.pulsar.InlongPulsarTopicInfo;
import org.apache.inlong.manager.pojo.node.DataNodeInfo;
import org.apache.inlong.manager.pojo.node.DataNodePageRequest;
import org.apache.inlong.manager.pojo.node.hive.HiveDataNodeInfo;
import org.apache.inlong.manager.pojo.node.hive.HiveDataNodeRequest;
import org.apache.inlong.manager.pojo.sink.SinkField;
Expand Down Expand Up @@ -661,7 +662,7 @@ void testListSink4AllType() {
.build());

stubFor(
get(urlMatching("/inlong/manager/api/sink/list.*"))
post(urlMatching("/inlong/manager/api/sink/list.*"))
.willReturn(
okJson(JsonUtils.toJsonString(
Response.success(new PageResult<>(Lists.newArrayList(sinkList)))))));
Expand All @@ -673,7 +674,7 @@ void testListSink4AllType() {
@Test
void testListSink4AllTypeShouldThrowException() {
stubFor(
get(urlMatching("/inlong/manager/api/sink/list.*"))
post(urlMatching("/inlong/manager/api/sink/list.*"))
.willReturn(
okJson(JsonUtils.toJsonString(
Response.fail("groupId should not empty")))));
Expand Down Expand Up @@ -922,7 +923,6 @@ void testListDataNode() {
List<DataNodeInfo> nodeResponses = Lists.newArrayList(
HiveDataNodeInfo.builder()
.id(1)
.name("test_node")
.type(DataNodeType.HIVE)
.build());

Expand All @@ -931,9 +931,8 @@ void testListDataNode() {
.willReturn(
okJson(JsonUtils.toJsonString(Response.success(new PageResult<>(nodeResponses))))));

HiveDataNodeRequest request = new HiveDataNodeRequest();
request.setName("test_hive_node");
PageResult<DataNodeInfo> pageInfo = dataNodeClient.list(request);
DataNodePageRequest pageRequest = new DataNodePageRequest();
PageResult<DataNodeInfo> pageInfo = dataNodeClient.list(pageRequest);
Assertions.assertEquals(JsonUtils.toJsonString(pageInfo.getList()), JsonUtils.toJsonString(nodeResponses));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public Response<StreamSink> get(@PathVariable Integer id) {
return Response.success(sinkService.get(id));
}

@RequestMapping(value = "/sink/list", method = RequestMethod.GET)
@RequestMapping(value = "/sink/list", method = RequestMethod.POST)
@ApiOperation(value = "List stream sinks by paginating")
public Response<PageResult<? extends StreamSink>> listByCondition(SinkPageRequest request) {
public Response<PageResult<? extends StreamSink>> listByCondition(@RequestBody SinkPageRequest request) {
return Response.success(sinkService.listByCondition(request));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public Response<StreamSource> get(@PathVariable Integer id) {
return Response.success(sourceService.get(id));
}

@RequestMapping(value = "/source/list", method = RequestMethod.GET)
@RequestMapping(value = "/source/list", method = RequestMethod.POST)
@ApiOperation(value = "List stream sources by paginating")
public Response<PageResult<? extends StreamSource>> listByCondition(SourcePageRequest request) {
public Response<PageResult<? extends StreamSource>> listByCondition(@RequestBody SourcePageRequest request) {
return Response.success(sourceService.listByCondition(request));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

package org.apache.inlong.manager.web.controller.openapi;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
import org.apache.inlong.manager.common.enums.OperationType;
import org.apache.inlong.manager.common.util.Preconditions;
Expand All @@ -39,11 +43,6 @@

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

/**
* Open InLong Stream Sink controller
*/
Expand All @@ -64,9 +63,9 @@ public Response<StreamSink> get(@PathVariable Integer id) {
return Response.success(sinkService.get(id, LoginUserUtils.getLoginUser()));
}

@RequestMapping(value = "/sink/list", method = RequestMethod.GET)
@RequestMapping(value = "/sink/list", method = RequestMethod.POST)
@ApiOperation(value = "List stream sinks by paginating")
public Response<List<? extends StreamSink>> listByCondition(SinkPageRequest request) {
public Response<List<? extends StreamSink>> listByCondition(@RequestBody SinkPageRequest request) {
Preconditions.expectNotNull(request, ErrorCodeEnum.INVALID_PARAMETER, "request cannot be null");
Preconditions.expectNotNull(LoginUserUtils.getLoginUser(), ErrorCodeEnum.LOGIN_USER_EMPTY);
return Response.success(sinkService.listByCondition(request, LoginUserUtils.getLoginUser()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public Response<StreamSource> get(@PathVariable Integer id) {
return Response.success(sourceService.get(id, LoginUserUtils.getLoginUser()));
}

@RequestMapping(value = "/source/list", method = RequestMethod.GET)
@RequestMapping(value = "/source/list", method = RequestMethod.POST)
@ApiOperation(value = "List stream sources by paginating")
public Response<PageResult<? extends StreamSource>> listByCondition(SourcePageRequest request) {
public Response<PageResult<? extends StreamSource>> listByCondition(@RequestBody SourcePageRequest request) {
Preconditions.expectNotNull(request, ErrorCodeEnum.INVALID_PARAMETER, "request cannot be null");
Preconditions.expectNotNull(LoginUserUtils.getLoginUser(), ErrorCodeEnum.LOGIN_USER_EMPTY);
return Response.success(sourceService.listByCondition(request, LoginUserUtils.getLoginUser()));
Expand Down

0 comments on commit 25b4221

Please sign in to comment.