You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/07/10 02:21:18 UTC

[GitHub] [flink] TsReaper commented on a change in pull request #9029: [FLINK-13118][jdbc] Introduce JDBC table factory and bridge JDBC table source with streaming table source

TsReaper commented on a change in pull request #9029: [FLINK-13118][jdbc] Introduce JDBC table factory and bridge JDBC table source with streaming table source
URL: https://github.com/apache/flink/pull/9029#discussion_r301862857
 
 

 ##########
 File path: flink-connectors/flink-jdbc/src/main/java/org/apache/flink/api/java/io/jdbc/JDBCTableSourceSinkFactory.java
 ##########
 @@ -0,0 +1,268 @@
+/*
+ * 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.flink.api.java.io.jdbc;
+
+import org.apache.flink.api.java.io.jdbc.dialect.JDBCDialect;
+import org.apache.flink.api.java.io.jdbc.dialect.JDBCDialects;
+import org.apache.flink.api.java.tuple.Tuple2;
+import org.apache.flink.table.descriptors.DescriptorProperties;
+import org.apache.flink.table.descriptors.SchemaValidator;
+import org.apache.flink.table.factories.StreamTableSinkFactory;
+import org.apache.flink.table.factories.StreamTableSourceFactory;
+import org.apache.flink.table.sinks.StreamTableSink;
+import org.apache.flink.table.sources.StreamTableSource;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.Preconditions;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import static org.apache.flink.table.descriptors.ConnectorDescriptorValidator.CONNECTOR_PROPERTY_VERSION;
+import static org.apache.flink.table.descriptors.ConnectorDescriptorValidator.CONNECTOR_TYPE;
+import static org.apache.flink.table.descriptors.Rowtime.ROWTIME_TIMESTAMPS_CLASS;
+import static org.apache.flink.table.descriptors.Rowtime.ROWTIME_TIMESTAMPS_FROM;
+import static org.apache.flink.table.descriptors.Rowtime.ROWTIME_TIMESTAMPS_SERIALIZED;
+import static org.apache.flink.table.descriptors.Rowtime.ROWTIME_TIMESTAMPS_TYPE;
+import static org.apache.flink.table.descriptors.Rowtime.ROWTIME_WATERMARKS_CLASS;
+import static org.apache.flink.table.descriptors.Rowtime.ROWTIME_WATERMARKS_DELAY;
+import static org.apache.flink.table.descriptors.Rowtime.ROWTIME_WATERMARKS_SERIALIZED;
+import static org.apache.flink.table.descriptors.Rowtime.ROWTIME_WATERMARKS_TYPE;
+import static org.apache.flink.table.descriptors.Schema.SCHEMA;
+import static org.apache.flink.table.descriptors.Schema.SCHEMA_FROM;
+import static org.apache.flink.table.descriptors.Schema.SCHEMA_NAME;
+import static org.apache.flink.table.descriptors.Schema.SCHEMA_PROCTIME;
+import static org.apache.flink.table.descriptors.Schema.SCHEMA_TYPE;
+
+/**
+ * Factory for creating configured instances of {@link JDBCTableSource} and {@link JDBCUpsertTableSink}.
+ */
+public class JDBCTableSourceSinkFactory implements
+	StreamTableSourceFactory<Row>,
+	StreamTableSinkFactory<Tuple2<Boolean, Row>> {
+
+	public static final String CONNECTOR_DRIVER_NAME = "connector.driver.name";
+	public static final String CONNECTOR_URL = "connector.url";
+	public static final String CONNECTOR_TABLE_NAME = "connector.table.name";
+	public static final String CONNECTOR_USERNAME = "connector.username";
+	public static final String CONNECTOR_PASSWORD = "connector.password";
+
+	public static final String CONNECTOR_SCAN_PARTITION_COLUMN_NAME = "connector.scan.partition.column.name";
+	public static final String CONNECTOR_SCAN_PARTITION_SIZE = "connector.scan.partition.size";
+	public static final String CONNECTOR_SCAN_PARTITION_LOWER = "connector.scan.partition.lower";
+	public static final String CONNECTOR_SCAN_PARTITION_UPPER = "connector.scan.partition.upper";
+
+	public static final String CONNECTOR_LOOKUP_CACHE_MAX_SIZE = "connector.lookup.cache.max-size";
+	public static final String CONNECTOR_LOOKUP_CACHE_EXPIRE_MS = "connector.lookup.cache.expire-ms";
+	public static final String CONNECTOR_LOOKUP_MAX_RETRY_TIMES = "connector.lookup.max-retry-times";
+
+	public static final String CONNECTOR_SINK_UPDATE_MODE = "connector.sink.update-mode";
+	public static final String CONNECTOR_SINK_FLUSH_MAX_SIZE = "connector.sink.flush.max-size";
+	public static final String CONNECTOR_SINK_FLUSH_INTERVAL_MS = "connector.sink.flush.interval-ms";
+	public static final String CONNECTOR_SINK_MAX_RETRY_TIMES = "connector.sink.max-retry-times";
+
+	@Override
+	public Map<String, String> requiredContext() {
+		Map<String, String> context = new HashMap<>();
+		context.put(CONNECTOR_TYPE, "jdbc"); // jdbc
 
 Review comment:
   No. `requiredContext` means that a specific property key must have a specific property value. As `CONNECTOR_URL` and `CONNECTOR_TABLE_NAME` will change according to the users' needs, they should not be in the `requiredContext`.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services