Search in sources :

Example 1 with EntityAuditEvent

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

the class EntityAuditListener method onEntitiesAdded.

@Override
public void onEntitiesAdded(Collection<ITypedReferenceableInstance> entities, boolean isImport) throws AtlasException {
    List<EntityAuditEvent> events = new ArrayList<>();
    for (ITypedReferenceableInstance entity : entities) {
        EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_CREATE : EntityAuditAction.ENTITY_CREATE);
        events.add(event);
    }
    auditRepository.putEvents(events);
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) ArrayList(java.util.ArrayList)

Example 2 with EntityAuditEvent

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

the class EntityAuditListener method onEntitiesUpdated.

@Override
public void onEntitiesUpdated(Collection<ITypedReferenceableInstance> entities, boolean isImport) throws AtlasException {
    List<EntityAuditEvent> events = new ArrayList<>();
    for (ITypedReferenceableInstance entity : entities) {
        EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_UPDATE : EntityAuditAction.ENTITY_UPDATE);
        events.add(event);
    }
    auditRepository.putEvents(events);
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) ArrayList(java.util.ArrayList)

Example 3 with EntityAuditEvent

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

the class EntityAuditListener method onEntitiesDeleted.

@Override
public void onEntitiesDeleted(Collection<ITypedReferenceableInstance> entities, boolean isImport) throws AtlasException {
    List<EntityAuditEvent> events = new ArrayList<>();
    for (ITypedReferenceableInstance entity : entities) {
        EntityAuditEvent event = createEvent(entity, isImport ? EntityAuditAction.ENTITY_IMPORT_DELETE : EntityAuditAction.ENTITY_DELETE, "Deleted entity");
        events.add(event);
    }
    auditRepository.putEvents(events);
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) ITypedReferenceableInstance(org.apache.atlas.typesystem.ITypedReferenceableInstance) ArrayList(java.util.ArrayList)

Example 4 with EntityAuditEvent

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

the class EntityAuditListener method onTraitsAdded.

@Override
public void onTraitsAdded(ITypedReferenceableInstance entity, Collection<? extends IStruct> traits) throws AtlasException {
    if (traits != null) {
        for (IStruct trait : traits) {
            EntityAuditEvent event = createEvent(entity, EntityAuditAction.TAG_ADD, "Added trait: " + InstanceSerialization.toJson(trait, true));
            auditRepository.putEvents(event);
        }
    }
}
Also used : EntityAuditEvent(org.apache.atlas.EntityAuditEvent) IStruct(org.apache.atlas.typesystem.IStruct)

Example 5 with EntityAuditEvent

use of org.apache.atlas.EntityAuditEvent 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

EntityAuditEvent (org.apache.atlas.EntityAuditEvent)20 ArrayList (java.util.ArrayList)7 Test (org.testng.annotations.Test)5 Referenceable (org.apache.atlas.typesystem.Referenceable)4 AtlasException (org.apache.atlas.AtlasException)3 ITypedReferenceableInstance (org.apache.atlas.typesystem.ITypedReferenceableInstance)3 IOException (java.io.IOException)2 IStruct (org.apache.atlas.typesystem.IStruct)2 Table (org.apache.hadoop.hbase.client.Table)2 BeforeTest (org.testng.annotations.BeforeTest)2 AtlasClient (org.apache.atlas.AtlasClient)1 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)1 HookNotification (org.apache.atlas.notification.hook.HookNotification)1 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)1 Put (org.apache.hadoop.hbase.client.Put)1 Result (org.apache.hadoop.hbase.client.Result)1 ResultScanner (org.apache.hadoop.hbase.client.ResultScanner)1 Scan (org.apache.hadoop.hbase.client.Scan)1 PageFilter (org.apache.hadoop.hbase.filter.PageFilter)1 JSONArray (org.codehaus.jettison.json.JSONArray)1