Search in sources :

Example 41 with AtlasException

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

the class AttributeInfo method output.

public void output(Appendable buf, Set<String> typesInProcess) throws AtlasException {
    try {
        buf.append("{name=").append(name);
        buf.append(", dataType=");
        dataType.output(buf, typesInProcess);
        buf.append(", multiplicity=").append(multiplicity.toString());
        buf.append(", isComposite=").append(Boolean.toString(isComposite));
        buf.append(", isUnique=").append(Boolean.toString(isUnique));
        buf.append(", isIndexable=").append(Boolean.toString(isIndexable));
        buf.append(", reverseAttributeName=").append(reverseAttributeName);
        buf.append('}');
    } catch (IOException e) {
        throw new AtlasException(e);
    }
}
Also used : IOException(java.io.IOException) AtlasException(org.apache.atlas.AtlasException)

Example 42 with AtlasException

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

the class SecureClientUtils method getSSLClientFile.

private static File getSSLClientFile() throws AtlasException {
    String confLocation = System.getProperty("atlas.conf");
    File sslDir;
    try {
        if (confLocation == null) {
            String persistDir = null;
            URL resource = SecureClientUtils.class.getResource("/");
            if (resource != null) {
                persistDir = resource.toURI().getPath();
            }
            assert persistDir != null;
            sslDir = new File(persistDir);
        } else {
            sslDir = new File(confLocation);
        }
        LOG.info("ssl-client.xml will be created in {}", sslDir);
    } catch (Exception e) {
        throw new AtlasException("Failed to find client configuration directory", e);
    }
    return new File(sslDir, SecurityProperties.SSL_CLIENT_PROPERTIES);
}
Also used : AtlasException(org.apache.atlas.AtlasException) File(java.io.File) URL(java.net.URL) DelegationTokenAuthenticatedURL(org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL) GeneralSecurityException(java.security.GeneralSecurityException) IOException(java.io.IOException) AtlasException(org.apache.atlas.AtlasException)

Example 43 with AtlasException

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

the class HBaseBasedAuditRepository method startInternal.

@VisibleForTesting
void startInternal(Configuration atlasConf, org.apache.hadoop.conf.Configuration hbaseConf) throws AtlasException {
    String tableNameStr = atlasConf.getString(CONFIG_TABLE_NAME, DEFAULT_TABLE_NAME);
    tableName = TableName.valueOf(tableNameStr);
    try {
        connection = createConnection(hbaseConf);
    } catch (IOException e) {
        throw new AtlasException(e);
    }
    if (!HAConfiguration.isHAEnabled(atlasConf)) {
        LOG.info("HA is disabled. Hence creating table on startup.");
        createTableIfNotExists();
    }
}
Also used : IOException(java.io.IOException) AtlasException(org.apache.atlas.AtlasException) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 44 with AtlasException

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

the class HBaseBasedAuditRepository method createTableIfNotExists.

private void createTableIfNotExists() throws AtlasException {
    Admin admin = null;
    try {
        admin = connection.getAdmin();
        LOG.info("Checking if table {} exists", tableName.getNameAsString());
        if (!admin.tableExists(tableName)) {
            LOG.info("Creating table {}", tableName.getNameAsString());
            HTableDescriptor tableDescriptor = new HTableDescriptor(tableName);
            HColumnDescriptor columnFamily = new HColumnDescriptor(COLUMN_FAMILY);
            columnFamily.setMaxVersions(1);
            columnFamily.setDataBlockEncoding(DataBlockEncoding.FAST_DIFF);
            columnFamily.setCompressionType(Compression.Algorithm.GZ);
            columnFamily.setBloomFilterType(BloomType.ROW);
            tableDescriptor.addFamily(columnFamily);
            admin.createTable(tableDescriptor);
        } else {
            LOG.info("Table {} exists", tableName.getNameAsString());
        }
    } catch (IOException e) {
        throw new AtlasException(e);
    } finally {
        close(admin);
    }
}
Also used : HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) IOException(java.io.IOException) Admin(org.apache.hadoop.hbase.client.Admin) AtlasException(org.apache.atlas.AtlasException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Example 45 with AtlasException

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

the class HBaseBasedAuditRepository method putEvents.

@Override
public /**
 * Add events to the event repository
 * @param events events to be added
 * @throws AtlasException
 */
void putEvents(List<EntityAuditEvent> events) throws AtlasException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Putting {} events", events.size());
    }
    Table table = null;
    try {
        table = connection.getTable(tableName);
        List<Put> puts = new ArrayList<>(events.size());
        for (EntityAuditEvent event : events) {
            LOG.debug("Adding entity audit event {}", event);
            Put put = new Put(getKey(event.getEntityId(), event.getTimestamp()));
            addColumn(put, COLUMN_ACTION, event.getAction());
            addColumn(put, COLUMN_USER, event.getUser());
            addColumn(put, COLUMN_DETAIL, event.getDetails());
            if (persistEntityDefinition) {
                addColumn(put, COLUMN_DEFINITION, event.getEntityDefinitionString());
            }
            puts.add(put);
        }
        table.put(puts);
    } catch (IOException e) {
        throw new AtlasException(e);
    } finally {
        close(table);
    }
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) Table(org.apache.hadoop.hbase.client.Table) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AtlasException(org.apache.atlas.AtlasException) Put(org.apache.hadoop.hbase.client.Put)

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