mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-30 01:23:08 +00:00
Fix : Add typeRegistry steps when reindexing by ops (#19820)
* Fix : Add typeRegistry steps when reindexing by ops * change to log.error in catch (cherry picked from commit 63eb9c30742b50290eaed2555c0a918a40872da2)
This commit is contained in:
parent
f1207e37bb
commit
defaeff903
@ -14,15 +14,22 @@
|
||||
package org.openmetadata.service;
|
||||
|
||||
import static org.openmetadata.common.utils.CommonUtil.listOrEmpty;
|
||||
import static org.openmetadata.service.Entity.ADMIN_USER_NAME;
|
||||
import static org.openmetadata.service.resources.types.TypeResource.PROPERTIES_FIELD;
|
||||
|
||||
import com.networknt.schema.JsonSchema;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.openmetadata.schema.entity.Type;
|
||||
import org.openmetadata.schema.entity.type.Category;
|
||||
import org.openmetadata.schema.entity.type.CustomProperty;
|
||||
import org.openmetadata.service.exception.CatalogExceptionMessage;
|
||||
import org.openmetadata.service.exception.EntityNotFoundException;
|
||||
import org.openmetadata.service.jdbi3.TypeRepository;
|
||||
import org.openmetadata.service.util.EntityUtil;
|
||||
import org.openmetadata.service.util.FullyQualifiedName;
|
||||
import org.openmetadata.service.util.JsonUtils;
|
||||
|
||||
@ -49,6 +56,33 @@ public class TypeRegistry {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public final void initialize(TypeRepository repository) {
|
||||
// Load types defined in OpenMetadata schemas
|
||||
long now = System.currentTimeMillis();
|
||||
List<Type> types = JsonUtils.getTypes();
|
||||
types.forEach(
|
||||
type -> {
|
||||
type.withId(UUID.randomUUID()).withUpdatedBy(ADMIN_USER_NAME).withUpdatedAt(now);
|
||||
LOG.debug("Loading type {}", type.getName());
|
||||
try {
|
||||
EntityUtil.Fields fields = repository.getFields(PROPERTIES_FIELD);
|
||||
try {
|
||||
Type storedType = repository.getByName(null, type.getName(), fields);
|
||||
type.setId(storedType.getId());
|
||||
// If entity type already exists, then carry forward custom properties
|
||||
if (storedType.getCategory().equals(Category.Entity)) {
|
||||
type.setCustomProperties(storedType.getCustomProperties());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Creating entity that does not exist ", e);
|
||||
}
|
||||
repository.addToRegistry(type);
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error loading type {}", type.getName(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addType(Type type) {
|
||||
TYPES.put(type.getName(), type);
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ public class TypeResource extends EntityResource<Type, TypeRepository> {
|
||||
type.setCustomProperties(storedType.getCustomProperties());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Creating entity that does not exist ", e);
|
||||
LOG.error("Creating entity that does not exist ", e);
|
||||
}
|
||||
this.repository.createOrUpdate(null, type);
|
||||
this.repository.addToRegistry(type);
|
||||
|
||||
@ -63,6 +63,7 @@ import org.openmetadata.schema.type.Include;
|
||||
import org.openmetadata.sdk.PipelineServiceClientInterface;
|
||||
import org.openmetadata.service.Entity;
|
||||
import org.openmetadata.service.OpenMetadataApplicationConfig;
|
||||
import org.openmetadata.service.TypeRegistry;
|
||||
import org.openmetadata.service.apps.ApplicationHandler;
|
||||
import org.openmetadata.service.apps.scheduler.AppScheduler;
|
||||
import org.openmetadata.service.clients.pipeline.PipelineServiceClientFactory;
|
||||
@ -77,6 +78,7 @@ import org.openmetadata.service.jdbi3.IngestionPipelineRepository;
|
||||
import org.openmetadata.service.jdbi3.ListFilter;
|
||||
import org.openmetadata.service.jdbi3.MigrationDAO;
|
||||
import org.openmetadata.service.jdbi3.SystemRepository;
|
||||
import org.openmetadata.service.jdbi3.TypeRepository;
|
||||
import org.openmetadata.service.jdbi3.UserRepository;
|
||||
import org.openmetadata.service.jdbi3.locator.ConnectionType;
|
||||
import org.openmetadata.service.migration.api.MigrationWorkflow;
|
||||
@ -515,6 +517,8 @@ public class OpenMetadataOperations implements Callable<Integer> {
|
||||
ApplicationHandler.initialize(config);
|
||||
CollectionRegistry.getInstance().loadSeedData(jdbi, config, null, null, null, true);
|
||||
ApplicationHandler.initialize(config);
|
||||
TypeRepository typeRepository = (TypeRepository) Entity.getEntityRepository(Entity.TYPE);
|
||||
TypeRegistry.instance().initialize(typeRepository);
|
||||
AppScheduler.initialize(config, collectionDAO, searchRepository);
|
||||
String appName = "SearchIndexingApplication";
|
||||
Set<String> entities =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user