-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ADMIN-3 | Send notifications to Kafka topic after planning is done for tag propagation #4085
base: tagpropv1master
Are you sure you want to change the base?
Conversation
@@ -39,4 +39,6 @@ private AtlasConstants() { | |||
public static final String DEFAULT_TYPE_VERSION = "1.0"; | |||
public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30; | |||
public static final int TASK_WAIT_TIME_MS = 180_000; | |||
public static final String ATLAS_KAFKA_TAG_TOPIC = "TAG_PROP_EVENTS"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will create a new topic which will handle other object propagation use-cases w a more generic name.
That is upcoming in a TRD. Will share and we can make changes accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will wait. Include me in the discussions too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will create a new topic which will handle other object propagation use-cases w a more generic name.
Can we change this to some generic name then ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you want to go ahead with this for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's change the name it OBJECT_PROP_EVENTS
.
@@ -480,6 +480,9 @@ public enum SupportedFileExtensions { XLSX, XLS, CSV } | |||
public static final String REQUEST_HEADER_USER_AGENT = "User-Agent"; | |||
public static final String REQUEST_HEADER_HOST = "Host"; | |||
|
|||
//kafka partition value for TAG_PROP_EVENTS | |||
public static final String TAG_PROP_EVENTS_PARTITION_COUNT = "5"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partition count might also get changed once we determine how we combine more use-cases into the same Kafka topic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, will wait. Include me in the discussions too
@@ -418,4 +478,18 @@ private boolean isKafkaConsumerOpen(KafkaConsumer consumer) { | |||
return ret; | |||
} | |||
|
|||
public Map<String, Object> createKafkaMessage(AtlasVertex vertex, AtlasGraph graph, String classificationType, String tagVertedId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function name is too generic and its body is doing something v specific to tag propagation. Rename the func.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed it to createTagPropKafkaMessage
@@ -70,6 +71,11 @@ public void sendInternal(NotificationType type, List<String> messages) { | |||
} | |||
} | |||
|
|||
@Override | |||
public void sendInternal(NotificationType notificationType, List<String> messages, Integer partition) throws NotificationException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raise a NotImplemented
exception from this method if it's only written to satisfy an interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
repository/pom.xml
Outdated
<dependency> | ||
<groupId>org.apache.atlas</groupId> | ||
<artifactId>atlas-notification</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.atlas</groupId> | ||
<artifactId>atlas-notification</artifactId> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Duplicated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
@@ -98,21 +100,9 @@ public abstract class DeleteHandlerV1 { | |||
private final TaskUtil taskUtil; | |||
private static final int CHUNK_SIZE = AtlasConfiguration.TASKS_GRAPH_COMMIT_CHUNK_SIZE.getInt(); | |||
|
|||
public void updateTaskVertexProperty(String propertyKey, long value, boolean isIncremental, BiConsumer<AtlasTask, Long> taskSetter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rebase and bring the latest v1 changes into this branch. Will continue reviewing once that is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
6a0fb40
to
317322e
Compare
@@ -39,4 +39,6 @@ private AtlasConstants() { | |||
public static final String DEFAULT_TYPE_VERSION = "1.0"; | |||
public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30; | |||
public static final int TASK_WAIT_TIME_MS = 180_000; | |||
public static final String ATLAS_KAFKA_TAG_TOPIC = "TAG_PROP_EVENTS"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will create a new topic which will handle other object propagation use-cases w a more generic name.
Can we change this to some generic name then ?
@@ -39,4 +39,6 @@ private AtlasConstants() { | |||
public static final String DEFAULT_TYPE_VERSION = "1.0"; | |||
public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30; | |||
public static final int TASK_WAIT_TIME_MS = 180_000; | |||
public static final String ATLAS_KAFKA_TAG_TOPIC = "TAG_PROP_EVENTS"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you want to go ahead with this for now?
@@ -39,4 +39,6 @@ private AtlasConstants() { | |||
public static final String DEFAULT_TYPE_VERSION = "1.0"; | |||
public static final int ATLAS_SHUTDOWN_HOOK_PRIORITY = 30; | |||
public static final int TASK_WAIT_TIME_MS = 180_000; | |||
public static final String ATLAS_KAFKA_TAG_TOPIC = "TAG_PROP_EVENTS"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the other python script, we are also considering the atlas.notification.propagation.topic.name
from application properties, I think we should follow same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to distro/src/bin/atlas_config.py
@@ -108,6 +108,38 @@ public void createTopics(List<String> topicNames, int numPartitions, int replica | |||
} | |||
} | |||
|
|||
public void createTopics(List<String[]> topicDetails, int replicationFactor) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need this method if the script distro/src/bin/atlas_config.py
also does create topics?
List<String[]> topicDetails = new ArrayList<>(); | ||
|
||
for (String topicName : topicNames) { | ||
if (AtlasConfiguration.NOTIFICATION_PROPAGATION_TOPIC_NAME.getString().equals(topicName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have created An Enum for all Kafka topics with all the details of every topic needed to avoid such special handling for a particular topic, fine for now shared this for future reference
List<MessageContext> messageContexts = new ArrayList<>(); | ||
|
||
for (String message : messages) { | ||
ProducerRecord record = new ProducerRecord(topic, partition, null, message); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once we accept message key instead of partition, use the proper ProducerRecord constructor here which accepts topic, key & value
Map<String, Object> kafkaMessage = kfknotif.createTagPropKafkaMessage(vertex, graph, CLASSIFICATION_PROPAGATION_ADD, classificationVertex.getIdForDisplay()); | ||
int partition = Math.abs((Integer) kafkaMessage.get("parentTaskGuid")) % numPartitions; | ||
LOG.debug("sending message with guid={} to partition={}",kafkaMessage.get("parentTaskVertexId"), partition); | ||
kfknotif.sendInternal(NotificationInterface.NotificationType.EMIT_PLANNED_RELATIONSHIPS, Collections.singletonList(kafkaMessage.toString()), partition); | ||
LOG.debug("Message with guid={} sent to partition={} sent successfully.",kafkaMessage.get("parentTaskVertexId"), partition ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to simplify 2 method calls into a single method call in kfknotif may be
#!/usr/bin/env python3 | ||
|
||
import os | ||
import subprocess | ||
import sys | ||
import platform | ||
import time | ||
|
||
|
||
|
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this file should not be in your PR, do rebase once
@@ -65,6 +65,8 @@ | |||
import static org.apache.atlas.repository.Constants.INDEX_PREFIX; | |||
import static org.apache.atlas.repository.Constants.VERTEX_INDEX; | |||
|
|||
import org.apache.atlas.hook.AtlasTopicCreator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not needed, remove all changes in this file
int partition = Math.abs((Integer) kafkaMessage.get("parentTaskGuid")) % numPartitions; | ||
LOG.debug("sending message with guid={} to partition={}",kafkaMessage.get("parentTaskVertexId"), partition); | ||
kfknotif.sendInternal(NotificationInterface.NotificationType.EMIT_PLANNED_RELATIONSHIPS, Collections.singletonList(kafkaMessage.toString()), partition); | ||
LOG.debug("Message with guid={} sent to partition={} sent successfully.",kafkaMessage.get("parentTaskVertexId"), partition ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need one debug log per message? consider removing this & if needed write a generic log outside the for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applicable for all other similar places
Change description
Key Changes:
Ref: V1.5
Type of change
Related issues
Checklists
Development
Security
Code review