You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/05/18 01:56:48 UTC

[GitHub] [incubator-inlong] baomingyu opened a new pull request, #4241: [INLONG-4240][Manager]Add postgres source and sink node configuration utils

baomingyu opened a new pull request, #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241

   Add postgres source and sink node configuration utils
   
   Fixes #4240
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] baomingyu commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
baomingyu commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r875645323


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/LoadNodeUtils.java:
##########
@@ -161,6 +165,29 @@ public static HiveLoadNode createLoadNode(HiveSinkResponse hiveSinkResponse) {
         );
     }
 
+    /**
+     * create Postgres sink response
+     * @param postgresSinkResponse postgresSinkResponse
+     * @return
+     */
+    public static PostgresLoadNode createLoadNode(PostgresSinkResponse postgresSinkResponse) {
+        List<SinkFieldResponse> sinkFieldResponses = postgresSinkResponse.getFieldList();
+
+        String name = postgresSinkResponse.getSinkName();
+        List<FieldInfo> fields = sinkFieldResponses.stream()
+                .map(sinkFieldResponse -> FieldInfoUtils.parseSinkFieldInfo(sinkFieldResponse,
+                        name))
+                .collect(Collectors.toList());
+        List<FieldRelationShip> fieldRelationShips = parseSinkFields(sinkFieldResponses, name);
+        return new PostgresLoadNode(postgresSinkResponse.getSinkName(),
+                postgresSinkResponse.getSinkName(),
+                fields, fieldRelationShips, null, null, 1,
+                null, postgresSinkResponse.getJdbcUrl(), postgresSinkResponse.getUsername(),
+                postgresSinkResponse.getPassword(),
+                postgresSinkResponse.getDbName() + "." + postgresSinkResponse.getTableName(),

Review Comment:
   dbName will be more clear when configuring.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] gong commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
gong commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r875541433


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/sink/PostgresSink.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.api.sink;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.client.api.auth.DefaultAuthentication;
+import org.apache.inlong.manager.common.enums.DataFormat;
+import org.apache.inlong.manager.common.enums.SinkType;
+import org.apache.inlong.manager.common.pojo.stream.SinkField;
+import org.apache.inlong.manager.common.pojo.stream.StreamSink;
+
+/**
+ * Postgres sink.
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("Postgres sink configuration")
+public class PostgresSink extends StreamSink {
+
+    @ApiModelProperty(value = "Sink type", required = true)
+    private SinkType sinkType = SinkType.POSTGRES;
+
+    @ApiModelProperty("Postgres JDBC URL")
+    private String jdbcUrl;
+
+    @ApiModelProperty("Target database name")
+    private String dbName;
+
+    @ApiModelProperty("Authentication for postgres")
+    private DefaultAuthentication authentication;
+
+    @ApiModelProperty("Target table name")
+    private String tableName;
+
+    @ApiModelProperty("Data format type for stream sink")
+    private DataFormat dataFormat;

Review Comment:
   `dataFormat` should not be need. `kafka` and `pulsar` may be need it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] baomingyu commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
baomingyu commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r875633926


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/sink/PostgresSink.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.api.sink;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.client.api.auth.DefaultAuthentication;
+import org.apache.inlong.manager.common.enums.DataFormat;
+import org.apache.inlong.manager.common.enums.SinkType;
+import org.apache.inlong.manager.common.pojo.stream.SinkField;
+import org.apache.inlong.manager.common.pojo.stream.StreamSink;
+
+/**
+ * Postgres sink.
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("Postgres sink configuration")
+public class PostgresSink extends StreamSink {
+
+    @ApiModelProperty(value = "Sink type", required = true)
+    private SinkType sinkType = SinkType.POSTGRES;
+
+    @ApiModelProperty("Postgres JDBC URL")
+    private String jdbcUrl;
+
+    @ApiModelProperty("Target database name")
+    private String dbName;
+
+    @ApiModelProperty("Authentication for postgres")
+    private DefaultAuthentication authentication;
+
+    @ApiModelProperty("Target table name")
+    private String tableName;
+
+    @ApiModelProperty("Data format type for stream sink")
+    private DataFormat dataFormat;

Review Comment:
   yes, dataFormat is not need here, but  this class extend StreamSink, so must add dataFormat here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] gong commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
gong commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r875544001


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sink/postgres/PostgresSinkDTO.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.common.pojo.sink.postgres;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Map;
+import javax.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+
+/**
+ * Postgres sink info
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class PostgresSinkDTO {
+
+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+    @ApiModelProperty("postgres JDBC URL")
+    private String jdbcUrl;
+
+    @ApiModelProperty("Username for JDBC URL")
+    private String username;
+
+    @ApiModelProperty("User password")
+    private String password;
+
+    @ApiModelProperty("Target database name")
+    private String dbName;
+
+    @ApiModelProperty("Target table name")
+    private String tableName;
+
+    @ApiModelProperty("Primary key is required when serializationType is json, avro")

Review Comment:
   describe error.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] healchow merged pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
healchow merged PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r879056973


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/ExtractNodeUtils.java:
##########
@@ -249,4 +253,25 @@ public static PulsarExtractNode createExtractNode(PulsarSourceResponse pulsarSou
                 startupMode.getValue(),
                 primaryKey);
     }
+
+    /**
+     * Create PostgresExtractNode based KafkaSourceResponse

Review Comment:
   Not `Kafka` please.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] gong commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
gong commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r875553911


##########
inlong-manager/manager-service/src/main/java/org/apache/inlong/manager/service/sort/util/LoadNodeUtils.java:
##########
@@ -161,6 +165,29 @@ public static HiveLoadNode createLoadNode(HiveSinkResponse hiveSinkResponse) {
         );
     }
 
+    /**
+     * create Postgres sink response
+     * @param postgresSinkResponse postgresSinkResponse
+     * @return
+     */
+    public static PostgresLoadNode createLoadNode(PostgresSinkResponse postgresSinkResponse) {
+        List<SinkFieldResponse> sinkFieldResponses = postgresSinkResponse.getFieldList();
+
+        String name = postgresSinkResponse.getSinkName();
+        List<FieldInfo> fields = sinkFieldResponses.stream()
+                .map(sinkFieldResponse -> FieldInfoUtils.parseSinkFieldInfo(sinkFieldResponse,
+                        name))
+                .collect(Collectors.toList());
+        List<FieldRelationShip> fieldRelationShips = parseSinkFields(sinkFieldResponses, name);
+        return new PostgresLoadNode(postgresSinkResponse.getSinkName(),
+                postgresSinkResponse.getSinkName(),
+                fields, fieldRelationShips, null, null, 1,
+                null, postgresSinkResponse.getJdbcUrl(), postgresSinkResponse.getUsername(),
+                postgresSinkResponse.getPassword(),
+                postgresSinkResponse.getDbName() + "." + postgresSinkResponse.getTableName(),

Review Comment:
   `dbName` stands for schema name? May be better to change naming to `schemaName`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] baomingyu commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
baomingyu commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r878693460


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/sink/PostgresSink.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.api.sink;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.client.api.auth.DefaultAuthentication;
+import org.apache.inlong.manager.common.enums.DataFormat;
+import org.apache.inlong.manager.common.enums.SinkType;
+import org.apache.inlong.manager.common.pojo.stream.SinkField;
+import org.apache.inlong.manager.common.pojo.stream.StreamSink;
+
+/**
+ * Postgres sink.
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("Postgres sink configuration")
+public class PostgresSink extends StreamSink {
+
+    @ApiModelProperty(value = "Sink type", required = true)
+    private SinkType sinkType = SinkType.POSTGRES;
+
+    @ApiModelProperty("Postgres JDBC URL")
+    private String jdbcUrl;
+
+    @ApiModelProperty("Target database name")
+    private String dbName;
+
+    @ApiModelProperty("Authentication for postgres")
+    private DefaultAuthentication authentication;
+
+    @ApiModelProperty("Target table name")
+    private String tableName;
+
+    @ApiModelProperty("Data format type for stream sink")
+    private DataFormat dataFormat;

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] baomingyu commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
baomingyu commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r875643991


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/source/PostgresSource.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.api.source;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.common.enums.DataFormat;
+import org.apache.inlong.manager.common.enums.SourceType;
+import org.apache.inlong.manager.common.pojo.stream.StreamSource;
+
+/**
+ * Postgres source.
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel("Base configuration for Postgres collection")
+public class PostgresSource extends StreamSource {
+
+    @ApiModelProperty(value = "DataSource type", required = true)
+    private SourceType sourceType = SourceType.POSTGRES;
+
+    @ApiModelProperty("SyncType")
+    private SyncType syncType = SyncType.INCREMENT;
+
+    @ApiModelProperty("Data format type")
+    private DataFormat dataFormat = DataFormat.NONE;
+
+    @ApiModelProperty("Db server username")
+    private String username;
+
+    @ApiModelProperty("Db password")
+    private String password;
+
+    @ApiModelProperty("DB Server hostname")
+    private String hostname;
+
+    @ApiModelProperty("DB Server port")
+    private int port;
+
+    @ApiModelProperty("Database name")
+    private String dbName;
+
+    @ApiModelProperty("schema info")
+    private String schema;
+
+    @ApiModelProperty("Data table name list")
+    private List<String> tableNameList;
+
+    @ApiModelProperty("decoding pulgin name")
+    private String decodingPluginName;
+
+    @ApiModelProperty("Primary key, needed when data format is csv, json, avro")

Review Comment:
   done



##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sink/postgres/PostgresSinkDTO.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.common.pojo.sink.postgres;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Map;
+import javax.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+
+/**
+ * Postgres sink info
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class PostgresSinkDTO {
+
+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+    @ApiModelProperty("postgres JDBC URL")
+    private String jdbcUrl;
+
+    @ApiModelProperty("Username for JDBC URL")
+    private String username;
+
+    @ApiModelProperty("User password")
+    private String password;
+
+    @ApiModelProperty("Target database name")
+    private String dbName;
+
+    @ApiModelProperty("Target table name")
+    private String tableName;
+
+    @ApiModelProperty("Primary key is required when serializationType is json, avro")

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] gong commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
gong commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r875542940


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/source/PostgresSource.java:
##########
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.api.source;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.common.enums.DataFormat;
+import org.apache.inlong.manager.common.enums.SourceType;
+import org.apache.inlong.manager.common.pojo.stream.StreamSource;
+
+/**
+ * Postgres source.
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel("Base configuration for Postgres collection")
+public class PostgresSource extends StreamSource {
+
+    @ApiModelProperty(value = "DataSource type", required = true)
+    private SourceType sourceType = SourceType.POSTGRES;
+
+    @ApiModelProperty("SyncType")
+    private SyncType syncType = SyncType.INCREMENT;
+
+    @ApiModelProperty("Data format type")
+    private DataFormat dataFormat = DataFormat.NONE;
+
+    @ApiModelProperty("Db server username")
+    private String username;
+
+    @ApiModelProperty("Db password")
+    private String password;
+
+    @ApiModelProperty("DB Server hostname")
+    private String hostname;
+
+    @ApiModelProperty("DB Server port")
+    private int port;
+
+    @ApiModelProperty("Database name")
+    private String dbName;
+
+    @ApiModelProperty("schema info")
+    private String schema;
+
+    @ApiModelProperty("Data table name list")
+    private List<String> tableNameList;
+
+    @ApiModelProperty("decoding pulgin name")
+    private String decodingPluginName;
+
+    @ApiModelProperty("Primary key, needed when data format is csv, json, avro")

Review Comment:
   describe error.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] gong commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
gong commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r875541867


##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/sink/PostgresSink.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.api.sink;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.client.api.auth.DefaultAuthentication;
+import org.apache.inlong.manager.common.enums.DataFormat;
+import org.apache.inlong.manager.common.enums.SinkType;
+import org.apache.inlong.manager.common.pojo.stream.SinkField;
+import org.apache.inlong.manager.common.pojo.stream.StreamSink;
+
+/**
+ * Postgres sink.
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("Postgres sink configuration")
+public class PostgresSink extends StreamSink {
+
+    @ApiModelProperty(value = "Sink type", required = true)
+    private SinkType sinkType = SinkType.POSTGRES;
+
+    @ApiModelProperty("Postgres JDBC URL")
+    private String jdbcUrl;
+
+    @ApiModelProperty("Target database name")
+    private String dbName;
+
+    @ApiModelProperty("Authentication for postgres")
+    private DefaultAuthentication authentication;
+
+    @ApiModelProperty("Target table name")
+    private String tableName;
+
+    @ApiModelProperty("Data format type for stream sink")
+    private DataFormat dataFormat;
+
+    @ApiModelProperty("Field definitions for postgres")
+    private List<SinkField> sinkFields;
+
+    @ApiModelProperty("Primary key is required when dataFormat is json, avro")

Review Comment:
   describe error.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-inlong] healchow commented on a diff in pull request #4241: [INLONG-4240][Manager] Support postgres source and sink

Posted by GitBox <gi...@apache.org>.
healchow commented on code in PR #4241:
URL: https://github.com/apache/incubator-inlong/pull/4241#discussion_r876002410


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/pojo/sink/postgres/PostgresSinkDTO.java:
##########
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.common.pojo.sink.postgres;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.Map;
+import javax.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Builder;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.common.enums.ErrorCodeEnum;
+import org.apache.inlong.manager.common.exceptions.BusinessException;
+
+/**
+ * Postgres sink info
+ */
+@Data
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class PostgresSinkDTO {
+
+    private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+    @ApiModelProperty("postgres JDBC URL")
+    private String jdbcUrl;
+
+    @ApiModelProperty("Username for JDBC URL")
+    private String username;
+
+    @ApiModelProperty("User password")
+    private String password;
+
+    @ApiModelProperty("Target database name")
+    private String dbName;
+
+    @ApiModelProperty("Target table name")
+    private String tableName;
+
+    @ApiModelProperty("Primary key")
+    private String primaryKey;
+
+    @ApiModelProperty("Properties for postgres")
+    private Map<String, Object> properties;
+
+    /**
+     * Get the dto instance from the request
+     */
+    public static PostgresSinkDTO getFromRequest(PostgresSinkRequest request) {
+        return PostgresSinkDTO.builder()
+                .jdbcUrl(request.getJdbcUrl())
+                .username(request.getUsername())
+                .password(request.getPassword())
+                .dbName(request.getDbName())
+                .primaryKey(request.getPrimaryKey())
+                .tableName(request.getTableName())
+                .properties(request.getProperties())
+                .build();
+    }
+
+    public static PostgresSinkDTO getFromJson(@NotNull String extParams) {

Review Comment:
   Java doc, please.



##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/sink/PostgresSink.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.inlong.manager.client.api.sink;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.inlong.manager.client.api.auth.DefaultAuthentication;
+import org.apache.inlong.manager.common.enums.DataFormat;
+import org.apache.inlong.manager.common.enums.SinkType;
+import org.apache.inlong.manager.common.pojo.stream.SinkField;
+import org.apache.inlong.manager.common.pojo.stream.StreamSink;
+
+/**
+ * Postgres sink.
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@ApiModel("Postgres sink configuration")
+public class PostgresSink extends StreamSink {
+
+    @ApiModelProperty(value = "Sink type", required = true)
+    private SinkType sinkType = SinkType.POSTGRES;
+
+    @ApiModelProperty("Postgres JDBC URL")
+    private String jdbcUrl;
+
+    @ApiModelProperty("Target database name")
+    private String dbName;
+
+    @ApiModelProperty("Authentication for postgres")
+    private DefaultAuthentication authentication;
+
+    @ApiModelProperty("Target table name")
+    private String tableName;
+
+    @ApiModelProperty("Data format type for stream sink")
+    private DataFormat dataFormat;

Review Comment:
   Maybe you can resolve like this:
   ```
       @Override
       public DataFormat getDataFormat() {
           return DataFormat.NONE;
       }
   ```



##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSinkTransfer.java:
##########
@@ -299,4 +306,59 @@ private static HiveSink parseHiveSink(HiveSinkResponse sinkResponse, StreamSink
         return hiveSink;
     }
 
+    private static SinkRequest createPostgresRequest(StreamSink streamSink, InlongStreamInfo streamInfo) {

Review Comment:
   Please add java docs for public or static methods, thanks.



##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSourceTransfer.java:
##########
@@ -158,6 +166,26 @@ private static AutoPushSource parseAutoPushSource(AutoPushSourceResponse respons
         return autoPushSource;
     }
 
+    private static PostgresSource parsePostgresSource(PostgresSourceResponse response) {

Review Comment:
   Java doc, please.



##########
inlong-manager/manager-client/src/main/java/org/apache/inlong/manager/client/api/util/InlongStreamSourceTransfer.java:
##########
@@ -250,4 +278,28 @@ private static AutoPushSourceRequest createAutoPushSourceRequest(AutoPushSource
         sourceRequest.setFieldList(InlongStreamTransfer.createStreamFields(source.getFields(), streamInfo));
         return sourceRequest;
     }
+
+    private static PostgresSourceRequest createPostgresSourceRequest(PostgresSource source,

Review Comment:
   ditto.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org