diff --git a/pinot-broker/pom.xml b/pinot-broker/pom.xml
index 28d3143c51b..771780bcc53 100644
--- a/pinot-broker/pom.xml
+++ b/pinot-broker/pom.xml
@@ -152,12 +152,6 @@
testng
test
-
- org.apache.pinot
- pinot-query-event-listener
- ${project.version}
- test
-
org.mockito
mockito-core
diff --git a/pinot-distribution/pinot-assembly.xml b/pinot-distribution/pinot-assembly.xml
index 08420c63e76..73aefa1c110 100644
--- a/pinot-distribution/pinot-assembly.xml
+++ b/pinot-distribution/pinot-assembly.xml
@@ -209,13 +209,6 @@
plugins/pinot-metrics/pinot-dropwizard/pinot-dropwizard-${project.version}-shaded.jar
-
-
-
- plugins/pinot-query-event-listener/pinot-query-event-listener-${project.version}.jar
-
-
-
- org.apache.pinot
- pinot-query-event-listener
- ${project.version}
-
org.testng
testng
diff --git a/pinot-integration-tests/pom.xml b/pinot-integration-tests/pom.xml
index 51bec0cf7b5..f7f3acd4dd1 100644
--- a/pinot-integration-tests/pom.xml
+++ b/pinot-integration-tests/pom.xml
@@ -339,11 +339,6 @@
${project.version}
test
-
- org.apache.pinot
- pinot-query-event-listener
- ${project.version}
-
org.testcontainers
testcontainers
diff --git a/pinot-plugins/pinot-query-event-listener/pom.xml b/pinot-plugins/pinot-query-event-listener/pom.xml
deleted file mode 100644
index acad8d97497..00000000000
--- a/pinot-plugins/pinot-query-event-listener/pom.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
- 4.0.0
-
- pinot-plugins
- org.apache.pinot
- 0.13.0-SNAPSHOT
- ..
-
- pinot-query-event-listener
- Pinot Query Event Listener
- https://pinot.apache.org/
-
- ${basedir}/../..
- none
-
-
-
-
- org.apache.pinot
- pinot-spi
-
-
-
diff --git a/pinot-plugins/pinot-query-event-listener/src/main/java/org/apache/pinot/plugin/query/event/listener/broker/NoOpBrokerQueryEventListenerFactory.java b/pinot-plugins/pinot-query-event-listener/src/main/java/org/apache/pinot/plugin/query/event/listener/broker/NoOpBrokerQueryEventListenerFactory.java
deleted file mode 100644
index 9b350d4a50b..00000000000
--- a/pinot-plugins/pinot-query-event-listener/src/main/java/org/apache/pinot/plugin/query/event/listener/broker/NoOpBrokerQueryEventListenerFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.pinot.plugin.query.event.listener.broker;
-
-import org.apache.pinot.spi.annotations.queryeventlistener.BrokerEventListenerFactory;
-import org.apache.pinot.spi.annotations.queryeventlistener.BrokerQueryEventListenerFactory;
-import org.apache.pinot.spi.env.PinotConfiguration;
-import org.apache.pinot.spi.queryeventlistener.BrokerQueryEventListener;
-
-@BrokerEventListenerFactory
-public class NoOpBrokerQueryEventListenerFactory implements BrokerQueryEventListenerFactory {
-
- private BrokerQueryEventListener _brokerQueryEventListener = null;
-
- @Override
- public void init(PinotConfiguration eventListenerConfiguration) {
- }
-
- @Override
- public BrokerQueryEventListener getBrokerQueryEventListener() {
- if (_brokerQueryEventListener == null) {
- _brokerQueryEventListener = new NoOpBrokerQueryEventListener();
- }
- return _brokerQueryEventListener;
- }
-
- @Override
- public String getEventListenerFactoryName() {
- return "NoOpBrokerEventListenerFactory";
- }
-}
diff --git a/pinot-plugins/pom.xml b/pinot-plugins/pom.xml
index 9d0af055b04..a2e0e29596e 100644
--- a/pinot-plugins/pom.xml
+++ b/pinot-plugins/pom.xml
@@ -50,7 +50,6 @@
pinot-segment-writer
pinot-segment-uploader
pinot-environment
- pinot-query-event-listener
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/annotations/queryeventlistener/BrokerEventListenerFactory.java b/pinot-spi/src/main/java/org/apache/pinot/spi/annotations/queryeventlistener/BrokerEventListenerFactory.java
deleted file mode 100644
index b49a76d048a..00000000000
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/annotations/queryeventlistener/BrokerEventListenerFactory.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.pinot.spi.annotations.queryeventlistener;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-public @interface BrokerEventListenerFactory {
-
- boolean enabled() default true;
-}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/annotations/queryeventlistener/BrokerQueryEventListenerFactory.java b/pinot-spi/src/main/java/org/apache/pinot/spi/annotations/queryeventlistener/BrokerQueryEventListenerFactory.java
deleted file mode 100644
index 7fda60a50b8..00000000000
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/annotations/queryeventlistener/BrokerQueryEventListenerFactory.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.pinot.spi.annotations.queryeventlistener;
-
-import org.apache.pinot.spi.env.PinotConfiguration;
-import org.apache.pinot.spi.queryeventlistener.BrokerQueryEventListener;
-
-public interface BrokerQueryEventListenerFactory {
-
- /**
- * Initializes the broker query event listener factory
- */
- void init(PinotConfiguration eventListenerConfiguration);
-
- /**
- * Gets {@link BrokerQueryEventListener}. There should be only one such instance in every
- * {@link BrokerQueryEventListener}.
- */
- BrokerQueryEventListener getBrokerQueryEventListener();
-
- String getEventListenerFactoryName();
-}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/BrokerQueryEventInfo.java b/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/BrokerQueryEventInfo.java
index ebed55050c5..9d228e28880 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/BrokerQueryEventInfo.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/BrokerQueryEventInfo.java
@@ -23,6 +23,7 @@
import java.util.List;
import org.apache.pinot.spi.trace.RequestContext;
+
public class BrokerQueryEventInfo {
private String _requestId;
private String _brokerId;
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/BrokerQueryEventListener.java b/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/BrokerQueryEventListener.java
index 5e3a100480f..6ae23c3078e 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/BrokerQueryEventListener.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/BrokerQueryEventListener.java
@@ -18,6 +18,7 @@
*/
package org.apache.pinot.spi.queryeventlistener;
+
public interface BrokerQueryEventListener {
void onQueryCompletion(BrokerQueryEventInfo brokerQueryEventInfo);
diff --git a/pinot-plugins/pinot-query-event-listener/src/main/java/org/apache/pinot/plugin/query/event/listener/broker/NoOpBrokerQueryEventListener.java b/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/NoOpBrokerQueryEventListener.java
similarity index 73%
rename from pinot-plugins/pinot-query-event-listener/src/main/java/org/apache/pinot/plugin/query/event/listener/broker/NoOpBrokerQueryEventListener.java
rename to pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/NoOpBrokerQueryEventListener.java
index 8d841855065..8bc0b9f2398 100644
--- a/pinot-plugins/pinot-query-event-listener/src/main/java/org/apache/pinot/plugin/query/event/listener/broker/NoOpBrokerQueryEventListener.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/NoOpBrokerQueryEventListener.java
@@ -16,16 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.pinot.plugin.query.event.listener.broker;
-
-import org.apache.pinot.spi.queryeventlistener.BrokerQueryEventInfo;
-import org.apache.pinot.spi.queryeventlistener.BrokerQueryEventListener;
+package org.apache.pinot.spi.queryeventlistener;
public class NoOpBrokerQueryEventListener implements BrokerQueryEventListener {
- @Override
- public void onQueryCompletion(BrokerQueryEventInfo brokerQueryEventInfo) {
- // Not implemented method
- }
+ @Override
+ public void onQueryCompletion(BrokerQueryEventInfo brokerQueryEventInfo) {
+ // Not implemented method
+ }
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/PinotBrokerQueryEventListenerUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/PinotBrokerQueryEventListenerUtils.java
index a29d2beb71e..24cce9d0bdb 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/PinotBrokerQueryEventListenerUtils.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/queryeventlistener/PinotBrokerQueryEventListenerUtils.java
@@ -22,106 +22,90 @@
import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.Optional;
-import java.util.Set;
-import org.apache.pinot.spi.annotations.queryeventlistener.BrokerEventListenerFactory;
-import org.apache.pinot.spi.annotations.queryeventlistener.BrokerQueryEventListenerFactory;
import org.apache.pinot.spi.env.PinotConfiguration;
-import org.apache.pinot.spi.utils.PinotReflectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.pinot.spi.utils.CommonConstants.CONFIG_OF_EVENT_LISTENER_FACTORY_CLASS_NAME;
-import static org.apache.pinot.spi.utils.CommonConstants.DEFAULT_EVENT_LISTENER_FACTORY_CLASS_NAME;
+import static org.apache.pinot.spi.utils.CommonConstants.CONFIG_OF_BROKER_EVENT_LISTENER_CLASS_NAME;
+import static org.apache.pinot.spi.utils.CommonConstants.DEFAULT_BROKER_EVENT_LISTENER_CLASS_NAME;
+
public class PinotBrokerQueryEventListenerUtils {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PinotBrokerQueryEventListenerUtils.class);
+ private static BrokerQueryEventListener _brokerQueryEventListener = null;
+
private PinotBrokerQueryEventListenerUtils() {
}
- private static final Logger LOGGER = LoggerFactory.getLogger(PinotBrokerQueryEventListenerUtils.class);
- private static final String EVENT_LISTENER_PACKAGE_REGEX_PATTERN = ".*\\.plugin\\.query.event.listener\\..*";
- private static BrokerQueryEventListenerFactory _brokerQueryEventListenerFactory = null;
-
/**
- * Initialize the eventListenerFactory and registers the eventListener
+ * Initialize the BrokerQueryEventListener and registers the eventListener
*/
@VisibleForTesting
public synchronized static void init(PinotConfiguration eventListenerConfiguration) {
- // Initializes PinotQueryEventListenerFactory.
- initializeBrokerQueryEventListenerFactory(eventListenerConfiguration);
+ // Initializes BrokerQueryEventListener.
+ initializeBrokerQueryEventListener(eventListenerConfiguration);
}
/**
- * Initializes PinotQueryEventListenerFactory with event-listener configurations.
+ * Initializes PinotBrokerQueryEventListener with event-listener configurations.
* @param eventListenerConfiguration The subset of the configuration containing the event-listener-related keys
*/
- private static void initializeBrokerQueryEventListenerFactory(PinotConfiguration eventListenerConfiguration) {
- Set> classes = getPinotBrokerQueryEventListenerFactoryClasses();
- if (classes.size() > 1) {
- LOGGER.warn("More than one BrokerQueryEventListenerFactory was found: {}", classes);
- }
-
- String brokerQueryEventFactoryClassName = eventListenerConfiguration.getProperty(
- CONFIG_OF_EVENT_LISTENER_FACTORY_CLASS_NAME, DEFAULT_EVENT_LISTENER_FACTORY_CLASS_NAME);
- LOGGER.info("{} will be initialized as the PinotBrokerQueryEventListenerFactory",
- brokerQueryEventFactoryClassName);
+ private static void initializeBrokerQueryEventListener(PinotConfiguration eventListenerConfiguration) {
+ String brokerQueryEventListenerClassName = eventListenerConfiguration.getProperty(
+ CONFIG_OF_BROKER_EVENT_LISTENER_CLASS_NAME, DEFAULT_BROKER_EVENT_LISTENER_CLASS_NAME);
+ LOGGER.info("{} will be initialized as the PinotBrokerQueryEventListener",
+ brokerQueryEventListenerClassName);
- Optional> clazzFound = classes.stream().filter(c -> c.getName()
- .equals(brokerQueryEventFactoryClassName)).findFirst();
+ Optional> clazzFound;
+ try {
+ clazzFound = Optional.of(Class.forName(brokerQueryEventListenerClassName));
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Failed to initialize BrokerQueryEventListener. "
+ + "Please check if any pinot-event-listener related jar is actually added to the classpath.");
+ }
clazzFound.ifPresent(clazz -> {
- BrokerEventListenerFactory annotation = clazz.getAnnotation(BrokerEventListenerFactory.class);
- LOGGER.info("Trying to init PinotBrokerQueryEventListenerFactory: {} "
- + "and BrokerQueryEventListenerFactory: {}", clazz, annotation);
- if (annotation.enabled()) {
- try {
- BrokerQueryEventListenerFactory brokerQueryEventListenerFactory =
- (BrokerQueryEventListenerFactory) clazz.newInstance();
- brokerQueryEventListenerFactory.init(eventListenerConfiguration);
- registerBrokerEventListenerFactory(brokerQueryEventListenerFactory);
- } catch (Exception e) {
- LOGGER.error("Caught exception while initializing event listener registry: {}, skipping it",
- clazz, e);
- }
+ try {
+ BrokerQueryEventListener brokerQueryEventListener =
+ (BrokerQueryEventListener) clazz.newInstance();
+ registerBrokerEventListener(brokerQueryEventListener);
+ } catch (Exception e) {
+ LOGGER.error("Caught exception while initializing event listener registry: {}, skipping it",
+ clazz, e);
}
}
);
- Preconditions.checkState(_brokerQueryEventListenerFactory != null,
- "Failed to initialize BrokerQueryEventListenerFactory. "
+ Preconditions.checkState(_brokerQueryEventListener != null,
+ "Failed to initialize BrokerQueryEventListener. "
+ "Please check if any pinot-event-listener related jar is actually added to the classpath.");
}
/**
- * Registers an broker event listener factory.
+ * Registers an broker event listener.
*/
- private static void registerBrokerEventListenerFactory(
- BrokerQueryEventListenerFactory brokerQueryEventListenerFactory) {
- LOGGER.info("Registering broker event listener factory: {}",
- brokerQueryEventListenerFactory.getEventListenerFactoryName());
- _brokerQueryEventListenerFactory = brokerQueryEventListenerFactory;
+ private static void registerBrokerEventListener(
+ BrokerQueryEventListener brokerQueryEventListener) {
+ LOGGER.info("Registering broker event listener : {}",
+ brokerQueryEventListener.getClass().getName());
+ _brokerQueryEventListener = brokerQueryEventListener;
}
/**
- * Returns the brokerQueryEventListener from the initialised BrokerQueryEventListenerFactory.
- * If the BrokerQueryEventListenerFactory is null, first creates and initializes the
- * BrokerQueryEventListenerFactory and registers the BrokerQueryEventListener.
+ * Returns the brokerQueryEventListener. If the BrokerQueryEventListener is null,
+ * first creates and initializes the BrokerQueryEventListener.
* @param eventListenerConfiguration event-listener configs
*/
public static synchronized BrokerQueryEventListener getBrokerQueryEventListener(
PinotConfiguration eventListenerConfiguration) {
- if (_brokerQueryEventListenerFactory == null) {
+ if (_brokerQueryEventListener == null) {
init(eventListenerConfiguration);
}
- return _brokerQueryEventListenerFactory.getBrokerQueryEventListener();
+ return _brokerQueryEventListener;
}
@VisibleForTesting
public static BrokerQueryEventListener getBrokerQueryEventListener() {
return getBrokerQueryEventListener(new PinotConfiguration(Collections.emptyMap()));
}
-
- private static Set> getPinotBrokerQueryEventListenerFactoryClasses() {
- return PinotReflectionUtils.getClassesThroughReflection(EVENT_LISTENER_PACKAGE_REGEX_PATTERN,
- BrokerEventListenerFactory.class);
- }
}
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
index 048667d8f34..988751d687e 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java
@@ -42,11 +42,11 @@ private CommonConstants() {
public static final String UNKNOWN = "unknown";
public static final String CONFIG_OF_METRICS_FACTORY_CLASS_NAME = "factory.className";
- public static final String CONFIG_OF_EVENT_LISTENER_FACTORY_CLASS_NAME = "factory.className";
+ public static final String CONFIG_OF_BROKER_EVENT_LISTENER_CLASS_NAME = "factory.className";
public static final String DEFAULT_METRICS_FACTORY_CLASS_NAME =
"org.apache.pinot.plugin.metrics.yammer.YammerMetricsFactory";
- public static final String DEFAULT_EVENT_LISTENER_FACTORY_CLASS_NAME =
- "org.apache.pinot.plugin.query.event.listener.broker.NoOpBrokerQueryEventListenerFactory";
+ public static final String DEFAULT_BROKER_EVENT_LISTENER_CLASS_NAME =
+ "org.apache.pinot.spi.queryeventlistener.NoOpBrokerQueryEventListener";
public static final String SWAGGER_AUTHORIZATION_KEY = "oauth";
public static final String CONFIG_OF_SWAGGER_RESOURCES_PATH = "META-INF/resources/webjars/swagger-ui/5.1.0/";
diff --git a/pinot-tools/pom.xml b/pinot-tools/pom.xml
index e54517e65c6..021e3839068 100644
--- a/pinot-tools/pom.xml
+++ b/pinot-tools/pom.xml
@@ -230,11 +230,6 @@
${project.version}
runtime
-
- org.apache.pinot
- pinot-query-event-listener
- ${project.version}
-
commons-cli
commons-cli