Search in sources :

Example 1 with ClickHouseSink

use of org.apache.inlong.manager.client.api.sink.ClickHouseSink in project incubator-inlong by apache.

the class InlongStreamSinkTransfer method createClickHouseRequest.

private static SinkRequest createClickHouseRequest(StreamSink streamSink, InlongStreamInfo streamInfo) {
    ClickHouseSinkRequest clickHouseSinkRequest = new ClickHouseSinkRequest();
    ClickHouseSink clickHouseSink = (ClickHouseSink) streamSink;
    clickHouseSinkRequest.setSinkName(clickHouseSink.getSinkName());
    clickHouseSinkRequest.setDatabaseName(clickHouseSink.getDatabaseName());
    clickHouseSinkRequest.setSinkType(clickHouseSink.getSinkType().name());
    clickHouseSinkRequest.setJdbcUrl(clickHouseSink.getJdbcUrl());
    DefaultAuthentication defaultAuthentication = clickHouseSink.getAuthentication();
    AssertUtil.notNull(defaultAuthentication, String.format("Clickhouse storage:%s must be authenticated", clickHouseSink.getDatabaseName()));
    clickHouseSinkRequest.setUsername(defaultAuthentication.getUserName());
    clickHouseSinkRequest.setPassword(defaultAuthentication.getPassword());
    clickHouseSinkRequest.setTableName(clickHouseSink.getTableName());
    clickHouseSinkRequest.setDistributedTable(clickHouseSink.getDistributedTable());
    clickHouseSinkRequest.setFlushInterval(clickHouseSink.getFlushInterval());
    clickHouseSinkRequest.setFlushRecordNumber(clickHouseSink.getFlushRecordNumber());
    clickHouseSinkRequest.setKeyFieldNames(clickHouseSink.getKeyFieldNames());
    clickHouseSinkRequest.setPartitionKey(clickHouseSink.getPartitionKey());
    clickHouseSinkRequest.setPartitionStrategy(clickHouseSink.getPartitionStrategy());
    clickHouseSinkRequest.setWriteMaxRetryTimes(clickHouseSink.getWriteMaxRetryTimes());
    clickHouseSinkRequest.setInlongGroupId(streamInfo.getInlongGroupId());
    clickHouseSinkRequest.setInlongStreamId(streamInfo.getInlongStreamId());
    clickHouseSinkRequest.setProperties(clickHouseSink.getProperties());
    clickHouseSinkRequest.setEnableCreateResource(clickHouseSink.isNeedCreated() ? 1 : 0);
    if (CollectionUtils.isNotEmpty(clickHouseSink.getSinkFields())) {
        List<SinkFieldRequest> fieldRequests = createSinkFieldRequests(streamSink.getSinkFields());
        clickHouseSinkRequest.setFieldList(fieldRequests);
    }
    return clickHouseSinkRequest;
}
Also used : ClickHouseSinkRequest(org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest) DefaultAuthentication(org.apache.inlong.manager.client.api.auth.DefaultAuthentication) SinkFieldRequest(org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest) ClickHouseSink(org.apache.inlong.manager.client.api.sink.ClickHouseSink)

Example 2 with ClickHouseSink

use of org.apache.inlong.manager.client.api.sink.ClickHouseSink in project incubator-inlong by apache.

the class InlongStreamSinkTransfer method parseClickHouseSink.

private static StreamSink parseClickHouseSink(ClickHouseSinkResponse sinkResponse, StreamSink streamSink) {
    ClickHouseSink clickHouseSink = new ClickHouseSink();
    if (streamSink != null) {
        AssertUtil.isTrue(sinkResponse.getSinkName().equals(streamSink.getSinkName()), String.format("SinkName is not equal: %s != %s", sinkResponse, streamSink));
        ClickHouseSink snapshot = (ClickHouseSink) streamSink;
        clickHouseSink = CommonBeanUtils.copyProperties(snapshot, ClickHouseSink::new);
    } else {
        clickHouseSink.setDistributedTable(sinkResponse.getDistributedTable());
        clickHouseSink.setSinkName(sinkResponse.getSinkName());
        clickHouseSink.setFlushInterval(sinkResponse.getFlushInterval());
        clickHouseSink.setAuthentication(new DefaultAuthentication(sinkResponse.getSinkName(), sinkResponse.getPassword()));
        clickHouseSink.setDatabaseName(sinkResponse.getDatabaseName());
        clickHouseSink.setFlushRecordNumber(sinkResponse.getFlushRecordNumber());
        clickHouseSink.setJdbcUrl(sinkResponse.getJdbcUrl());
        clickHouseSink.setPartitionKey(sinkResponse.getPartitionKey());
        clickHouseSink.setKeyFieldNames(sinkResponse.getKeyFieldNames());
        clickHouseSink.setPartitionStrategy(sinkResponse.getPartitionStrategy());
        clickHouseSink.setWriteMaxRetryTimes(sinkResponse.getWriteMaxRetryTimes());
        clickHouseSink.setDistributedTable(sinkResponse.getDistributedTable());
    }
    clickHouseSink.setProperties(sinkResponse.getProperties());
    clickHouseSink.setNeedCreated(sinkResponse.getEnableCreateResource() == 1);
    if (CollectionUtils.isNotEmpty(sinkResponse.getFieldList())) {
        clickHouseSink.setSinkFields(convertToSinkFields(sinkResponse.getFieldList()));
    }
    return clickHouseSink;
}
Also used : DefaultAuthentication(org.apache.inlong.manager.client.api.auth.DefaultAuthentication) ClickHouseSink(org.apache.inlong.manager.client.api.sink.ClickHouseSink)

Aggregations

DefaultAuthentication (org.apache.inlong.manager.client.api.auth.DefaultAuthentication)2 ClickHouseSink (org.apache.inlong.manager.client.api.sink.ClickHouseSink)2 SinkFieldRequest (org.apache.inlong.manager.common.pojo.sink.SinkFieldRequest)1 ClickHouseSinkRequest (org.apache.inlong.manager.common.pojo.sink.ck.ClickHouseSinkRequest)1