Search in sources :

Example 1 with GraphBackedSearchIndexer

use of org.apache.atlas.repository.graph.GraphBackedSearchIndexer in project atlas by apache.

the class AtlasRelationshipStoreV1Test method setUp.

@BeforeClass
public void setUp() throws Exception {
    new GraphBackedSearchIndexer(typeRegistry);
    // create employee relationship types
    AtlasTypesDef employeeTypes = getDepartmentEmployeeTypes();
    typeDefStore.createTypesDef(employeeTypes);
    AtlasEntitiesWithExtInfo employeeInstances = getDepartmentEmployeeInstances();
    EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(employeeInstances), false);
    for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) {
        employeeNameIdMap.put((String) entityHeader.getAttribute(NAME), getAtlasObjectId(entityHeader));
    }
    init();
    AtlasTypesDef typesDef = getInverseReferenceTestTypes();
    AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry);
    if (!typesToCreate.isEmpty()) {
        typeDefStore.createTypesDef(typesToCreate);
    }
}
Also used : GraphBackedSearchIndexer(org.apache.atlas.repository.graph.GraphBackedSearchIndexer) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) BeforeClass(org.testng.annotations.BeforeClass)

Example 2 with GraphBackedSearchIndexer

use of org.apache.atlas.repository.graph.GraphBackedSearchIndexer in project incubator-atlas by apache.

the class AtlasRelationshipStoreV1Test method setUp.

@BeforeClass
public void setUp() throws Exception {
    new GraphBackedSearchIndexer(typeRegistry);
    // create employee relationship types
    AtlasTypesDef employeeTypes = getDepartmentEmployeeTypes();
    typeDefStore.createTypesDef(employeeTypes);
    AtlasEntitiesWithExtInfo employeeInstances = getDepartmentEmployeeInstances();
    EntityMutationResponse response = entityStore.createOrUpdate(new AtlasEntityStream(employeeInstances), false);
    for (AtlasEntityHeader entityHeader : response.getCreatedEntities()) {
        employeeNameIdMap.put((String) entityHeader.getAttribute(NAME), getAtlasObjectId(entityHeader));
    }
    init();
    AtlasTypesDef testTypes = getInverseReferenceTestTypes();
    typeDefStore.createTypesDef(testTypes);
}
Also used : GraphBackedSearchIndexer(org.apache.atlas.repository.graph.GraphBackedSearchIndexer) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) EntityMutationResponse(org.apache.atlas.model.instance.EntityMutationResponse) AtlasEntityHeader(org.apache.atlas.model.instance.AtlasEntityHeader) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) BeforeClass(org.testng.annotations.BeforeClass)

Example 3 with GraphBackedSearchIndexer

use of org.apache.atlas.repository.graph.GraphBackedSearchIndexer 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)

Example 4 with GraphBackedSearchIndexer

use of org.apache.atlas.repository.graph.GraphBackedSearchIndexer 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 GraphBackedSearchIndexer

use of org.apache.atlas.repository.graph.GraphBackedSearchIndexer in project atlas by apache.

the class AtlasEntityStoreV1Test method setUp.

@BeforeClass
public void setUp() throws Exception {
    RequestContextV1.clear();
    RequestContextV1.get().setUser(TestUtilsV2.TEST_USER, null);
    new GraphBackedSearchIndexer(typeRegistry);
    AtlasTypesDef[] testTypesDefs = new AtlasTypesDef[] { TestUtilsV2.defineDeptEmployeeTypes(), TestUtilsV2.defineHiveTypes(), TestUtilsV2.defineTypeWithNestedCollectionAttributes() };
    for (AtlasTypesDef typesDef : testTypesDefs) {
        AtlasTypesDef typesToCreate = AtlasTypeDefStoreInitializer.getTypesToCreate(typesDef, typeRegistry);
        if (!typesToCreate.isEmpty()) {
            typeDefStore.createTypesDef(typesToCreate);
        }
    }
    deptEntity = TestUtilsV2.createDeptEg2();
    dbEntity = TestUtilsV2.createDBEntityV2();
    tblEntity = TestUtilsV2.createTableEntityV2(dbEntity.getEntity());
    nestedCollectionAttrEntity = TestUtilsV2.createNestedCollectionAttrEntity();
    AtlasTypesDef typesDef11 = new AtlasTypesDef();
    List primitiveEntityDef = new ArrayList<AtlasEntityDef>();
    primitiveEntityDef.add(TestUtilsV2.createPrimitiveEntityDef());
    typesDef11.setEntityDefs(primitiveEntityDef);
    typeDefStore.createTypesDef(typesDef11);
    primitiveEntity = TestUtilsV2.createprimitiveEntityV2();
}
Also used : GraphBackedSearchIndexer(org.apache.atlas.repository.graph.GraphBackedSearchIndexer) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) AtlasTypesDef(org.apache.atlas.model.typedef.AtlasTypesDef) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

GraphBackedSearchIndexer (org.apache.atlas.repository.graph.GraphBackedSearchIndexer)7 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)4 BeforeClass (org.testng.annotations.BeforeClass)4 AtlasTypeRegistry (org.apache.atlas.type.AtlasTypeRegistry)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)2 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)2 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)2 AtlasException (org.apache.atlas.AtlasException)1 EntityChangeListener (org.apache.atlas.listener.EntityChangeListener)1 TypesChangeListener (org.apache.atlas.listener.TypesChangeListener)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 DefaultMetadataService (org.apache.atlas.services.DefaultMetadataService)1 IDataType (org.apache.atlas.typesystem.types.IDataType)1 DefaultTypeCache (org.apache.atlas.typesystem.types.cache.DefaultTypeCache)1 TypeCache (org.apache.atlas.typesystem.types.cache.TypeCache)1 AtlasRepositoryConfiguration (org.apache.atlas.util.AtlasRepositoryConfiguration)1