Search in sources :

Example 1 with EntityDeleteRequestV2

use of org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2 in project atlas by apache.

the class DropDatabase method getNotificationMessages.

@Override
public List<HookNotification> getNotificationMessages() {
    List<HookNotification> ret = null;
    List<AtlasObjectId> entities = context.isMetastoreHook() ? getHiveMetastoreEntities() : getHiveEntities();
    if (CollectionUtils.isNotEmpty(entities)) {
        ret = new ArrayList<>(entities.size());
        for (AtlasObjectId entity : entities) {
            ret.add(new EntityDeleteRequestV2(getUserName(), Collections.singletonList(entity)));
        }
    }
    return ret;
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) EntityDeleteRequestV2(org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2)

Example 2 with EntityDeleteRequestV2

use of org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2 in project atlas by apache.

the class HookNotificationTest method testEntityDeleteV2SerDe.

@Test
public void testEntityDeleteV2SerDe() throws Exception {
    AtlasEntity entity1 = new AtlasEntity("sometype");
    AtlasEntity entity2 = new AtlasEntity("newtype");
    AtlasEntity entity3 = new AtlasEntity("othertype");
    List<AtlasObjectId> objectsToDelete = new ArrayList<>();
    objectsToDelete.add(new AtlasObjectId(entity1.getGuid(), entity1.getTypeName()));
    objectsToDelete.add(new AtlasObjectId(entity2.getGuid(), entity2.getTypeName()));
    objectsToDelete.add(new AtlasObjectId(entity3.getGuid(), entity3.getTypeName()));
    String user = "user";
    EntityDeleteRequestV2 request = new EntityDeleteRequestV2(user, objectsToDelete);
    String notificationJson = AtlasJson.toJson(request);
    HookNotification actualNotification = deserializer.deserialize(notificationJson);
    assertEquals(actualNotification.getType(), HookNotificationType.ENTITY_DELETE_V2);
    assertEquals(actualNotification.getUser(), user);
    EntityDeleteRequestV2 deleteRequest = (EntityDeleteRequestV2) actualNotification;
    assertEquals(deleteRequest.getEntities().size(), objectsToDelete.size());
    assertEquals(deleteRequest.getEntities(), objectsToDelete);
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) ArrayList(java.util.ArrayList) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) EntityDeleteRequestV2(org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2) Test(org.testng.annotations.Test)

Example 3 with EntityDeleteRequestV2

use of org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2 in project atlas by apache.

the class HBaseAtlasHook method deleteTableInstance.

private void deleteTableInstance(HBaseOperationContext hbaseOperationContext) {
    TableName tableName = hbaseOperationContext.getTableName();
    String nameSpaceName = tableName.getNamespaceAsString();
    if (nameSpaceName == null) {
        nameSpaceName = tableName.getNameWithNamespaceInclAsString();
    }
    String tableNameStr = tableName.getNameAsString();
    String tableQName = getTableQualifiedName(getMetadataNamespace(), nameSpaceName, tableNameStr);
    AtlasObjectId tableId = new AtlasObjectId(HBaseDataTypes.HBASE_TABLE.getName(), REFERENCEABLE_ATTRIBUTE_NAME, tableQName);
    LOG.info("Delete Table {}", tableQName);
    hbaseOperationContext.addMessage(new EntityDeleteRequestV2(hbaseOperationContext.getUser(), Collections.singletonList(tableId)));
}
Also used : TableName(org.apache.hadoop.hbase.TableName) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) EntityDeleteRequestV2(org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2)

Example 4 with EntityDeleteRequestV2

use of org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2 in project atlas by apache.

the class HBaseAtlasHook method deleteNameSpaceInstance.

private void deleteNameSpaceInstance(HBaseOperationContext hbaseOperationContext) {
    String nameSpaceQName = getNameSpaceQualifiedName(getMetadataNamespace(), hbaseOperationContext.getNameSpace());
    AtlasObjectId nameSpaceId = new AtlasObjectId(HBaseDataTypes.HBASE_NAMESPACE.getName(), REFERENCEABLE_ATTRIBUTE_NAME, nameSpaceQName);
    LOG.info("Delete NameSpace {}", nameSpaceQName);
    hbaseOperationContext.addMessage(new EntityDeleteRequestV2(hbaseOperationContext.getUser(), Collections.singletonList(nameSpaceId)));
}
Also used : AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) EntityDeleteRequestV2(org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2)

Example 5 with EntityDeleteRequestV2

use of org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2 in project atlas by apache.

the class HBaseAtlasHook method deleteColumnFamilyInstance.

private void deleteColumnFamilyInstance(HBaseOperationContext hbaseOperationContext) {
    TableName tableName = hbaseOperationContext.getTableName();
    String nameSpaceName = tableName.getNamespaceAsString();
    if (nameSpaceName == null) {
        nameSpaceName = tableName.getNameWithNamespaceInclAsString();
    }
    String tableNameStr = tableName.getNameAsString();
    String columnFamilyName = hbaseOperationContext.getColummFamily();
    String columnFamilyQName = getColumnFamilyQualifiedName(getMetadataNamespace(), nameSpaceName, tableNameStr, columnFamilyName);
    AtlasObjectId columnFamilyId = new AtlasObjectId(HBaseDataTypes.HBASE_COLUMN_FAMILY.getName(), REFERENCEABLE_ATTRIBUTE_NAME, columnFamilyQName);
    LOG.info("Delete ColumnFamily {}", columnFamilyQName);
    hbaseOperationContext.addMessage(new EntityDeleteRequestV2(hbaseOperationContext.getUser(), Collections.singletonList(columnFamilyId)));
}
Also used : TableName(org.apache.hadoop.hbase.TableName) AtlasObjectId(org.apache.atlas.model.instance.AtlasObjectId) EntityDeleteRequestV2(org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2)

Aggregations

AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)6 EntityDeleteRequestV2 (org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2)6 HookNotification (org.apache.atlas.model.notification.HookNotification)3 TableName (org.apache.hadoop.hbase.TableName)2 ArrayList (java.util.ArrayList)1 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)1 Test (org.testng.annotations.Test)1