yunqingmoswu commented on code in PR #6618: URL: https://github.com/apache/inlong/pull/6618#discussion_r1032168449
########## inlong-sort/sort-connectors/base/src/main/java/org/apache/inlong/sort/base/dirty/DirtyOptions.java: ########## @@ -0,0 +1,105 @@ +/* + * 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.base.dirty; + +import org.apache.flink.configuration.ReadableConfig; +import org.apache.flink.table.api.ValidationException; + +import java.io.Serializable; +import static org.apache.inlong.sort.base.Constants.DIRTY_IGNORE; +import static org.apache.inlong.sort.base.Constants.DIRTY_SINK_ENABLE; +import static org.apache.inlong.sort.base.Constants.SINK_DIRTY_CONNECTOR; +import static org.apache.inlong.sort.base.Constants.SINK_DIRTY_IGNORE_SINK_ERRORS; +import static org.apache.inlong.sort.base.Constants.SINK_DIRTY_LABELS; +import static org.apache.inlong.sort.base.Constants.SINK_DIRTY_LOG_TAG; + +/** + * Dirty common options + */ +public class DirtyOptions implements Serializable { + + private static final long serialVersionUID = 1L; + + private final boolean ignoreDirty; + private final boolean enableDirtySink; + private final boolean ignoreSinkErrors; + private final String dirtyConnector; + private final String labels; + private final String logTag; + + private DirtyOptions(boolean ignoreDirty, boolean enableDirtySink, boolean ignoreSinkErrors, + String dirtyConnector, String labels, String logTag) { + this.ignoreDirty = ignoreDirty; + this.enableDirtySink = enableDirtySink; + this.ignoreSinkErrors = ignoreSinkErrors; + this.dirtyConnector = dirtyConnector; + this.labels = labels; + this.logTag = logTag; + } + + /** + * Get dirty options from {@link ReadableConfig} + * + * @param config The config + * @return Dirty options + */ + public static DirtyOptions fromConfig(ReadableConfig config) { + boolean ignoreDirty = config.get(DIRTY_IGNORE); + boolean enableDirtySink = config.get(DIRTY_SINK_ENABLE); + boolean ignoreSinkError = config.get(SINK_DIRTY_IGNORE_SINK_ERRORS); + String dirtyConnector = config.getOptional(SINK_DIRTY_CONNECTOR).orElse(null); + String labels = config.getOptional(SINK_DIRTY_LABELS).orElse(null); + String logTag = config.get(SINK_DIRTY_LOG_TAG); Review Comment: A log tag must be required here, and there is a default if the user does not set 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
