Search in sources :

Example 1 with EntityCreateRequestV2

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

the class HBaseAtlasHook method createOrUpdateColumnFamilyInstance.

private void createOrUpdateColumnFamilyInstance(HBaseOperationContext hbaseOperationContext) {
    AtlasEntity nameSpace = buildNameSpace(hbaseOperationContext);
    AtlasEntity table = buildTable(hbaseOperationContext, nameSpace);
    AtlasEntity columnFamily = buildColumnFamily(hbaseOperationContext, hbaseOperationContext.gethColumnDescriptor(), nameSpace, table);
    AtlasEntitiesWithExtInfo entities = new AtlasEntitiesWithExtInfo(columnFamily);
    entities.addReferredEntity(nameSpace);
    entities.addReferredEntity(table);
    switch(hbaseOperationContext.getOperation()) {
        case CREATE_COLUMN_FAMILY:
            LOG.info("Create ColumnFamily {}", columnFamily.getAttribute(REFERENCEABLE_ATTRIBUTE_NAME));
            hbaseOperationContext.addMessage(new EntityCreateRequestV2(hbaseOperationContext.getUser(), entities));
            break;
        case ALTER_COLUMN_FAMILY:
            LOG.info("Alter ColumnFamily {}", columnFamily.getAttribute(REFERENCEABLE_ATTRIBUTE_NAME));
            hbaseOperationContext.addMessage(new EntityUpdateRequestV2(hbaseOperationContext.getUser(), entities));
            break;
    }
}
Also used : AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) EntityUpdateRequestV2(org.apache.atlas.model.notification.HookNotification.EntityUpdateRequestV2) EntityCreateRequestV2(org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2)

Example 2 with EntityCreateRequestV2

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

the class CreateTable method getNotificationMessages.

@Override
public List<HookNotification> getNotificationMessages() throws Exception {
    List<HookNotification> ret = null;
    AtlasEntitiesWithExtInfo entities = getEntities();
    if (entities != null && CollectionUtils.isNotEmpty(entities.getEntities())) {
        ret = Collections.singletonList(new EntityCreateRequestV2(getUserName(), entities));
    }
    return ret;
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) EntityCreateRequestV2(org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2)

Example 3 with EntityCreateRequestV2

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

the class SqoopHook method publish.

@Override
public void publish(SqoopJobDataPublisher.Data data) throws AtlasHookException {
    try {
        Configuration atlasProperties = ApplicationProperties.get();
        String clusterName = atlasProperties.getString(ATLAS_CLUSTER_NAME, DEFAULT_CLUSTER_NAME);
        AtlasEntity entDbStore = toSqoopDBStoreEntity(data);
        AtlasEntity entHiveDb = toHiveDatabaseEntity(clusterName, data.getHiveDB());
        AtlasEntity entHiveTable = data.getHiveTable() != null ? toHiveTableEntity(entHiveDb, data.getHiveTable()) : null;
        AtlasEntity entProcess = toSqoopProcessEntity(entDbStore, entHiveDb, entHiveTable, data, clusterName);
        AtlasEntitiesWithExtInfo entities = new AtlasEntitiesWithExtInfo(entProcess);
        entities.addReferredEntity(entDbStore);
        entities.addReferredEntity(entHiveDb);
        if (entHiveTable != null) {
            entities.addReferredEntity(entHiveTable);
        }
        HookNotification message = new EntityCreateRequestV2(AtlasHook.getUser(), entities);
        AtlasHook.notifyEntities(Collections.singletonList(message), atlasProperties.getInt(HOOK_NUM_RETRIES, 3));
    } catch (Exception e) {
        LOG.error("SqoopHook.publish() failed", e);
        throw new AtlasHookException("SqoopHook.publish() failed.", e);
    }
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) Configuration(org.apache.commons.configuration.Configuration) AtlasEntity(org.apache.atlas.model.instance.AtlasEntity) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) ImportException(org.apache.sqoop.util.ImportException) AtlasHookException(org.apache.atlas.hook.AtlasHookException) AtlasHookException(org.apache.atlas.hook.AtlasHookException) EntityCreateRequestV2(org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2)

Example 4 with EntityCreateRequestV2

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

the class CreateDatabase method getNotificationMessages.

@Override
public List<HookNotification> getNotificationMessages() throws Exception {
    List<HookNotification> ret = null;
    AtlasEntitiesWithExtInfo entities = getEntities();
    if (entities != null && CollectionUtils.isNotEmpty(entities.getEntities())) {
        ret = Collections.singletonList(new EntityCreateRequestV2(getUserName(), entities));
    }
    return ret;
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) EntityCreateRequestV2(org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2)

Example 5 with EntityCreateRequestV2

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

the class CreateHiveProcess method getNotificationMessages.

@Override
public List<HookNotification> getNotificationMessages() throws Exception {
    List<HookNotification> ret = null;
    AtlasEntitiesWithExtInfo entities = getEntities();
    if (entities != null && CollectionUtils.isNotEmpty(entities.getEntities())) {
        ret = Collections.singletonList(new EntityCreateRequestV2(getUserName(), entities));
    }
    return ret;
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) AtlasEntitiesWithExtInfo(org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo) EntityCreateRequestV2(org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2)

Aggregations

AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)8 EntityCreateRequestV2 (org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2)8 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)5 HookNotification (org.apache.atlas.model.notification.HookNotification)5 EntityUpdateRequestV2 (org.apache.atlas.model.notification.HookNotification.EntityUpdateRequestV2)3 Map (java.util.Map)1 AtlasHookException (org.apache.atlas.hook.AtlasHookException)1 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)1 Configuration (org.apache.commons.configuration.Configuration)1 ImportException (org.apache.sqoop.util.ImportException)1 Test (org.testng.annotations.Test)1