Search in sources :

Example 16 with HookNotification

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

the class AtlasHookTest method testFailedMessageIsLoggedIfRequired.

@Test
public void testFailedMessageIsLoggedIfRequired() throws NotificationException {
    List<HookNotification> hookNotifications = new ArrayList<HookNotification>() {

        {
            add(new EntityCreateRequest("user"));
        }
    };
    doThrow(new NotificationException(new Exception(), Arrays.asList("test message"))).when(notificationInterface).send(NotificationInterface.NotificationType.HOOK, hookNotifications);
    AtlasHook.notifyEntitiesInternal(hookNotifications, 2, notificationInterface, true, failedMessagesLogger);
    verify(failedMessagesLogger, times(1)).log("test message");
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) ArrayList(java.util.ArrayList) NotificationException(org.apache.atlas.notification.NotificationException) EntityCreateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest) NotificationException(org.apache.atlas.notification.NotificationException) Test(org.testng.annotations.Test)

Example 17 with HookNotification

use of org.apache.atlas.model.notification.HookNotification 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 18 with HookNotification

use of org.apache.atlas.model.notification.HookNotification 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)

Example 19 with HookNotification

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

the class DropTable method getNotificationMessages.

@Override
public List<HookNotification> getNotificationMessages() throws Exception {
    List<HookNotification> ret = null;
    List<AtlasObjectId> entities = getEntities();
    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 20 with HookNotification

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

the class FalconHook method fireAndForget.

private void fireAndForget(FalconEvent event) throws FalconException, URISyntaxException {
    LOG.info("Entered Atlas hook for Falcon hook operation {}", event.getOperation());
    List<HookNotification> messages = new ArrayList<>();
    Operation op = getOperation(event.getOperation());
    String user = getUser(event.getUser());
    LOG.info("fireAndForget user:{}", user);
    switch(op) {
        case ADD:
            messages.add(new EntityCreateRequest(user, createEntities(event, user)));
            break;
    }
    notifyEntities(messages);
}
Also used : HookNotification(org.apache.atlas.model.notification.HookNotification) ArrayList(java.util.ArrayList) EntityCreateRequest(org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)

Aggregations

HookNotification (org.apache.atlas.model.notification.HookNotification)31 Test (org.testng.annotations.Test)18 ArrayList (java.util.ArrayList)13 AtlasEntitiesWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntitiesWithExtInfo)9 Referenceable (org.apache.atlas.v1.model.instance.Referenceable)9 AtlasObjectId (org.apache.atlas.model.instance.AtlasObjectId)8 EntityCreateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityCreateRequest)8 AtlasEntity (org.apache.atlas.model.instance.AtlasEntity)6 EntityNotificationTest (org.apache.atlas.notification.entity.EntityNotificationTest)6 EntityUpdateRequest (org.apache.atlas.v1.model.notification.HookNotificationV1.EntityUpdateRequest)6 Map (java.util.Map)5 EntityCreateRequestV2 (org.apache.atlas.model.notification.HookNotification.EntityCreateRequestV2)5 NotificationException (org.apache.atlas.notification.NotificationException)5 EntityUpdateRequestV2 (org.apache.atlas.model.notification.HookNotification.EntityUpdateRequestV2)4 AtlasEntityWithExtInfo (org.apache.atlas.model.instance.AtlasEntity.AtlasEntityWithExtInfo)3 EntityDeleteRequestV2 (org.apache.atlas.model.notification.HookNotification.EntityDeleteRequestV2)3 EntityPartialUpdateRequestV2 (org.apache.atlas.model.notification.HookNotification.EntityPartialUpdateRequestV2)3 MessageVersion (org.apache.atlas.model.notification.MessageVersion)2 Table (org.apache.hadoop.hive.ql.metadata.Table)2 ConsumerRecord (org.apache.kafka.clients.consumer.ConsumerRecord)2