Search in sources :

Example 1 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class RestUtilsTest method convertV2toV1.

private List<HierarchicalTypeDefinition<ClassType>> convertV2toV1(List<AtlasEntityDef> toConvert) throws AtlasBaseException {
    AtlasTypeRegistry reg = createRegistry(toConvert);
    List<HierarchicalTypeDefinition<ClassType>> result = new ArrayList<>(toConvert.size());
    for (int i = 0; i < toConvert.size(); i++) {
        AtlasEntityDef entityDef = toConvert.get(i);
        AtlasEntityType entity = reg.getEntityTypeByName(entityDef.getName());
        HierarchicalTypeDefinition<ClassType> converted = TypeConverterUtil.toTypesDef(entity, reg).classTypesAsJavaList().get(0);
        result.add(converted);
    }
    return result;
}
Also used : HierarchicalTypeDefinition(org.apache.atlas.typesystem.types.HierarchicalTypeDefinition) AtlasEntityDef(org.apache.atlas.model.typedef.AtlasEntityDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) ArrayList(java.util.ArrayList) ClassType(org.apache.atlas.typesystem.types.ClassType) AtlasEntityType(org.apache.atlas.type.AtlasEntityType)

Example 2 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class GraphBackedMetadataRepositoryDeleteTestBase method setUp.

@BeforeClass
public void setUp() throws Exception {
    typeSystem = TypeSystem.getInstance();
    typeSystem.reset();
    new GraphBackedSearchIndexer(new AtlasTypeRegistry());
    final GraphBackedMetadataRepository delegate = new GraphBackedMetadataRepository(getDeleteHandler(typeSystem), atlasGraph);
    repositoryService = TestUtils.addTransactionWrapper(delegate);
    TestUtils.defineDeptEmployeeTypes(typeSystem);
    TestUtils.createHiveTypes(typeSystem);
    // Define type for map value.
    HierarchicalTypeDefinition<ClassType> mapValueDef = TypesUtil.createClassTypeDef("CompositeMapValue", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE));
    // Define type with map where the value is a composite class reference to MapValue.
    HierarchicalTypeDefinition<ClassType> mapOwnerDef = TypesUtil.createClassTypeDef("CompositeMapOwner", ImmutableSet.<String>of(), TypesUtil.createUniqueRequiredAttrDef(NAME, DataTypes.STRING_TYPE), new AttributeDefinition("map", DataTypes.mapTypeName(DataTypes.STRING_TYPE.getName(), "CompositeMapValue"), Multiplicity.OPTIONAL, true, null));
    TypesDef typesDef = TypesUtil.getTypesDef(ImmutableList.<EnumTypeDefinition>of(), ImmutableList.<StructTypeDefinition>of(), ImmutableList.<HierarchicalTypeDefinition<TraitType>>of(), ImmutableList.of(mapOwnerDef, mapValueDef));
    typeSystem.defineTypes(typesDef);
    compositeMapOwnerType = typeSystem.getDataType(ClassType.class, "CompositeMapOwner");
    compositeMapValueType = typeSystem.getDataType(ClassType.class, "CompositeMapValue");
}
Also used : TypesDef(org.apache.atlas.typesystem.TypesDef) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class GraphBackedMetadataRepositoryTest method setUp.

@BeforeClass
public void setUp() throws Exception {
    typeSystem = TypeSystem.getInstance();
    typeSystem.reset();
    assertTrue(repositoryService instanceof GraphBackedMetadataRepository);
    repositoryService = TestUtils.addTransactionWrapper(repositoryService);
    new GraphBackedSearchIndexer(new AtlasTypeRegistry());
    TestUtils.defineDeptEmployeeTypes(typeSystem);
    TestUtils.createHiveTypes(typeSystem);
}
Also used : AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class GraphBackedDiscoveryServiceTest method addIndexesForNewTypes.

private void addIndexesForNewTypes(Collection<String> oldTypeNames, final TypeSystem typeSystem) throws AtlasException {
    Set<String> newTypeNames = new HashSet<>();
    newTypeNames.addAll(typeSystem.getTypeNames());
    newTypeNames.removeAll(oldTypeNames);
    Collection<IDataType> newTypes = new ArrayList<>();
    for (String name : newTypeNames) {
        try {
            newTypes.add(typeSystem.getDataType(IDataType.class, name));
        } catch (AtlasException e) {
            e.printStackTrace();
        }
    }
    //We need to commit the transaction before creating the indices to release the locks held by the transaction.
    //otherwise, the index commit will fail while waiting for the those locks to be released.
    AtlasGraphProvider.getGraphInstance().commit();
    GraphBackedSearchIndexer idx = new GraphBackedSearchIndexer(new AtlasTypeRegistry());
    idx.onAdd(newTypes);
}
Also used : GraphBackedSearchIndexer(org.apache.atlas.repository.graph.GraphBackedSearchIndexer) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) IDataType(org.apache.atlas.typesystem.types.IDataType) AtlasException(org.apache.atlas.AtlasException)

Example 5 with AtlasTypeRegistry

use of org.apache.atlas.type.AtlasTypeRegistry in project incubator-atlas by apache.

the class TestUtils method setupGraphProvider.

/**
     * Triggers the Atlas initialization process using the specified MetadataRepository.
     * This causes the built-in types and their indices to be created.
     */
public static void setupGraphProvider(MetadataRepository repo) throws AtlasException {
    TypeCache typeCache = null;
    try {
        typeCache = AtlasRepositoryConfiguration.getTypeCache().newInstance();
    } catch (Throwable t) {
        typeCache = new DefaultTypeCache();
    }
    final GraphBackedSearchIndexer indexer = new GraphBackedSearchIndexer(new AtlasTypeRegistry());
    Configuration config = ApplicationProperties.get();
    ITypeStore typeStore = new GraphBackedTypeStore(AtlasGraphProvider.getGraphInstance());
    DefaultMetadataService defaultMetadataService = new DefaultMetadataService(repo, typeStore, new HashSet<TypesChangeListener>() {

        {
            add(indexer);
        }
    }, new HashSet<EntityChangeListener>(), TypeSystem.getInstance(), config, typeCache, // Fixme: Can we work with Noop
    new InMemoryEntityAuditRepository());
    //commit the created types
    getGraph().commit();
}
Also used : EntityChangeListener(org.apache.atlas.listener.EntityChangeListener) AtlasRepositoryConfiguration(org.apache.atlas.util.AtlasRepositoryConfiguration) Configuration(org.apache.commons.configuration.Configuration) AtlasTypeRegistry(org.apache.atlas.type.AtlasTypeRegistry) InMemoryEntityAuditRepository(org.apache.atlas.repository.audit.InMemoryEntityAuditRepository) ITypeStore(org.apache.atlas.repository.typestore.ITypeStore) GraphBackedSearchIndexer(org.apache.atlas.repository.graph.GraphBackedSearchIndexer) TypesChangeListener(org.apache.atlas.listener.TypesChangeListener) GraphBackedTypeStore(org.apache.atlas.repository.typestore.GraphBackedTypeStore) DefaultMetadataService(org.apache.atlas.services.DefaultMetadataService) TypeCache(org.apache.atlas.typesystem.types.cache.TypeCache) DefaultTypeCache(org.apache.atlas.typesystem.types.cache.DefaultTypeCache) DefaultTypeCache(org.apache.atlas.typesystem.types.cache.DefaultTypeCache)

Aggregations

AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)15 AtlasEntityDef (org.apache.atlas.model.typedef.AtlasEntityDef)6 Test (org.testng.annotations.Test)6 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)4 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)3 GraphBackedSearchIndexer (org.apache.atlas.repository.graph.GraphBackedSearchIndexer)3 AtlasClassificationType (org.apache.atlas.type.AtlasClassificationType)3 HierarchicalTypeDefinition (org.apache.atlas.typesystem.types.HierarchicalTypeDefinition)3 TypesDef (org.apache.atlas.typesystem.TypesDef)2 ClassType (org.apache.atlas.typesystem.types.ClassType)2 BeforeClass (org.testng.annotations.BeforeClass)2 ArrayList (java.util.ArrayList)1 AtlasException (org.apache.atlas.AtlasException)1 EntityChangeListener (org.apache.atlas.listener.EntityChangeListener)1 TypesChangeListener (org.apache.atlas.listener.TypesChangeListener)1 AtlasAttributeDef (org.apache.atlas.model.typedef.AtlasStructDef.AtlasAttributeDef)1 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)1 InMemoryEntityAuditRepository (org.apache.atlas.repository.audit.InMemoryEntityAuditRepository)1 GraphBackedTypeStore (org.apache.atlas.repository.typestore.GraphBackedTypeStore)1 ITypeStore (org.apache.atlas.repository.typestore.ITypeStore)1