Repository: incubator-atlas Updated Branches: refs/heads/master 92574b574 -> de9b890dd
ATLAS-422 JavaDoc NotificationConsumer and NotificationInterface. Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/de9b890d Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/de9b890d Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/de9b890d Branch: refs/heads/master Commit: de9b890dd05816cf3d71da7250e59ba760a9116f Parents: 92574b5 Author: Suma Shivaprasad <[email protected]> Authored: Tue Mar 1 14:07:40 2016 -0800 Committer: Suma Shivaprasad <[email protected]> Committed: Tue Mar 1 14:08:33 2016 -0800 ---------------------------------------------------------------------- .../org/apache/atlas/kafka/KafkaConsumer.java | 2 +- .../AbstractNotificationConsumer.java | 17 ++++----- .../notification/NotificationConsumer.java | 22 ++++++++++-- .../notification/NotificationInterface.java | 37 ++++++++++++++++++-- release-log.txt | 1 + 5 files changed, 64 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/de9b890d/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java ---------------------------------------------------------------------- diff --git a/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java b/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java index f336481..029a072 100644 --- a/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java +++ b/notification/src/main/java/org/apache/atlas/kafka/KafkaConsumer.java @@ -52,7 +52,7 @@ public class KafkaConsumer<T> extends AbstractNotificationConsumer<T> { } - // ----- Iterator -------------------------------------------------------- + // ----- NotificationConsumer -------------------------------------------- @Override public boolean hasNext() { http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/de9b890d/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java ---------------------------------------------------------------------- diff --git a/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java b/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java index 4bdaed3..1cadb99 100644 --- a/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java +++ b/notification/src/main/java/org/apache/atlas/notification/AbstractNotificationConsumer.java @@ -63,7 +63,7 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon private final Class<T> type; - // ----- Constructors ------------------------------------------------------ + // ----- Constructors ---------------------------------------------------- /** * Construct an AbstractNotificationConsumer. @@ -84,8 +84,15 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon */ protected abstract String getNext(); + /** + * Get the next notification as a string without advancing. + * + * @return the next notification in string form + */ + protected abstract String peekMessage(); + - // ----- Iterator --------------------------------------------------------- + // ----- NotificationConsumer --------------------------------------------- @Override public T next() { @@ -97,13 +104,11 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon return GSON.fromJson(peekMessage(), type); } - protected abstract String peekMessage(); /** * Deserializer for ImmutableList used by AbstractNotificationConsumer.GSON. */ public static class ImmutableListDeserializer implements JsonDeserializer<ImmutableList<?>> { - public static final Type LIST_TYPE = new TypeToken<List<?>>() { }.getType(); @@ -115,7 +120,6 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon } } - /** * Deserializer for ImmutableMap used by AbstractNotificationConsumer.GSON. */ @@ -144,7 +148,6 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon } } - /** * Serde for Struct used by AbstractNotificationConsumer.GSON. */ @@ -162,7 +165,6 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon } } - /** * Serde for Referenceable used by AbstractNotificationConsumer.GSON. */ @@ -182,7 +184,6 @@ public abstract class AbstractNotificationConsumer<T> implements NotificationCon } } - /** * Serde for JSONArray used by AbstractNotificationConsumer.GSON. */ http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/de9b890d/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java ---------------------------------------------------------------------- diff --git a/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java b/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java index 53b3c6a..f0956a8 100644 --- a/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java +++ b/notification/src/main/java/org/apache/atlas/notification/NotificationConsumer.java @@ -18,13 +18,29 @@ package org.apache.atlas.notification; /** - * Interface for notification consumer. - * @param <T> message type + * Atlas notification consumer. This consumer blocks until a notification can be read. + * + * @param <T> the class type of notifications returned by this consumer */ -public interface NotificationConsumer<T> { +public interface NotificationConsumer<T>{ + /** + * Returns true when the consumer has more notifications. Blocks until a notification becomes available. + * + * @return true when the consumer has notifications to be read + */ boolean hasNext(); + /** + * Returns the next notification. + * + * @return the next notification + */ T next(); + /** + * Returns the next notification without advancing. + * + * @return the next notification + */ T peek(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/de9b890d/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java ---------------------------------------------------------------------- diff --git a/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java b/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java index dd52bff..ac285aa 100644 --- a/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java +++ b/notification/src/main/java/org/apache/atlas/notification/NotificationInterface.java @@ -23,20 +23,30 @@ import org.apache.atlas.notification.hook.HookNotification; import java.util.List; /** - * Notification interface for sending/receiving messages. + * Interface to the Atlas notification framework. Use this interface to create consumers and to send messages of a + * given notification type. + * * 1. Atlas sends entity notifications * 2. Hooks send notifications to create/update types/entities. Atlas reads these messages */ public interface NotificationInterface { + /** + * Prefix for Atlas notification related configuration properties. + */ String PROPERTY_PREFIX = "atlas.notification"; /** - * Notification type - hooks and entities. + * Atlas notification types. */ enum NotificationType { - HOOK(HookNotification.HookNotificationMessage.class), ENTITIES(EntityNotification.class); + HOOK(HookNotification.HookNotificationMessage.class), // notifications from the Atlas integration hook producers + ENTITIES(EntityNotification.class); // notifications to entity change consumers + + /** + * The notification class associated with this type. + */ private final Class classType; NotificationType(Class classType) { @@ -59,9 +69,30 @@ public interface NotificationInterface { */ <T> List<NotificationConsumer<T>> createConsumers(NotificationType notificationType, int numConsumers); + /** + * Send the given messages. + * + * @param type the message type + * @param messages the messages to send + * @param <T> the message type + * + * @throws NotificationException if an error occurs while sending + */ <T> void send(NotificationType type, T... messages) throws NotificationException; + /** + * Send the given messages. + * + * @param type the message type + * @param messages the list of messages to send + * @param <T> the message type + * + * @throws NotificationException if an error occurs while sending + */ <T> void send(NotificationType type, List<T> messages) throws NotificationException; + /** + * Shutdown any notification producers and consumers associated with this interface instance. + */ void close(); } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/de9b890d/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 6689143..45b7f57 100644 --- a/release-log.txt +++ b/release-log.txt @@ -9,6 +9,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags) ALL CHANGES: +ATLAS-422 JavaDoc NotificationConsumer and NotificationInterface.(tbeerbower via sumasai) ATLAS-536 Falcon hook loads incorrect configuration when -Datlas.conf is not given when falcon server startup (ayubkhan via shwethags) ATLAS-502 UI: Provide the ability to search for tags (anilsg via shwethags) ATLAS-364 UI Code standardization (darshankumar89 via shwethags)
