vernedeng commented on code in PR #9031: URL: https://github.com/apache/inlong/pull/9031#discussion_r1355962967
########## inlong-sort/sort-flink/sort-flink-v1.15/sort-connectors/tubemq/src/main/java/org/apache/inlong/sort/tubemq/table/TubeMQOptions.java: ########## @@ -0,0 +1,420 @@ +/* + * 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.sort.tubemq.table; + +import org.apache.flink.configuration.ConfigOption; +import org.apache.flink.configuration.ConfigOptions; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.configuration.ReadableConfig; +import org.apache.flink.configuration.description.Description; +import org.apache.flink.table.api.TableException; +import org.apache.flink.table.api.ValidationException; +import org.apache.flink.table.types.DataType; +import org.apache.flink.table.types.logical.LogicalType; +import org.apache.flink.table.types.logical.LogicalTypeRoot; +import org.apache.flink.table.types.logical.utils.LogicalTypeChecks; +import org.apache.flink.util.Preconditions; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.TreeSet; +import java.util.function.Consumer; +import java.util.stream.IntStream; + +import static org.apache.flink.table.factories.FactoryUtil.FORMAT; + +/** + * Option utils for tubeMQ table source and sink. + */ +public class TubeMQOptions { + + // -------------------------------------------------------------------------------------------- + // Option enumerations + // -------------------------------------------------------------------------------------------- + + public static final String PROPERTIES_PREFIX = "properties."; + + // Start up offset. + // Always start from the max consume position. + public static final String CONSUMER_FROM_MAX_OFFSET_ALWAYS = "max"; + // Start from the latest position for the first time. Otherwise start from last consume position. + public static final String CONSUMER_FROM_LATEST_OFFSET = "latest"; + // Start from 0 for the first time. Otherwise start from last consume position. + public static final String CONSUMER_FROM_FIRST_OFFSET = "earliest"; + + // -------------------------------------------------------------------------------------------- + // Format options + // -------------------------------------------------------------------------------------------- + + public static final ConfigOption<String> KEY_FORMAT = ConfigOptions + .key("key." + FORMAT.key()) + .stringType() + .noDefaultValue() + .withDescription("Defines the format identifier for encoding key data. " + + "The identifier is used to discover a suitable format factory."); + + public static final ConfigOption<List<String>> KEY_FIELDS = + ConfigOptions.key("key.fields") + .stringType() + .asList() + .defaultValues() + .withDescription( + "Defines an explicit list of physical columns from the table schema " + + "that configure the data type for the key format. By default, this list is " + + "empty and thus a key is undefined."); + + // -------------------------------------------------------------------------------------------- + // TubeMQ specific options + // -------------------------------------------------------------------------------------------- + + public static final ConfigOption<String> TOPIC = + ConfigOptions.key("topic") + .stringType() + .noDefaultValue() + .withDescription( + "Topic names from which the table is read. Either 'topic' " + + "or 'topic-pattern' must be set for source."); + + public static final ConfigOption<String> TOPIC_PATTERN = + ConfigOptions.key("topic-pattern") + .stringType() + .noDefaultValue() + .withDescription( + "Optional topic pattern from which the table is read for source." + + " Either 'topic' or 'topic-pattern' must be set."); + + public static final ConfigOption<String> MASTER_RPC = + ConfigOptions.key("master.rpc") + .stringType() + .noDefaultValue() + .withDescription("Required TubeMQ master connection string"); + + public static final ConfigOption<String> GROUP_ID = + ConfigOptions.key("group.id") + .stringType() + .noDefaultValue() + .withDescription( + "Required consumer group in TubeMQ consumer"); + + public static final ConfigOption<String> TUBE_MESSAGE_NOT_FOUND_WAIT_PERIOD = + ConfigOptions.key("tubemq.message.not.found.wait.period") + .stringType() + .defaultValue("350ms") + .withDescription("The time of waiting period if " + + "tubeMQ broker return message not found."); + + public static final ConfigOption<Long> TUBE_SUBSCRIBE_RETRY_TIMEOUT = + ConfigOptions.key("tubemq.subscribe.retry.timeout") + .longType() + .defaultValue(300000L) + .withDescription("The time of subscribing tubeMQ timeout, in millisecond"); + + public static final ConfigOption<Integer> SOURCE_EVENT_QUEUE_CAPACITY = + ConfigOptions.key("source.event.queue.capacity") + .intType() + .defaultValue(1024); + + public static final ConfigOption<String> SESSION_KEY = + ConfigOptions.key("session.key") + .stringType() + .defaultValue("default_session_key") + .withDescription("The session key for this consumer group at startup."); + + public static final ConfigOption<List<String>> TID = Review Comment: streamId -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
