Search in sources :

Example 56 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class Titan0GraphDatabase method getGraphInstance.

public static TitanGraph getGraphInstance() {
    if (graphInstance == null) {
        synchronized (Titan0GraphDatabase.class) {
            if (graphInstance == null) {
                Configuration config;
                try {
                    config = getConfiguration();
                } catch (AtlasException e) {
                    throw new RuntimeException(e);
                }
                graphInstance = TitanFactory.open(config);
                atlasGraphInstance = new Titan0Graph();
                validateIndexBackend(config);
            }
        }
    }
    return graphInstance;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) AtlasException(org.apache.atlas.AtlasException)

Example 57 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class NotificationProvider method get.

public static KafkaNotification get() {
    if (kafka == null) {
        try {
            Configuration applicationProperties = ApplicationProperties.get();
            kafka = new KafkaNotification(applicationProperties);
        } catch (AtlasException e) {
            throw new RuntimeException(e);
        }
    }
    return kafka;
}
Also used : Configuration(org.apache.commons.configuration.Configuration) AtlasException(org.apache.atlas.AtlasException)

Example 58 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class ClassStore method createInstance.

/*
     * - assumes id is already validated
     */
ReferenceableInstance createInstance(MemRepository repo, Id id) throws RepositoryException {
    Integer pos = idPosMap.get(id);
    String typeName = typeNameList.get(pos);
    if (!Objects.equals(typeName, hierarchicalType.getName())) {
        return repo.getClassStore(typeName).createInstance(repo, id);
    }
    ImmutableList<String> traitNames = traitNamesStore.get(pos);
    String[] tNs = traitNames.toArray(new String[] {});
    try {
        return (ReferenceableInstance) classType.createInstance(id, tNs);
    } catch (AtlasException me) {
        throw new RepositoryException(me);
    }
}
Also used : RepositoryException(org.apache.atlas.repository.RepositoryException) ReferenceableInstance(org.apache.atlas.typesystem.persistence.ReferenceableInstance) AtlasException(org.apache.atlas.AtlasException)

Example 59 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class TypedInstanceToGraphMapper method walkClassInstances.

private Collection<IReferenceableInstance> walkClassInstances(ITypedReferenceableInstance typedInstance) throws RepositoryException {
    EntityProcessor entityProcessor = new EntityProcessor();
    try {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Walking the object graph for instance {}", typedInstance.toShortString());
        }
        new ObjectGraphWalker(typeSystem, entityProcessor, typedInstance).walk();
    } catch (AtlasException me) {
        throw new RepositoryException("TypeSystem error when walking the ObjectGraph", me);
    }
    entityProcessor.addInstanceIfNotExists(typedInstance);
    return entityProcessor.getInstances();
}
Also used : RepositoryException(org.apache.atlas.repository.RepositoryException) AtlasException(org.apache.atlas.AtlasException)

Example 60 with AtlasException

use of org.apache.atlas.AtlasException in project incubator-atlas by apache.

the class DefaultMetadataServiceTest method testOnChangeRefresh.

@Test
public void testOnChangeRefresh() {
    try {
        List<String> beforeChangeTypeNames = new ArrayList<>();
        beforeChangeTypeNames.addAll(metadataService.getTypeNames(new HashMap<TypeCache.TYPE_FILTER, String>()));
        typeDefChangeListener.onChange(new ChangedTypeDefs());
        List<String> afterChangeTypeNames = new ArrayList<>();
        afterChangeTypeNames.addAll(metadataService.getTypeNames(new HashMap<TypeCache.TYPE_FILTER, String>()));
        Collections.sort(beforeChangeTypeNames);
        Collections.sort(afterChangeTypeNames);
        assertEquals(afterChangeTypeNames, beforeChangeTypeNames);
    } catch (AtlasBaseException e) {
        fail("Should've succeeded", e);
    } catch (AtlasException e) {
        fail("getTypeNames should've succeeded", e);
    }
}
Also used : ChangedTypeDefs(org.apache.atlas.listener.ChangedTypeDefs) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TypeCache(org.apache.atlas.typesystem.types.cache.TypeCache) AtlasException(org.apache.atlas.AtlasException) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Aggregations

AtlasException (org.apache.atlas.AtlasException)101 AttributeInfo (org.apache.atlas.typesystem.types.AttributeInfo)26 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)19 IOException (java.io.IOException)13 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)13 RepositoryException (org.apache.atlas.repository.RepositoryException)12 JSONObject (org.codehaus.jettison.json.JSONObject)12 CreateUpdateEntitiesResult (org.apache.atlas.CreateUpdateEntitiesResult)9 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)9 Configuration (org.apache.commons.configuration.Configuration)9 ArrayList (java.util.ArrayList)7 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)7 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)6 Id (org.apache.atlas.typesystem.persistence.Id)6 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)6 HashMap (java.util.HashMap)5 GraphTransaction (org.apache.atlas.annotation.GraphTransaction)5 CatalogRuntimeException (org.apache.atlas.catalog.exception.CatalogRuntimeException)5 Referenceable (org.apache.atlas.typesystem.Referenceable)5 EntityExistsException (org.apache.atlas.typesystem.exception.EntityExistsException)5