use of org.apache.inlong.manager.client.api.auth.DefaultAuthentication 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;
}
use of org.apache.inlong.manager.client.api.auth.DefaultAuthentication in project incubator-inlong by apache.
the class InlongStreamSinkTransfer method parseHiveSink.
private static HiveSink parseHiveSink(HiveSinkResponse sinkResponse, StreamSink sink) {
HiveSink hiveSink = new HiveSink();
if (sink != null) {
AssertUtil.isTrue(sinkResponse.getSinkName().equals(sink.getSinkName()), String.format("SinkName is not equal: %s != %s", sinkResponse, sink));
HiveSink snapshot = (HiveSink) sink;
hiveSink.setSinkName(snapshot.getSinkName());
hiveSink.setDataSeparator(snapshot.getDataSeparator());
hiveSink.setCharset(snapshot.getCharset());
hiveSink.setAuthentication(snapshot.getAuthentication());
hiveSink.setWarehouseDir(snapshot.getWarehouseDir());
hiveSink.setFileFormat(snapshot.getFileFormat());
hiveSink.setJdbcUrl(snapshot.getJdbcUrl());
hiveSink.setTableName(snapshot.getTableName());
hiveSink.setDbName(snapshot.getDbName());
hiveSink.setHdfsDefaultFs(snapshot.getHdfsDefaultFs());
hiveSink.setSecondaryPartition(snapshot.getSecondaryPartition());
hiveSink.setPrimaryPartition(snapshot.getPrimaryPartition());
} else {
hiveSink.setSinkName(sinkResponse.getSinkName());
hiveSink.setDataSeparator(DataSeparator.forAscii(Integer.parseInt(sinkResponse.getDataSeparator())));
hiveSink.setCharset(Charset.forName(sinkResponse.getDataEncoding()));
String password = sinkResponse.getPassword();
String uname = sinkResponse.getUsername();
hiveSink.setAuthentication(new DefaultAuthentication(uname, password));
hiveSink.setWarehouseDir(sinkResponse.getWarehouseDir());
hiveSink.setFileFormat(FileFormat.forName(sinkResponse.getFileFormat()));
hiveSink.setJdbcUrl(sinkResponse.getJdbcUrl());
hiveSink.setTableName(sinkResponse.getTableName());
hiveSink.setDbName(sinkResponse.getDbName());
hiveSink.setHdfsDefaultFs(sinkResponse.getHdfsDefaultFs());
hiveSink.setSecondaryPartition(sinkResponse.getSecondaryPartition());
hiveSink.setPrimaryPartition(sinkResponse.getPrimaryPartition());
}
hiveSink.setProperties(sinkResponse.getProperties());
hiveSink.setSinkType(SinkType.HIVE);
hiveSink.setNeedCreated(sinkResponse.getEnableCreateResource() == 1);
if (CollectionUtils.isNotEmpty(sinkResponse.getFieldList())) {
hiveSink.setSinkFields(convertToSinkFields(sinkResponse.getFieldList()));
}
return hiveSink;
}
use of org.apache.inlong.manager.client.api.auth.DefaultAuthentication 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;
}
use of org.apache.inlong.manager.client.api.auth.DefaultAuthentication in project incubator-inlong by apache.
the class InlongStreamSourceTransfer method parseMySQLBinlogSource.
private static MySQLBinlogSource parseMySQLBinlogSource(BinlogSourceResponse response) {
MySQLBinlogSource binlogSource = new MySQLBinlogSource();
binlogSource.setSourceName(response.getSourceName());
binlogSource.setHostname(response.getHostname());
binlogSource.setDataFormat(DataFormat.NONE);
binlogSource.setPort(response.getPort());
binlogSource.setAgentIp(response.getAgentIp());
DefaultAuthentication defaultAuthentication = new DefaultAuthentication(response.getUser(), response.getPassword());
binlogSource.setAuthentication(defaultAuthentication);
binlogSource.setIncludeSchema(response.getIncludeSchema());
binlogSource.setServerTimezone(response.getServerTimezone());
binlogSource.setMonitoredDdl(response.getMonitoredDdl());
binlogSource.setTimestampFormatStandard(response.getTimestampFormatStandard());
binlogSource.setAllMigration(response.isAllMigration());
if (StringUtils.isNotBlank(response.getDatabaseWhiteList())) {
binlogSource.setDbNames(Arrays.asList(response.getDatabaseWhiteList().split(",")));
}
if (StringUtils.isNotBlank(response.getTableWhiteList())) {
binlogSource.setTableNames(Arrays.asList(response.getTableWhiteList().split(",")));
}
return binlogSource;
}
use of org.apache.inlong.manager.client.api.auth.DefaultAuthentication in project incubator-inlong by apache.
the class InlongStreamSinkTransfer method createHiveRequest.
private static HiveSinkRequest createHiveRequest(StreamSink streamSink, InlongStreamInfo streamInfo) {
HiveSinkRequest hiveSinkRequest = new HiveSinkRequest();
HiveSink hiveSink = (HiveSink) streamSink;
hiveSinkRequest.setSinkName(streamSink.getSinkName());
hiveSinkRequest.setInlongGroupId(streamInfo.getInlongGroupId());
hiveSinkRequest.setInlongStreamId(streamInfo.getInlongStreamId());
hiveSinkRequest.setDataEncoding(hiveSink.getCharset().name());
hiveSinkRequest.setEnableCreateTable(hiveSink.isNeedCreated() ? 1 : 0);
hiveSinkRequest.setDataSeparator(String.valueOf(hiveSink.getDataSeparator().getAsciiCode()));
hiveSinkRequest.setDbName(hiveSink.getDbName());
hiveSinkRequest.setTableName(hiveSink.getTableName());
hiveSinkRequest.setHdfsDefaultFs(hiveSink.getHdfsDefaultFs());
hiveSinkRequest.setJdbcUrl(hiveSink.getJdbcUrl());
hiveSinkRequest.setWarehouseDir(hiveSink.getWarehouseDir());
hiveSinkRequest.setFileFormat(hiveSink.getFileFormat().name());
hiveSinkRequest.setSinkType(hiveSink.getSinkType().name());
DefaultAuthentication defaultAuthentication = hiveSink.getAuthentication();
AssertUtil.notNull(defaultAuthentication, String.format("Hive storage:%s must be authenticated", hiveSink.getDbName()));
hiveSinkRequest.setUsername(defaultAuthentication.getUserName());
hiveSinkRequest.setPassword(defaultAuthentication.getPassword());
hiveSinkRequest.setPrimaryPartition(hiveSink.getPrimaryPartition());
hiveSinkRequest.setSecondaryPartition(hiveSink.getSecondaryPartition());
hiveSinkRequest.setProperties(hiveSink.getProperties());
if (CollectionUtils.isNotEmpty(hiveSink.getSinkFields())) {
List<SinkFieldRequest> fieldRequests = createSinkFieldRequests(streamSink.getSinkFields());
hiveSinkRequest.setFieldList(fieldRequests);
}
return hiveSinkRequest;
}
Aggregations