Search in sources :

Example 21 with AtlasException

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

the class InMemoryJAASConfiguration method init.

public static void init(org.apache.commons.configuration.Configuration atlasConfiguration) throws AtlasException {
    LOG.debug("==> InMemoryJAASConfiguration.init()");
    if (atlasConfiguration != null && !atlasConfiguration.isEmpty()) {
        Properties properties = ConfigurationConverter.getProperties(atlasConfiguration);
        init(properties);
    } else {
        throw new AtlasException("Failed to load JAAS application properties: configuration NULL or empty!");
    }
    LOG.debug("<== InMemoryJAASConfiguration.init()");
}
Also used : Properties(java.util.Properties) AtlasException(org.apache.atlas.AtlasException)

Example 22 with AtlasException

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

the class DefaultTypeSystem method createTraitInstance.

@Override
public void createTraitInstance(String guid, String typeName, Map<String, Object> properties) throws ResourceAlreadyExistsException {
    try {
        // not using the constructor with properties argument because it is marked 'InterfaceAudience.Private'
        Struct struct = new Struct(typeName);
        for (Map.Entry<String, Object> propEntry : properties.entrySet()) {
            struct.set(propEntry.getKey(), propEntry.getValue());
        }
        // add Taxonomy Namespace
        struct.set(TaxonomyResourceProvider.NAMESPACE_ATTRIBUTE_NAME, TaxonomyResourceProvider.TAXONOMY_NS);
        metadataService.addTrait(guid, metadataService.createTraitInstance(struct));
    } catch (IllegalArgumentException e) {
        // todo: unfortunately, IllegalArgumentException can be thrown for other reasons
        if (e.getMessage().contains("is already defined for entity")) {
            throw new ResourceAlreadyExistsException(String.format("Tag '%s' already associated with the entity", typeName));
        } else {
            throw e;
        }
    } catch (AtlasException e) {
        throw new CatalogRuntimeException(String.format("Unable to create trait instance '%s' in type system: %s", typeName, e), e);
    }
}
Also used : CatalogRuntimeException(org.apache.atlas.catalog.exception.CatalogRuntimeException) ResourceAlreadyExistsException(org.apache.atlas.catalog.exception.ResourceAlreadyExistsException) AtlasException(org.apache.atlas.AtlasException) Map(java.util.Map) Struct(org.apache.atlas.typesystem.Struct)

Example 23 with AtlasException

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

the class DefaultTypeSystem method deleteEntity.

@Override
public void deleteEntity(ResourceDefinition definition, Request request) throws ResourceNotFoundException {
    String typeName = definition.getTypeName();
    String cleanIdPropName = definition.getIdPropertyName();
    String idValue = request.getProperty(cleanIdPropName);
    try {
        // transaction handled by atlas repository
        metadataService.deleteEntityByUniqueAttribute(typeName, cleanIdPropName, idValue);
    } catch (EntityNotFoundException e) {
        throw new ResourceNotFoundException(String.format("The specified entity doesn't exist: type=%s, %s=%s", typeName, cleanIdPropName, idValue));
    } catch (AtlasException e) {
        throw new CatalogRuntimeException(String.format("An unexpected error occurred while attempting to delete entity: type=%s, %s=%s : %s", typeName, cleanIdPropName, idValue, e), e);
    }
}
Also used : CatalogRuntimeException(org.apache.atlas.catalog.exception.CatalogRuntimeException) EntityNotFoundException(org.apache.atlas.typesystem.exception.EntityNotFoundException) ResourceNotFoundException(org.apache.atlas.catalog.exception.ResourceNotFoundException) AtlasException(org.apache.atlas.AtlasException)

Example 24 with AtlasException

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

the class TaxonomyResourceProvider method createDefaultTaxonomyIfNeeded.

// must be called from within class monitor
private void createDefaultTaxonomyIfNeeded() {
    if (!autoInitializationChecked()) {
        try {
            LOG.info("Checking if default taxonomy needs to be created.");
            // see if any taxonomy exists.
            if (doGetResources(new CollectionRequest(null, null)).getPropertyMaps().isEmpty()) {
                LOG.info("No taxonomies found - going to create default taxonomy.");
                Map<String, Object> requestProperties = new HashMap<>();
                String defaultTaxonomyName = DEFAULT_TAXONOMY_NAME;
                try {
                    Configuration configuration = ApplicationProperties.get();
                    defaultTaxonomyName = configuration.getString("atlas.taxonomy.default.name", defaultTaxonomyName);
                } catch (AtlasException e) {
                    LOG.warn("Unable to read Atlas configuration, will use {} as default taxonomy name", defaultTaxonomyName, e);
                }
                requestProperties.put("name", defaultTaxonomyName);
                requestProperties.put("description", DEFAULT_TAXONOMY_DESCRIPTION);
                doCreateResource(new InstanceRequest(requestProperties));
                LOG.info("Successfully created default taxonomy {}.", defaultTaxonomyName);
            } else {
                taxonomyAutoInitializationChecked = true;
                LOG.info("Some taxonomy exists, not creating default taxonomy");
            }
        } catch (InvalidQueryException | ResourceNotFoundException e) {
            LOG.error("Unable to query for existing taxonomies due to internal error.", e);
        } catch (ResourceAlreadyExistsException e) {
            LOG.info("Attempted to create default taxonomy and it already exists.");
        }
    }
}
Also used : Configuration(org.apache.commons.configuration.Configuration) AtlasException(org.apache.atlas.AtlasException)

Example 25 with AtlasException

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

the class KafkaNotification method start.

// ----- Service ---------------------------------------------------------
@Override
public void start() throws AtlasException {
    if (isHAEnabled()) {
        LOG.info("Not starting embedded instances when HA is enabled.");
        return;
    }
    if (isEmbedded()) {
        try {
            startZk();
            startKafka();
        } catch (Exception e) {
            throw new AtlasException("Failed to start embedded kafka", e);
        }
    }
}
Also used : AtlasException(org.apache.atlas.AtlasException) URISyntaxException(java.net.URISyntaxException) NotificationException(org.apache.atlas.notification.NotificationException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) AtlasException(org.apache.atlas.AtlasException)

Aggregations

AtlasException (org.apache.atlas.AtlasException)139 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)36 IOException (java.io.IOException)27 AttributeInfo (org.apache.atlas.typesystem.types.AttributeInfo)26 Configuration (org.apache.commons.configuration.Configuration)19 CreateUpdateEntitiesResult (org.apache.atlas.CreateUpdateEntitiesResult)14 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)13 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)13 ArrayList (java.util.ArrayList)12 RepositoryException (org.apache.atlas.repository.RepositoryException)12 JSONObject (org.codehaus.jettison.json.JSONObject)12 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)10 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)9 HashMap (java.util.HashMap)8 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)8 AtlasVertex (org.apache.atlas.repository.graphdb.AtlasVertex)8 Properties (java.util.Properties)7 File (java.io.File)6 InputStream (java.io.InputStream)6 EntityChangeListener (org.apache.atlas.listener.EntityChangeListener)6