NamsB7 commented on code in PR #4121: URL: https://github.com/apache/gobblin/pull/4121#discussion_r2225239449
########## gobblin-metastore/src/main/java/org/apache/gobblin/metastore/MysqlErrorPatternStore.java: ########## @@ -0,0 +1,364 @@ +package org.apache.gobblin.metastore; + +import org.apache.gobblin.broker.SharedResourcesBrokerFactory; +import org.apache.gobblin.configuration.ConfigurationKeys; +import org.apache.gobblin.configuration.ErrorPatternProfile; +import org.apache.gobblin.configuration.Category; + +import com.typesafe.config.Config; + +import org.apache.gobblin.util.ConfigUtils; + +import javax.sql.DataSource; + +import javax.inject.Inject; +import lombok.extern.slf4j.Slf4j; + +import java.io.IOException; +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; + + +/** + * MySQL-backed implementation of IssueStore. + * + * Expected table schemas: + * + * 1. error_summary_regex_store + * - description_regex: VARCHAR(255) NOT NULL UNIQUE + * - error_category_name: VARCHAR(255) NOT NULL + * + * 2. error_categories + * - error_category_name: VARCHAR(255) PRIMARY KEY + * - priority: INT UNIQUE NOT NULL + * - is_default: BOOLEAN (optional, not compulsory; used if present to indicate the default category) + * + * This class provides methods to primarily retrieve error regex patterns and error categories. + * There are also methods to add and delete, which should be used with caution, and retrieve error patterns and categories. + */ +@Slf4j +public class MysqlErrorPatternStore implements ErrorPatternStore { + private final DataSource dataSource; + private final String errorRegexSummaryStoreTable; + private final String errorCategoriesTable; + public static final String CONFIG_PREFIX = "MysqlErrorPatternStore"; + + private static final int DEFAULT_MAX_CHARACTERS_IN_SQL_DESCRIPTION_REGEX = 2000; + private static final int DEFAULT_MAX_CHARACTERS_IN_SQL_CATEGORY_NAME = 255; + private final int maxCharactersInSqlDescriptionRegex; + private final int maxCharactersInSqlCategoryName; + + private static final String CREATE_ERROR_REGEX_SUMMARY_STORE_TABLE_STATEMENT = + "CREATE TABLE IF NOT EXISTS %s (" + " description_regex VARCHAR(%d) NOT NULL UNIQUE, " Review Comment: Changed accorndingly. -- 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: dev-unsubscr...@gobblin.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org