Search in sources :

Example 1 with SourceRequest

use of org.apache.inlong.manager.common.pojo.source.SourceRequest in project incubator-inlong by apache.

the class InnerInlongManagerClient method updateSource.

public Pair<Boolean, String> updateSource(SourceRequest sourceRequest) {
    final String path = HTTP_PATH + "/source/update";
    final String url = formatUrl(path);
    final String storage = GsonUtil.toJson(sourceRequest);
    final RequestBody storageBody = RequestBody.create(MediaType.parse("application/json"), storage);
    Request request = new Request.Builder().method("POST", storageBody).url(url).build();
    Call call = httpClient.newCall(request);
    try {
        Response response = call.execute();
        String body = response.body().string();
        AssertUtil.isTrue(response.isSuccessful(), String.format("Inlong request failed:%s", body));
        org.apache.inlong.manager.common.beans.Response responseBody = InlongParser.parseResponse(body);
        if (responseBody.getData() != null) {
            return Pair.of(Boolean.valueOf(responseBody.getData().toString()), responseBody.getErrMsg());
        } else {
            return Pair.of(false, responseBody.getErrMsg());
        }
    } catch (Exception e) {
        throw new RuntimeException(String.format("Inlong source update failed with ex:%s", e.getMessage()), e);
    }
}
Also used : Response(okhttp3.Response) InlongStreamConfigLogListResponse(org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse) SinkListResponse(org.apache.inlong.manager.common.pojo.sink.SinkListResponse) SourceListResponse(org.apache.inlong.manager.common.pojo.source.SourceListResponse) InlongGroupListResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse) InlongGroupResponse(org.apache.inlong.manager.common.pojo.group.InlongGroupResponse) FullStreamResponse(org.apache.inlong.manager.common.pojo.stream.FullStreamResponse) Call(okhttp3.Call) SinkRequest(org.apache.inlong.manager.common.pojo.sink.SinkRequest) Request(okhttp3.Request) InlongStreamApproveRequest(org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest) InlongGroupRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupRequest) SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest) InlongGroupApproveRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest) RequestBody(okhttp3.RequestBody)

Example 2 with SourceRequest

use of org.apache.inlong.manager.common.pojo.source.SourceRequest in project incubator-inlong by apache.

the class StreamSourceServiceImpl method restart.

@Override
public boolean restart(Integer id, String sourceType, String operator) {
    LOGGER.info("begin to restart source by id={}, sourceType={}", id, sourceType);
    Preconditions.checkNotNull(id, Constant.ID_IS_EMPTY);
    StreamSourceEntity entity = sourceMapper.selectByPrimaryKey(id);
    Preconditions.checkNotNull(entity, ErrorCodeEnum.SOURCE_INFO_NOT_FOUND.getMessage());
    commonOperateService.checkGroupStatus(entity.getInlongGroupId(), operator);
    StreamSourceOperation operation = operationFactory.getInstance(SourceType.forType(sourceType));
    SourceRequest sourceRequest = new SourceRequest();
    CommonBeanUtils.copyProperties(entity, sourceRequest, true);
    operation.restartOpt(sourceRequest, operator);
    LOGGER.info("success to restart source info:{}", entity);
    return true;
}
Also used : SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest) StreamSourceEntity(org.apache.inlong.manager.dao.entity.StreamSourceEntity)

Example 3 with SourceRequest

use of org.apache.inlong.manager.common.pojo.source.SourceRequest in project incubator-inlong by apache.

the class DefaultInlongStreamBuilder method source.

@Override
public InlongStreamBuilder source(StreamSource source) {
    inlongStream.addSource(source);
    SourceRequest sourceRequest = InlongStreamSourceTransfer.createSourceRequest(source, streamContext.getStreamInfo());
    streamContext.setSourceRequest(sourceRequest);
    return this;
}
Also used : SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest)

Example 4 with SourceRequest

use of org.apache.inlong.manager.common.pojo.source.SourceRequest in project incubator-inlong by apache.

the class DefaultInlongStreamBuilder method initOrUpdate.

@Override
public InlongStream initOrUpdate() {
    InlongStreamInfo dataStreamInfo = streamContext.getStreamInfo();
    Pair<Boolean, InlongStreamInfo> existMsg = managerClient.isStreamExists(dataStreamInfo);
    if (existMsg.getKey()) {
        Pair<Boolean, String> updateMsg = managerClient.updateStreamInfo(dataStreamInfo);
        if (updateMsg.getKey()) {
            List<SourceRequest> sourceRequests = Lists.newArrayList(streamContext.getSourceRequests().values());
            for (SourceRequest sourceRequest : sourceRequests) {
                sourceRequest.setId(initOrUpdateSource(sourceRequest));
            }
            List<SinkRequest> sinkRequests = Lists.newArrayList(streamContext.getSinkRequests().values());
            for (SinkRequest sinkRequest : sinkRequests) {
                sinkRequest.setId(initOrUpdateSink(sinkRequest));
            }
        } else {
            throw new RuntimeException(String.format("Update data stream failed:%s", updateMsg.getValue()));
        }
        return inlongStream;
    } else {
        return init();
    }
}
Also used : SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest) SinkRequest(org.apache.inlong.manager.common.pojo.sink.SinkRequest) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Example 5 with SourceRequest

use of org.apache.inlong.manager.common.pojo.source.SourceRequest in project incubator-inlong by apache.

the class DefaultInlongStreamBuilder method init.

@Override
public InlongStream init() {
    InlongStreamInfo streamInfo = streamContext.getStreamInfo();
    String streamIndex = managerClient.createStreamInfo(streamInfo);
    streamInfo.setId(Double.valueOf(streamIndex).intValue());
    // Create source and update index
    List<SourceRequest> sourceRequests = Lists.newArrayList(streamContext.getSourceRequests().values());
    for (SourceRequest sourceRequest : sourceRequests) {
        String sourceIndex = managerClient.createSource(sourceRequest);
        sourceRequest.setId(Double.valueOf(sourceIndex).intValue());
    }
    // Create sink and update index
    List<SinkRequest> sinkRequests = Lists.newArrayList(streamContext.getSinkRequests().values());
    for (SinkRequest sinkRequest : sinkRequests) {
        String sinkIndex = managerClient.createSink(sinkRequest);
        sinkRequest.setId(Double.valueOf(sinkIndex).intValue());
    }
    return inlongStream;
}
Also used : SourceRequest(org.apache.inlong.manager.common.pojo.source.SourceRequest) SinkRequest(org.apache.inlong.manager.common.pojo.sink.SinkRequest) InlongStreamInfo(org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)

Aggregations

SourceRequest (org.apache.inlong.manager.common.pojo.source.SourceRequest)9 SinkRequest (org.apache.inlong.manager.common.pojo.sink.SinkRequest)4 StreamSourceEntity (org.apache.inlong.manager.dao.entity.StreamSourceEntity)3 Call (okhttp3.Call)2 Request (okhttp3.Request)2 RequestBody (okhttp3.RequestBody)2 Response (okhttp3.Response)2 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)2 InlongGroupListResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupListResponse)2 InlongGroupRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupRequest)2 InlongGroupResponse (org.apache.inlong.manager.common.pojo.group.InlongGroupResponse)2 SinkListResponse (org.apache.inlong.manager.common.pojo.sink.SinkListResponse)2 SourceListResponse (org.apache.inlong.manager.common.pojo.source.SourceListResponse)2 FullStreamResponse (org.apache.inlong.manager.common.pojo.stream.FullStreamResponse)2 InlongStreamApproveRequest (org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest)2 InlongStreamConfigLogListResponse (org.apache.inlong.manager.common.pojo.stream.InlongStreamConfigLogListResponse)2 InlongStreamInfo (org.apache.inlong.manager.common.pojo.stream.InlongStreamInfo)2 SourceResponse (org.apache.inlong.manager.common.pojo.source.SourceResponse)1 BinlogSourceRequest (org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceRequest)1 BinlogSourceResponse (org.apache.inlong.manager.common.pojo.source.binlog.BinlogSourceResponse)1