diff --git a/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/DefaultTableUUIDProvider.java b/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/DefaultTableUUIDProvider.java new file mode 100644 index 000000000..1598ef6c2 --- /dev/null +++ b/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/DefaultTableUUIDProvider.java @@ -0,0 +1,17 @@ +package com.netflix.metacat.common.server.usermetadata; + +import com.netflix.metacat.common.dto.TableDto; + +import java.util.Optional; + +/** + * Default Table UUID Provider. + * + * @author yingjianw + */ +public class DefaultTableUUIDProvider implements TableUUIDProvider { + @Override + public Optional getUUID(final TableDto tableDto) { + return Optional.empty(); + } +} diff --git a/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/TableUUIDProvider.java b/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/TableUUIDProvider.java new file mode 100644 index 000000000..d7c9de63e --- /dev/null +++ b/metacat-common-server/src/main/java/com/netflix/metacat/common/server/usermetadata/TableUUIDProvider.java @@ -0,0 +1,18 @@ +package com.netflix.metacat.common.server.usermetadata; + +import com.netflix.metacat.common.dto.TableDto; + +import java.util.Optional; + +/** + * Interface for TableUUIDPorvider. + * @author yingjianw + */ +public interface TableUUIDProvider { + /** + * Given a tableDto, get the corresponding table uuid if applicable. + * @param tableDto dto for table + * @return the uuid of the table + **/ + Optional getUUID(TableDto tableDto); +} diff --git a/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/ParentChildRelMetadataServiceSpec.groovy b/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/ParentChildRelMetadataServiceSpec.groovy index 4dce3c9e9..e3e1f9987 100644 --- a/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/ParentChildRelMetadataServiceSpec.groovy +++ b/metacat-functional-tests/src/functionalTest/groovy/com/netflix/metacat/ParentChildRelMetadataServiceSpec.groovy @@ -7,9 +7,6 @@ import com.netflix.metacat.common.server.usermetadata.ParentChildRelMetadataServ import com.netflix.metacat.metadata.mysql.MySqlParentChildRelMetaDataService import org.springframework.jdbc.core.JdbcTemplate import org.springframework.jdbc.datasource.DriverManagerDataSource -import org.springframework.retry.backoff.NoBackOffPolicy -import org.springframework.retry.policy.SimpleRetryPolicy -import org.springframework.retry.support.RetryTemplate import spock.lang.Shared import spock.lang.Specification @@ -18,8 +15,6 @@ class ParentChildRelMetadataServiceSpec extends Specification{ private ParentChildRelMetadataService service; @Shared private JdbcTemplate jdbcTemplate; - @Shared - private RetryTemplate retryTemplate; @Shared private String catalog = "prodhive" @@ -37,17 +32,8 @@ class ParentChildRelMetadataServiceSpec extends Specification{ dataSource.setUsername(username) dataSource.setPassword(password) - retryTemplate = new RetryTemplate() - - // Configure no backoff policy - retryTemplate.setBackOffPolicy(new NoBackOffPolicy()) - - // Configure retry policy with no retries - SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(1) // 1 attempt means no retries - retryTemplate.setRetryPolicy(retryPolicy) - jdbcTemplate = new JdbcTemplate(dataSource) - service = new MySqlParentChildRelMetaDataService(jdbcTemplate, retryTemplate) + service = new MySqlParentChildRelMetaDataService(jdbcTemplate) } def cleanup() { diff --git a/metacat-main/src/main/java/com/netflix/metacat/main/configs/ServicesConfig.java b/metacat-main/src/main/java/com/netflix/metacat/main/configs/ServicesConfig.java index 90f88e89c..8e491dd8d 100644 --- a/metacat-main/src/main/java/com/netflix/metacat/main/configs/ServicesConfig.java +++ b/metacat-main/src/main/java/com/netflix/metacat/main/configs/ServicesConfig.java @@ -35,8 +35,9 @@ import com.netflix.metacat.common.server.usermetadata.LookupService; import com.netflix.metacat.common.server.usermetadata.TagService; import com.netflix.metacat.common.server.usermetadata.UserMetadataService; -import com.netflix.metacat.common.server.util.ThreadServiceManager; import com.netflix.metacat.common.server.usermetadata.ParentChildRelMetadataService; +import com.netflix.metacat.common.server.usermetadata.TableUUIDProvider; +import com.netflix.metacat.common.server.util.ThreadServiceManager; import com.netflix.metacat.main.manager.CatalogManager; import com.netflix.metacat.main.manager.ConnectorManager; import com.netflix.metacat.main.manager.PluginManager; @@ -230,6 +231,7 @@ public DatabaseService databaseService( * @param authorizationService authorization Service * @param ownerValidationService owner validation service * @param parentChildRelMetadataService parentChildRelMetadataService + * @param tableUUIDProvider provider that provides the uuid for a table * * @return The table service bean */ @@ -247,7 +249,8 @@ public TableService tableService( final ConverterUtil converterUtil, final AuthorizationService authorizationService, final OwnerValidationService ownerValidationService, - final ParentChildRelMetadataService parentChildRelMetadataService) { + final ParentChildRelMetadataService parentChildRelMetadataService, + final TableUUIDProvider tableUUIDProvider) { return new TableServiceImpl( connectorManager, connectorTableServiceProxy, @@ -261,7 +264,8 @@ public TableService tableService( converterUtil, authorizationService, ownerValidationService, - parentChildRelMetadataService + parentChildRelMetadataService, + tableUUIDProvider ); } diff --git a/metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java b/metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java index af00f70bb..c25643b27 100644 --- a/metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java +++ b/metacat-main/src/main/java/com/netflix/metacat/main/services/impl/TableServiceImpl.java @@ -44,17 +44,18 @@ import com.netflix.metacat.common.server.events.MetacatUpdateIcebergTablePostEvent; import com.netflix.metacat.common.server.events.MetacatUpdateTablePostEvent; import com.netflix.metacat.common.server.events.MetacatUpdateTablePreEvent; -import com.netflix.metacat.common.server.monitoring.Metrics; import com.netflix.metacat.common.server.model.ChildInfo; import com.netflix.metacat.common.server.model.ParentInfo; +import com.netflix.metacat.common.server.monitoring.Metrics; import com.netflix.metacat.common.server.properties.Config; import com.netflix.metacat.common.server.spi.MetacatCatalogConfig; import com.netflix.metacat.common.server.usermetadata.AuthorizationService; -import com.netflix.metacat.common.server.usermetadata.ParentChildRelMetadataService; import com.netflix.metacat.common.server.usermetadata.GetMetadataInterceptorParameters; import com.netflix.metacat.common.server.usermetadata.MetacatOperation; import com.netflix.metacat.common.server.usermetadata.TagService; import com.netflix.metacat.common.server.usermetadata.UserMetadataService; +import com.netflix.metacat.common.server.usermetadata.ParentChildRelMetadataService; +import com.netflix.metacat.common.server.usermetadata.TableUUIDProvider; import com.netflix.metacat.common.server.util.MetacatContextManager; import com.netflix.metacat.common.server.util.MetacatUtils; import com.netflix.metacat.main.manager.ConnectorManager; @@ -95,6 +96,7 @@ public class TableServiceImpl implements TableService { private final AuthorizationService authorizationService; private final OwnerValidationService ownerValidationService; private final ParentChildRelMetadataService parentChildRelMetadataService; + private final TableUUIDProvider tableUUIDProvider; /** * {@inheritDoc} @@ -323,14 +325,6 @@ private void tag(final QualifiedName name, final ObjectNode definitionMetadata) } } - private Optional getUUID(final TableDto tableDto) { - final Map m = tableDto.getMetadata(); - if (m != null && m.containsKey("uuid")) { - return Optional.of(m.get("uuid")); - } - return Optional.empty(); - } - /** * {@inheritDoc} */ @@ -371,7 +365,7 @@ public TableDto deleteAndReturn(final QualifiedName name, final boolean isMView) } } - final Optional uuid = getUUID(tableDto); + final Optional uuid = tableUUIDProvider.getUUID(tableDto); final Set childInfos = parentChildRelMetadataService.getChildren(name, uuid); if (childInfos != null && !childInfos.isEmpty()) { throw new RuntimeException("Fail to drop " + name + " because it still has child table"); @@ -491,7 +485,7 @@ public Optional get(final QualifiedName name, final GetTableServicePar : userMetadataService.getDefinitionMetadataWithInterceptor(name, GetMetadataInterceptorParameters.builder().hasMetadata(tableInternal).build()); // Always get the source of truth for parent child relation from the parentChildRelMetadataService - final Optional uuid = getUUID(table); + final Optional uuid = tableUUIDProvider.getUUID(table); final Set parentInfo = parentChildRelMetadataService.getParents(name, uuid); final Set childInfos = parentChildRelMetadataService.getChildren(name, uuid); final ObjectNode parentChildRelObjectNode = createParentChildObjectNode(parentInfo, childInfos); @@ -565,7 +559,7 @@ public void rename( eventBus.post(new MetacatRenameTablePreEvent(oldName, metacatRequestContext, this, newName)); // Before rename, first rename its parent child relation - final Optional uuid = getUUID(oldTable); + final Optional uuid = tableUUIDProvider.getUUID(oldTable); parentChildRelMetadataService.rename(oldName, newName, uuid); try { diff --git a/metacat-main/src/test/groovy/com/netflix/metacat/main/services/impl/TableServiceImplSpec.groovy b/metacat-main/src/test/groovy/com/netflix/metacat/main/services/impl/TableServiceImplSpec.groovy index 023d256f7..2ea62d774 100644 --- a/metacat-main/src/test/groovy/com/netflix/metacat/main/services/impl/TableServiceImplSpec.groovy +++ b/metacat-main/src/test/groovy/com/netflix/metacat/main/services/impl/TableServiceImplSpec.groovy @@ -40,6 +40,7 @@ import com.netflix.metacat.common.server.model.ParentInfo import com.netflix.metacat.common.server.properties.Config import com.netflix.metacat.common.server.spi.MetacatCatalogConfig import com.netflix.metacat.common.server.usermetadata.DefaultAuthorizationService +import com.netflix.metacat.common.server.usermetadata.TableUUIDProvider import com.netflix.metacat.common.server.usermetadata.TagService import com.netflix.metacat.common.server.usermetadata.UserMetadataService import com.netflix.metacat.common.server.util.MetacatContextManager @@ -84,6 +85,7 @@ class TableServiceImplSpec extends Specification { def authorizationService def ownerValidationService def parentChildRelSvc + def tableUUIDProvider def service def setup() { @@ -101,10 +103,12 @@ class TableServiceImplSpec extends Specification { authorizationService = new DefaultAuthorizationService(config) ownerValidationService = Mock(OwnerValidationService) parentChildRelSvc = Mock(ParentChildRelMetadataService) + tableUUIDProvider = Mock(TableUUIDProvider) service = new TableServiceImpl(connectorManager, connectorTableServiceProxy, databaseService, tagService, usermetadataService, new MetacatJsonLocator(), - eventBus, registry, config, converterUtil, authorizationService, ownerValidationService, parentChildRelSvc) + eventBus, registry, config, converterUtil, authorizationService, ownerValidationService, parentChildRelSvc, + tableUUIDProvider) } def testTableGet() { @@ -316,13 +320,20 @@ class TableServiceImplSpec extends Specification { def "Test Drop - Clone Table Fail to drop parent child relation"() { given: def name = QualifiedName.ofTable("clone", "clone", "child") -// parentChildRelSvc.getParents(_,_) >> [new ParentInfo("parent", "clone", "parent_uuid")] as Set -// parentChildRelSvc.getChildren(_,_) >> [new ChildInfo("child", "clone", "child_uuid")] as Set when: service.delete(name) + then: + 1 * parentChildRelSvc.getParents(_, _) >> {[new ParentInfo("parent", "clone", "parent_uuid")] as Set} + 2 * parentChildRelSvc.getChildren(_, _) >> {[new ChildInfo("child", "clone", "child_uuid")] as Set} + 1 * config.getNoTableDeleteOnTags() >> [] + thrown(RuntimeException) + when: + service.delete(name) then: + 1 * parentChildRelSvc.getParents(_, _) + 2 * parentChildRelSvc.getChildren(_, _) 1 * config.getNoTableDeleteOnTags() >> [] 1 * connectorTableServiceProxy.delete(_) >> {throw new RuntimeException("Fail to drop")} 0 * parentChildRelSvc.drop(_, _) @@ -370,7 +381,7 @@ class TableServiceImplSpec extends Specification { connectorManager, connectorTableServiceProxy, databaseService, tagService, usermetadataService, new MetacatJsonLocator(), eventBus, new DefaultRegistry(), config, converterUtil, authorizationService, - new DefaultOwnerValidationService(new NoopRegistry()), parentChildRelSvc) + new DefaultOwnerValidationService(new NoopRegistry()), parentChildRelSvc, tableUUIDProvider) def initialDefinitionMetadataJson = toObjectNode(initialDefinitionMetadata) tableDto = new TableDto( diff --git a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlParentChildRelMetaDataService.java b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlParentChildRelMetaDataService.java index e94f664f3..89f029413 100644 --- a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlParentChildRelMetaDataService.java +++ b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlParentChildRelMetaDataService.java @@ -8,8 +8,6 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.retry.RetryCallback; -import org.springframework.retry.support.RetryTemplate; import org.springframework.transaction.annotation.Transactional; import java.sql.PreparedStatement; @@ -41,7 +39,7 @@ public class MySqlParentChildRelMetaDataService implements ParentChildRelMetadat + "SET child = ? WHERE child = ?"; static final String SQL_DROP_CHILD = "DELETE FROM parent_child_relation " - + "WHERE child = ? "; + + "WHERE child = ? "; static final String SQL_DROP_PARENT = "DELETE FROM parent_child_relation " + "WHERE parent = ? "; @@ -52,21 +50,15 @@ public class MySqlParentChildRelMetaDataService implements ParentChildRelMetadat + "FROM parent_child_relation WHERE parent = ?"; private JdbcTemplate jdbcTemplate; - private RetryTemplate retryTemplate; /** * Constructor. * * @param jdbcTemplate jdbc template - * @param retryTemplate retry template */ @Autowired - public MySqlParentChildRelMetaDataService( - final JdbcTemplate jdbcTemplate, - final RetryTemplate retryTemplate - ) { + public MySqlParentChildRelMetaDataService(final JdbcTemplate jdbcTemplate) { this.jdbcTemplate = jdbcTemplate; - this.retryTemplate = retryTemplate; } @Override @@ -98,16 +90,14 @@ public void createParentChildRelation(final QualifiedName parentName, + "- child table: " + childName + " already have child"); } - retryTemplate.execute((RetryCallback) context -> { - return jdbcTemplate.update(connection -> { - final PreparedStatement ps = connection.prepareStatement(SQL_CREATE_PARENT_CHILD_RELATIONS); - ps.setString(1, parentName.toString()); - ps.setString(2, parentUUID); - ps.setString(3, childName.toString()); - ps.setString(4, childUUID); - ps.setString(5, type); - return ps; - }); + jdbcTemplate.update(connection -> { + final PreparedStatement ps = connection.prepareStatement(SQL_CREATE_PARENT_CHILD_RELATIONS); + ps.setString(1, parentName.toString()); + ps.setString(2, parentUUID); + ps.setString(3, childName.toString()); + ps.setString(4, childUUID); + ps.setString(5, type); + return ps; }); } @@ -117,20 +107,17 @@ public void deleteParentChildRelation(final QualifiedName parentName, final QualifiedName childName, final String childUUID, final String type) { - retryTemplate.execute((RetryCallback) context -> { - return jdbcTemplate.update(connection -> { - final PreparedStatement ps = connection.prepareStatement(SQL_DELETE_PARENT_CHILD_RELATIONS); - ps.setString(1, parentName.toString()); - ps.setString(2, parentUUID); - ps.setString(3, childName.toString()); - ps.setString(4, childUUID); - ps.setString(5, type); - return ps; - }); + jdbcTemplate.update(connection -> { + final PreparedStatement ps = connection.prepareStatement(SQL_DELETE_PARENT_CHILD_RELATIONS); + ps.setString(1, parentName.toString()); + ps.setString(2, parentUUID); + ps.setString(3, childName.toString()); + ps.setString(4, childUUID); + ps.setString(5, type); + return ps; }); } - @Override public void rename(final QualifiedName oldName, final QualifiedName newName, final Optional uuid) { try { @@ -145,32 +132,28 @@ public void rename(final QualifiedName oldName, final QualifiedName newName, fin private void renameParent(final QualifiedName oldName, final QualifiedName newName, final Optional uuid) { final String query = uuid.isPresent() ? SQL_RENAME_PARENT_ENTITY + " AND parent_uuid = ?" : SQL_RENAME_PARENT_ENTITY; - retryTemplate.execute((RetryCallback) context -> { - return jdbcTemplate.update(connection -> { - final PreparedStatement ps = connection.prepareStatement(query); - ps.setString(1, newName.toString()); - ps.setString(2, oldName.toString()); - if (uuid.isPresent()) { - ps.setString(3, uuid.get()); - } - return ps; - }); + jdbcTemplate.update(connection -> { + final PreparedStatement ps = connection.prepareStatement(query); + ps.setString(1, newName.toString()); + ps.setString(2, oldName.toString()); + if (uuid.isPresent()) { + ps.setString(3, uuid.get()); + } + return ps; }); } private void renameChild(final QualifiedName oldName, final QualifiedName newName, final Optional uuid) { final String query = uuid.isPresent() ? SQL_RENAME_CHILD_ENTITY + " AND child_uuid = ?" : SQL_RENAME_CHILD_ENTITY; - retryTemplate.execute((RetryCallback) context -> { - return jdbcTemplate.update(connection -> { - final PreparedStatement ps = connection.prepareStatement(query); - ps.setString(1, newName.toString()); - ps.setString(2, oldName.toString()); - if (uuid.isPresent()) { - ps.setString(3, uuid.get()); - } - return ps; - }); + jdbcTemplate.update(connection -> { + final PreparedStatement ps = connection.prepareStatement(query); + ps.setString(1, newName.toString()); + ps.setString(2, oldName.toString()); + if (uuid.isPresent()) { + ps.setString(3, uuid.get()); + } + return ps; }); } @@ -182,78 +165,63 @@ public void drop(final QualifiedName name, final Optional uuid) { private void dropParent(final QualifiedName name, final Optional uuid) { final String query = uuid.isPresent() ? SQL_DROP_PARENT + " AND parent_uuid = ?" : SQL_DROP_PARENT; - retryTemplate.execute((RetryCallback) context -> { - jdbcTemplate.update(connection -> { - final PreparedStatement ps = connection.prepareStatement(query); - ps.setString(1, name.toString()); - - if (uuid.isPresent()) { - ps.setString(2, uuid.get()); - } - return ps; - }); - return null; + jdbcTemplate.update(connection -> { + final PreparedStatement ps = connection.prepareStatement(query); + ps.setString(1, name.toString()); + if (uuid.isPresent()) { + ps.setString(2, uuid.get()); + } + return ps; }); } private void dropChild(final QualifiedName name, final Optional uuid) { final String query = uuid.isPresent() ? SQL_DROP_CHILD + " AND child_uuid = ?" : SQL_DROP_CHILD; - retryTemplate.execute((RetryCallback) context -> { - jdbcTemplate.update(connection -> { - final PreparedStatement ps = connection.prepareStatement(query); - ps.setString(1, name.toString()); - - if (uuid.isPresent()) { - ps.setString(2, uuid.get()); - } - return ps; - }); - return null; + jdbcTemplate.update(connection -> { + final PreparedStatement ps = connection.prepareStatement(query); + ps.setString(1, name.toString()); + if (uuid.isPresent()) { + ps.setString(2, uuid.get()); + } + return ps; }); } @Override public Set getParents(final QualifiedName name, final Optional uuid) { final String query = uuid.isPresent() ? SQL_GET_PARENTS + " AND child_uuid = ?" : SQL_GET_PARENTS; - return retryTemplate.execute((RetryCallback, RuntimeException>) context -> { - final List params = new ArrayList<>(); - params.add(name.toString()); - if (uuid.isPresent()) { - params.add(uuid.get().toString()); - } - - final List parents = jdbcTemplate.query( - query, params.toArray(), (rs, rowNum) -> { - final ParentInfo parentInfo = new ParentInfo(); - parentInfo.setName(rs.getString("parent")); - parentInfo.setRelationType(rs.getString("relation_type")); - parentInfo.setUuid(rs.getString("parent_uuid")); - return parentInfo; - }); - return new HashSet<>(parents); - }); + final List params = new ArrayList<>(); + params.add(name.toString()); + if (uuid.isPresent()) { + params.add(uuid.get().toString()); + } + final List parents = jdbcTemplate.query( + query, params.toArray(), (rs, rowNum) -> { + final ParentInfo parentInfo = new ParentInfo(); + parentInfo.setName(rs.getString("parent")); + parentInfo.setRelationType(rs.getString("relation_type")); + parentInfo.setUuid(rs.getString("parent_uuid")); + return parentInfo; + }); + return new HashSet<>(parents); } @Override public Set getChildren(final QualifiedName name, final Optional uuid) { - return retryTemplate.execute((RetryCallback, RuntimeException>) context -> { - final List params = new ArrayList<>(); - params.add(name.toString()); - - final String query = uuid.isPresent() ? SQL_GET_CHILDREN + " AND parent_uuid = ?" : SQL_GET_CHILDREN; - if (uuid.isPresent()) { - params.add(uuid.get().toString()); - } - - final List children = jdbcTemplate.query( - query, params.toArray(), (rs, rowNum) -> { - final ChildInfo childInfo = new ChildInfo(); - childInfo.setName(rs.getString("child")); - childInfo.setRelationType(rs.getString("relation_type")); - childInfo.setUuid(rs.getString("child_uuid")); - return childInfo; - }); - return new HashSet<>(children); - }); + final List params = new ArrayList<>(); + params.add(name.toString()); + final String query = uuid.isPresent() ? SQL_GET_CHILDREN + " AND parent_uuid = ?" : SQL_GET_CHILDREN; + if (uuid.isPresent()) { + params.add(uuid.get().toString()); + } + final List children = jdbcTemplate.query( + query, params.toArray(), (rs, rowNum) -> { + final ChildInfo childInfo = new ChildInfo(); + childInfo.setName(rs.getString("child")); + childInfo.setRelationType(rs.getString("relation_type")); + childInfo.setUuid(rs.getString("child_uuid")); + return childInfo; + }); + return new HashSet<>(children); } } diff --git a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlUserMetadataConfig.java b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlUserMetadataConfig.java index b68d2d920..879a25376 100644 --- a/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlUserMetadataConfig.java +++ b/metacat-metadata-mysql/src/main/java/com/netflix/metacat/metadata/mysql/MySqlUserMetadataConfig.java @@ -16,12 +16,14 @@ import com.netflix.metacat.common.json.MetacatJson; import com.netflix.metacat.common.server.properties.Config; import com.netflix.metacat.common.server.properties.MetacatProperties; +import com.netflix.metacat.common.server.usermetadata.TableUUIDProvider; +import com.netflix.metacat.common.server.usermetadata.DefaultTableUUIDProvider; +import com.netflix.metacat.common.server.usermetadata.UserMetadataService; import com.netflix.metacat.common.server.usermetadata.LookupService; -import com.netflix.metacat.common.server.usermetadata.MetadataInterceptor; import com.netflix.metacat.common.server.usermetadata.TagService; import com.netflix.metacat.common.server.usermetadata.ParentChildRelMetadataService; +import com.netflix.metacat.common.server.usermetadata.MetadataInterceptor; import com.netflix.metacat.common.server.usermetadata.MetadataInterceptorImpl; -import com.netflix.metacat.common.server.usermetadata.UserMetadataService; import com.netflix.metacat.common.server.util.DataSourceManager; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -30,9 +32,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.retry.backoff.ExponentialBackOffPolicy; -import org.springframework.retry.policy.SimpleRetryPolicy; -import org.springframework.retry.support.RetryTemplate; import javax.sql.DataSource; @@ -45,7 +44,6 @@ @Configuration @ConditionalOnProperty(value = "metacat.mysqlmetadataservice.enabled", havingValue = "true") public class MySqlUserMetadataConfig { - /** * business Metadata Manager. * @return business Metadata Manager @@ -57,6 +55,18 @@ public MetadataInterceptor businessMetadataManager( return new MetadataInterceptorImpl(); } + /** + * The parentChildRelMetadataService to use. + * + * @return The TableUUIDProvider implementation + */ + @Bean + @ConditionalOnMissingBean(TableUUIDProvider.class) + public TableUUIDProvider tableUUIDProvider( + ) { + return new DefaultTableUUIDProvider(); + } + /** * User Metadata service. * @@ -112,42 +122,17 @@ public TagService tagService( return new MySqlTagService(config, jdbcTemplate, lookupService, metacatJson, userMetadataService); } - /** - * RetryTemplate for parentChildRelMetadataService. - * @return RetryTemplate for parentChildRelMetadataService - */ - @Bean - RetryTemplate parentChildRelMetadataServiceRetryTemplate() { - final RetryTemplate retryTemplate = new RetryTemplate(); - - // Configure exponential backoff policy - final ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy(); - backOffPolicy.setInitialInterval(500); // Initial interval in milliseconds - backOffPolicy.setMultiplier(2.0); // Multiplier for the backoff interval - backOffPolicy.setMaxInterval(5000); // Maximum backoff interval - - // Configure retry policy - final SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(); - retryPolicy.setMaxAttempts(3); // Maximum number of retry attempts - - retryTemplate.setRetryPolicy(retryPolicy); - retryTemplate.setBackOffPolicy(backOffPolicy); - return retryTemplate; - } - /** * The parentChildRelMetadataService to use. * * @param jdbcTemplate JDBC template - * @param retryTemplate RetryTemplate * @return The parentChildRelMetadataService implementation backed by MySQL */ @Bean ParentChildRelMetadataService parentChildRelMetadataService( - @Qualifier("metadataJdbcTemplate") final JdbcTemplate jdbcTemplate, - @Qualifier("parentChildRelMetadataServiceRetryTemplate") final RetryTemplate retryTemplate + @Qualifier("metadataJdbcTemplate") final JdbcTemplate jdbcTemplate ) { - return new MySqlParentChildRelMetaDataService(jdbcTemplate, retryTemplate); + return new MySqlParentChildRelMetaDataService(jdbcTemplate); } /**