This is an automated email from the ASF dual-hosted git repository.
mandarambawane pushed a commit to branch atlas-2.6
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/atlas-2.6 by this push:
new ab73e99c32 ATLAS-5207: Fix webapp test-compile on atlas-2.6 and
restore ATLAS-5320 hook parallel API (#801)
ab73e99c32 is described below
commit ab73e99c326cdc5bb32b42e42a84cd8d6754f9dd
Author: UmeshPatil-1 <[email protected]>
AuthorDate: Fri Nov 20 12:31:28 2026 +0530
ATLAS-5207: Fix webapp test-compile on atlas-2.6 and restore ATLAS-5320
hook parallel API (#801)
* ATLAS-5207 (2.6 follow-up): fix webapp testCompile; restore ATLAS-5320
hook parallel API
- AtlasJwtAuthWrapperTest missing Knox filter import after server-common
move.
- AtlasSecurityConfigTest ctor missing AtlasHeaderPreAuthFilter /
AtlasJwtAuthWrapper.
- RestNotificationTest missing commons-configuration2 BaseConfiguration
import.
Restore ATLAS-5320 parallel preprocessing surface
(getPreprocessorHookConsumers,
9-arg ctor, HOOK_PREPROCESS) on NotificationHookConsumer without reverting
full
ATLAS-5207 consumer merge. Align webapp tests with open source changes 5207.
Refs: ATLAS-5207
* ATLAS-5207 (2.6 follow-up): add SERVICE_NOTIFICATION_POST to
AtlasPrivilege for rest-notification compile
ATLAS-5388 (c2f780e7a) renamed the enum to POST_NOTIFICATION for
topic-scoped auth on 2.6.
ATLAS-5434 (39aeb1949) added verifyAccess(SERVICE_NOTIFICATION_POST) on
rest-notification-webapp NotificationREST without restoring the enum
constant,
causing rest-notification-webapp compile failure after webapp testCompile
was fixed.
Add SERVICE_NOTIFICATION_POST alongside POST_NOTIFICATION to complete 5434
and align
with PR #622 / master REST auth without reverting ATLAS-5388.
Refs: ATLAS-5207, ATLAS-5388, ATLAS-5434, PR #801, PR #799, PR #622.
* ATLAS-5207 (2.6 follow-up): align AtlasSecurityConfigTest with header/JWT
filter chain
---
.../org/apache/atlas/authorize/AtlasPrivilege.java | 4 +-
.../atlas/notification/RestNotificationTest.java | 1 +
.../notification/NotificationHookConsumer.java | 80 +++++++++++++++++++++-
.../atlas/web/filters/AtlasJwtAuthWrapperTest.java | 1 +
.../web/security/AtlasSecurityConfigTest.java | 18 ++++-
5 files changed, 98 insertions(+), 6 deletions(-)
diff --git
a/authorization/src/main/java/org/apache/atlas/authorize/AtlasPrivilege.java
b/authorization/src/main/java/org/apache/atlas/authorize/AtlasPrivilege.java
index e02d89b708..d9268d6342 100644
--- a/authorization/src/main/java/org/apache/atlas/authorize/AtlasPrivilege.java
+++ b/authorization/src/main/java/org/apache/atlas/authorize/AtlasPrivilege.java
@@ -48,7 +48,9 @@ public enum AtlasPrivilege {
ADMIN_AUDITS("admin-audits"),
- POST_NOTIFICATION("post-notification");
+ POST_NOTIFICATION("post-notification"),
+
+ SERVICE_NOTIFICATION_POST("service-notification-post");
private final String type;
diff --git
a/notification/src/test/java/org/apache/atlas/notification/RestNotificationTest.java
b/notification/src/test/java/org/apache/atlas/notification/RestNotificationTest.java
index 032da6f9c8..26d87bc390 100644
---
a/notification/src/test/java/org/apache/atlas/notification/RestNotificationTest.java
+++
b/notification/src/test/java/org/apache/atlas/notification/RestNotificationTest.java
@@ -28,6 +28,7 @@ import org.apache.atlas.AtlasErrorCode;
import org.apache.atlas.AtlasException;
import org.apache.atlas.kafka.NotificationProvider;
import org.apache.atlas.notification.rest.RestNotification;
+import org.apache.commons.configuration2.BaseConfiguration;
import org.apache.commons.configuration2.Configuration;
import org.mockito.Matchers;
import org.mockito.Mock;
diff --git
a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
index 1af988c5b5..a52f8ed90c 100644
---
a/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
+++
b/webapp/src/main/java/org/apache/atlas/notification/NotificationHookConsumer.java
@@ -47,6 +47,7 @@ import
org.apache.atlas.model.notification.ImportNotification.AtlasEntityImportN
import
org.apache.atlas.model.notification.ImportNotification.AtlasTypesDefImportNotification;
import org.apache.atlas.model.typedef.AtlasTypesDef;
import org.apache.atlas.notification.NotificationInterface.NotificationType;
+import org.apache.atlas.notification.preprocessor.NotificationPreProcessor;
import org.apache.atlas.notification.preprocessor.EntityPreprocessor;
import org.apache.atlas.notification.preprocessor.GenericEntityPreprocessor;
import org.apache.atlas.notification.preprocessor.PreprocessorContext;
@@ -54,6 +55,7 @@ import
org.apache.atlas.notification.preprocessor.PreprocessorContext.Preprocess
import org.apache.atlas.repository.converters.AtlasInstanceConverter;
import org.apache.atlas.repository.impexp.AsyncImporter;
import org.apache.atlas.repository.store.graph.AtlasEntityStore;
+import org.apache.atlas.repository.store.graph.AtlasTypeDefGraphStore;
import org.apache.atlas.repository.store.graph.EntityCorrelationStore;
import org.apache.atlas.repository.store.graph.v2.AtlasEntityStream;
import org.apache.atlas.repository.store.graph.v2.AtlasGraphUtilsV2;
@@ -179,6 +181,7 @@ public class NotificationHookConsumer implements Service,
ActiveStateChangeHandl
private static final int KAFKA_CONSUMER_SHUTDOWN_WAIT
= 30000;
private static final String ATLAS_HOOK_CONSUMER_THREAD_NAME
= "atlas-hook-consumer-thread";
private static final String ATLAS_HOOK_UNSORTED_CONSUMER_THREAD_NAME
= "atlas-hook-unsorted-consumer-thread";
+ private static final String ATLAS_HOOK_PRE_PROCESSOR_CONSUMER_THREAD_NAME
= "atlas-hook-preprocessor-consumer-thread";
private static final String ATLAS_IMPORT_CONSUMER_THREAD_PREFIX
= "atlas-import-consumer-thread-";
private static final String THREADNAME_PREFIX
= NotificationHookConsumer.class.getSimpleName();
@@ -221,6 +224,8 @@ public class NotificationHookConsumer implements Service,
ActiveStateChangeHandl
private final long consumerMsgBufferingIntervalMS;
private final int consumerMsgBufferingBatchSize;
private final AsyncImporter asyncImporter;
+ private final boolean parallelProcessingEnabled;
+ private final AtlasTypeDefGraphStore typeDefStore;
private ExecutorService executors;
private Instant nextStatsLogTime =
AtlasMetricsCounter.getNextHourStartTime(Instant.now());
@@ -233,6 +238,10 @@ public class NotificationHookConsumer implements Service,
ActiveStateChangeHandl
@Inject
public NotificationHookConsumer(NotificationInterface
notificationInterface, AtlasEntityStore atlasEntityStore, ServiceState
serviceState, AtlasInstanceConverter instanceConverter, AtlasTypeRegistry
typeRegistry, AtlasMetricsUtil metricsUtil, EntityCorrelationStore
entityCorrelationStore, @Lazy AsyncImporter asyncImporter) throws
AtlasException {
+ this(notificationInterface, atlasEntityStore, serviceState,
instanceConverter, typeRegistry, metricsUtil, entityCorrelationStore,
asyncImporter, null);
+ }
+
+ public NotificationHookConsumer(NotificationInterface
notificationInterface, AtlasEntityStore atlasEntityStore, ServiceState
serviceState, AtlasInstanceConverter instanceConverter, AtlasTypeRegistry
typeRegistry, AtlasMetricsUtil metricsUtil, EntityCorrelationStore
entityCorrelationStore, @Lazy AsyncImporter asyncImporter,
AtlasTypeDefGraphStore typeDefStore) throws AtlasException {
this.notificationInterface = notificationInterface;
this.atlasEntityStore = atlasEntityStore;
this.serviceState = serviceState;
@@ -242,6 +251,8 @@ public class NotificationHookConsumer implements Service,
ActiveStateChangeHandl
this.metricsUtil = metricsUtil;
this.lastCommittedPartitionOffset = new HashMap<>();
this.asyncImporter = asyncImporter;
+ this.typeDefStore = typeDefStore;
+ this.parallelProcessingEnabled =
AtlasConfiguration.ATLAS_PARALLEL_PROCESSING_ENABLED.getBoolean();
maxRetries =
applicationProperties.getInt(CONSUMER_RETRIES_PROPERTY, 3);
failedMsgCacheSize =
applicationProperties.getInt(CONSUMER_FAILEDCACHESIZE_PROPERTY, 1);
@@ -543,9 +554,35 @@ public class NotificationHookConsumer implements Service,
ActiveStateChangeHandl
hookConsumers.add(hookConsumer);
}
+ if (parallelProcessingEnabled) {
+ hookConsumers.addAll(getPreprocessorHookConsumers());
+ }
+
startConsumers(hookConsumers);
}
+ List<HookConsumer> getPreprocessorHookConsumers() {
+ List<NotificationConsumer<HookNotification>> notificationConsumers =
notificationInterface.createConsumers(NotificationType.HOOK_PREPROCESS, 1);
+ List<HookConsumer> hookConsumers =
new ArrayList<>();
+
+ for (final NotificationConsumer<HookNotification> consumer :
notificationConsumers) {
+ NotificationPreProcessor processor = new
NotificationPreProcessor(applicationProperties, metricsUtil, typeRegistry,
FAILED_LOG);
+
+ if (typeDefStore != null) {
+ typeDefStore.registerTypeDefChangeListener(processor);
+ LOG.info("Registered NotificationPreProcessor with
AtlasTypeDefStore for type registry updates");
+ } else {
+ LOG.warn("AtlasTypeDefStore is null, NotificationPreProcessor
will not receive type registry updates");
+ }
+
+ HookConsumer hookConsumer = new
HookConsumer(ATLAS_HOOK_PRE_PROCESSOR_CONSUMER_THREAD_NAME, consumer,
processor);
+
+ hookConsumers.add(hookConsumer);
+ }
+
+ return hookConsumers;
+ }
+
public void startAsyncImportConsumer(NotificationType notificationType,
String importId, String topic) throws AtlasBaseException {
if (topic != null) {
notificationInterface.addTopicToNotificationType(notificationType,
topic);
@@ -1121,6 +1158,7 @@ public class NotificationHookConsumer implements Service,
ActiveStateChangeHandl
class HookConsumer extends Thread {
private final NotificationConsumer<HookNotification> consumer;
private final AtomicBoolean shouldRun =
new AtomicBoolean(false);
+ private final NotificationEntityProcessor entityProcessor;
private final List<String> failedMessages =
new ArrayList<>();
private final AdaptiveWaiter adaptiveWaiter =
new AdaptiveWaiter(minWaitDuration, maxWaitDuration, minWaitDuration);
@@ -1129,13 +1167,22 @@ public class NotificationHookConsumer implements
Service, ActiveStateChangeHandl
public HookConsumer(NotificationConsumer<HookNotification> consumer) {
super(ATLAS_HOOK_CONSUMER_THREAD_NAME);
- this.consumer = consumer;
+ this.consumer = consumer;
+ this.entityProcessor = null;
}
public HookConsumer(String consumerThreadName,
NotificationConsumer<HookNotification> consumer) {
super(consumerThreadName);
- this.consumer = consumer;
+ this.consumer = consumer;
+ this.entityProcessor = null;
+ }
+
+ public HookConsumer(String consumerThreadName,
NotificationConsumer<HookNotification> consumer, NotificationEntityProcessor
entityProcessor) {
+ super(consumerThreadName);
+
+ this.consumer = consumer;
+ this.entityProcessor = entityProcessor;
}
@Override
@@ -1243,6 +1290,12 @@ public class NotificationHookConsumer implements
Service, ActiveStateChangeHandl
@VisibleForTesting
void handleMessage(AtlasKafkaMessage<HookNotification> kafkaMsg) {
+ if (entityProcessor != null) {
+ TopicPartitionOffsetResult result =
entityProcessor.handleMessage(kafkaMsg);
+ commit(result);
+ return;
+ }
+
AtlasPerfTracer perf = null;
HookNotification message = kafkaMsg.getMessage();
String messageUser = message.getUser();
@@ -1683,6 +1736,20 @@ public class NotificationHookConsumer implements
Service, ActiveStateChangeHandl
failedMessages.clear();
}
+ private void commit(TopicPartitionOffsetResult result) {
+ if (result != null) {
+ if
(!lastCommittedPartitionOffset.containsKey(result.getTopicPartition())
+ ||
(lastCommittedPartitionOffset.containsKey(result.getTopicPartition())
+ &&
lastCommittedPartitionOffset.get(result.getTopicPartition()) != null
+ &&
lastCommittedPartitionOffset.get(result.getTopicPartition()) !=
result.getOffset())) {
+ LOG.info("Committing the result: {}", result.getKey());
+ commit(result.getTopicPartition(), result.getOffset());
+ } else {
+ consumer.poll();
+ }
+ }
+ }
+
private void commit(AtlasKafkaMessage<HookNotification> kafkaMessage) {
recordFailedMessages();
@@ -1692,5 +1759,14 @@ public class NotificationHookConsumer implements
Service, ActiveStateChangeHandl
consumer.commit(kafkaMessage.getTopicPartition(), commitOffset);
}
+
+ private void commit(TopicPartition topicPartition, long commitOffset) {
+ long offsetToCommit = commitOffset + 1;
+ consumer.commit(topicPartition, offsetToCommit);
+ lastCommittedPartitionOffset.put(topicPartition, commitOffset);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Committing: topicPartition: {} with offset: {}",
topicPartition, offsetToCommit);
+ }
+ }
}
}
diff --git
a/webapp/src/test/java/org/apache/atlas/web/filters/AtlasJwtAuthWrapperTest.java
b/webapp/src/test/java/org/apache/atlas/web/filters/AtlasJwtAuthWrapperTest.java
index d9d1d5a0d2..b6b7e8208f 100644
---
a/webapp/src/test/java/org/apache/atlas/web/filters/AtlasJwtAuthWrapperTest.java
+++
b/webapp/src/test/java/org/apache/atlas/web/filters/AtlasJwtAuthWrapperTest.java
@@ -18,6 +18,7 @@
*/
package org.apache.atlas.web.filters;
+import org.apache.atlas.server.common.filters.AtlasKnoxSSOAuthenticationFilter;
import org.apache.commons.configuration2.Configuration;
import org.mockito.Mockito;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
diff --git
a/webapp/src/test/java/org/apache/atlas/web/security/AtlasSecurityConfigTest.java
b/webapp/src/test/java/org/apache/atlas/web/security/AtlasSecurityConfigTest.java
index fb65167d0a..9b730ce304 100644
---
a/webapp/src/test/java/org/apache/atlas/web/security/AtlasSecurityConfigTest.java
+++
b/webapp/src/test/java/org/apache/atlas/web/security/AtlasSecurityConfigTest.java
@@ -131,6 +131,12 @@ public class AtlasSecurityConfigTest {
@Mock
private StaleTransactionCleanupFilter mockStaleTransactionCleanupFilter;
+ @Mock
+ private AtlasHeaderPreAuthFilter mockHeaderPreAuthFilter;
+
+ @Mock
+ private AtlasJwtAuthWrapper mockAtlasJwtAuthWrapper;
+
@Mock
private ActiveServerFilter mockActiveServerFilter;
@@ -177,7 +183,9 @@ public class AtlasSecurityConfigTest {
mockAtlasAuthenticationEntryPoint,
mockConfiguration,
objectProvider(mockActiveServerFilter),
- objectProvider(mockStaleTransactionCleanupFilter));
+ objectProvider(mockStaleTransactionCleanupFilter),
+ mockHeaderPreAuthFilter,
+ mockAtlasJwtAuthWrapper);
}
@Test
@@ -467,8 +475,10 @@ public class AtlasSecurityConfigTest {
}
// Verify standard filters are always added
+ verify(freshHttpSecurity,
atLeastOnce()).addFilterBefore(eq(mockHeaderPreAuthFilter), any());
+ verify(freshHttpSecurity,
atLeastOnce()).addFilterAfter(eq(mockSsoAuthenticationFilter),
eq(AtlasHeaderPreAuthFilter.class));
+ verify(freshHttpSecurity,
atLeastOnce()).addFilterAfter(eq(mockAtlasJwtAuthWrapper),
eq(AtlasKnoxSSOAuthenticationFilter.class));
verify(freshHttpSecurity,
atLeastOnce()).addFilterAfter(eq(mockStaleTransactionCleanupFilter), any());
- verify(freshHttpSecurity,
atLeastOnce()).addFilterBefore(eq(mockSsoAuthenticationFilter), any());
verify(freshHttpSecurity,
atLeastOnce()).addFilterAfter(eq(mockAtlasAuthenticationFilter), any());
verify(freshHttpSecurity,
atLeastOnce()).addFilterAfter(eq(mockCsrfPreventionFilter), any());
@@ -797,7 +807,9 @@ public class AtlasSecurityConfigTest {
AtlasAuthenticationEntryPoint.class,
Configuration.class,
ObjectProvider.class,
- ObjectProvider.class
+ ObjectProvider.class,
+ AtlasHeaderPreAuthFilter.class,
+ AtlasJwtAuthWrapper.class
).getAnnotation(Inject.class);
assertNotNull(injectAnnotation);
}