You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/08/17 11:59:02 UTC
[GitHub] [incubator-kyuubi] zhaomin1423 opened a new pull request, #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
zhaomin1423 opened a new pull request, #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261
<!--
Thanks for sending a pull request!
Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
-->
### _Why are the changes needed?_
<!--
Please clarify why the changes are needed. For instance,
1. If you add a feature, you can talk about the use case of it.
2. If you fix a bug, you can clarify why it is a bug.
-->
close https://github.com/apache/incubator-kyuubi/issues/3089#issue-1306657936
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] zhaomin1423 commented on pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
zhaomin1423 commented on PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#issuecomment-1219154687
> doc needed
here: https://github.com/apache/incubator-kyuubi/pull/3179
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r947874086
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/CustomEventHandlerProvider.scala:
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.kyuubi.events.handler
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+trait CustomEventHandlerProvider {
+
+ def create(kyuubiConf: KyuubiConf): EventHandler[KyuubiEvent]
Review Comment:
cc @yaooqinn
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r949945253
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/CustomEventHandlerProvider.scala:
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.kyuubi.events.handler
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+trait CustomEventHandlerProvider {
Review Comment:
please add some comments since it's a developer api
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] zhaomin1423 commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
zhaomin1423 commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r947949487
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/EventHandlerLoader.scala:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.kyuubi.events.handler
+
+import java.util.ServiceLoader
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+object EventHandlerLoader {
+
+ def loadCustom(kyuubiConf: KyuubiConf): List[EventHandler[KyuubiEvent]] = {
+ val providers = ArrayBuffer[CustomEventHandlerProvider]()
+ ServiceLoader.load(
+ classOf[CustomEventHandlerProvider],
+ Thread.currentThread().getContextClassLoader)
+ .iterator()
+ .asScala
+ .foreach(provider => providers += provider)
+
+ providers.map(_.create(kyuubiConf)).toList
Review Comment:
It will continue to throw it to the method of loadEventhandler. should we catch it?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] zhaomin1423 commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
zhaomin1423 commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r948622254
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/EventHandlerLoader.scala:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.kyuubi.events.handler
+
+import java.util.ServiceLoader
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+object EventHandlerLoader {
+
+ def loadCustom(kyuubiConf: KyuubiConf): List[EventHandler[KyuubiEvent]] = {
+ val providers = ArrayBuffer[CustomEventHandlerProvider]()
+ ServiceLoader.load(
+ classOf[CustomEventHandlerProvider],
+ Thread.currentThread().getContextClassLoader)
+ .iterator()
+ .asScala
+ .foreach(provider => providers += provider)
+
+ providers.map(_.create(kyuubiConf)).toList
Review Comment:
catch it and add a test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r951020974
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/CustomEventHandlerProvider.scala:
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.kyuubi.events.handler
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+trait CustomEventHandlerProvider {
Review Comment:
For developer api, is it better use Java interface rather than scala triat for the compatible with Java ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r949944753
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/EventHandlerLoader.scala:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.kyuubi.events.handler
+
+import java.util.ServiceLoader
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+import scala.util.{Failure, Success, Try}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+object EventHandlerLoader extends Logging {
+
+ def loadCustom(kyuubiConf: KyuubiConf): Seq[EventHandler[KyuubiEvent]] = {
+ val providers = ArrayBuffer[CustomEventHandlerProvider]()
+ ServiceLoader.load(
+ classOf[CustomEventHandlerProvider],
+ Thread.currentThread().getContextClassLoader)
+ .iterator()
+ .asScala
+ .foreach(provider => providers += provider)
+
+ providers.map { provider =>
+ Try {
+ provider.create(kyuubiConf)
+ } match {
+ case Success(value) =>
+ value
+ case Failure(exception) =>
+ warn(
+ s"Failed to create an EventHandler by the ${provider.toString}, it will be ignored.",
Review Comment:
`provider.toString` do you mean the class name ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r947869722
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/EventHandlerLoader.scala:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.kyuubi.events.handler
+
+import java.util.ServiceLoader
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+object EventHandlerLoader {
+
+ def loadCustom(kyuubiConf: KyuubiConf): List[EventHandler[KyuubiEvent]] = {
+ val providers = ArrayBuffer[CustomEventHandlerProvider]()
+ ServiceLoader.load(
+ classOf[CustomEventHandlerProvider],
+ Thread.currentThread().getContextClassLoader)
+ .iterator()
+ .asScala
+ .foreach(provider => providers += provider)
+
+ providers.map(_.create(kyuubiConf)).toList
Review Comment:
what happens if it throw exception
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#issuecomment-1225072237
thanks, merging to master for 1.7
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r951020421
##########
kyuubi-events/src/test/scala/org/apache/kyuubi/events/CustomEventHandlerSuite.scala:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.kyuubi.events
+
+import org.apache.kyuubi.{KyuubiException, KyuubiFunSuite}
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.config.KyuubiConf.ENGINE_EVENT_LOGGERS
+import org.apache.kyuubi.events.handler.{CustomEventHandlerProvider, EventHandler, EventHandlerLoader}
+
+class CustomEventHandlerSuite extends KyuubiFunSuite {
+
+ test("load custom event handler") {
+ val kyuubiConf = new KyuubiConf()
+ kyuubiConf.set(ENGINE_EVENT_LOGGERS.key, "custom")
+ val providers = EventHandlerLoader.loadCustom(kyuubiConf)
+ assert(providers.head.getClass === classOf[Fake1EventHandler])
+ assert(providers(1).getClass === classOf[Fake2EventHandler])
Review Comment:
nit: `assert(providers.size == 2)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r951021085
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/CustomEventHandlerProvider.scala:
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.kyuubi.events.handler
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+trait CustomEventHandlerProvider {
Review Comment:
and the docs should be java-like docs
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you closed pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you closed pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
URL: https://github.com/apache/incubator-kyuubi/pull/3261
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r948588679
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/EventHandlerLoader.scala:
##########
@@ -0,0 +1,40 @@
+/*
+ * 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.kyuubi.events.handler
+
+import java.util.ServiceLoader
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+object EventHandlerLoader {
+
+ def loadCustom(kyuubiConf: KyuubiConf): List[EventHandler[KyuubiEvent]] = {
+ val providers = ArrayBuffer[CustomEventHandlerProvider]()
+ ServiceLoader.load(
+ classOf[CustomEventHandlerProvider],
+ Thread.currentThread().getContextClassLoader)
+ .iterator()
+ .asScala
+ .foreach(provider => providers += provider)
+
+ providers.map(_.create(kyuubiConf)).toList
Review Comment:
according to the listener extension of Spark, it should be better not affect the engine if the plugin fails to initialize. we can catch it and add some logging.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r947861689
##########
kyuubi-events/src/test/scala/org/apache/kyuubi/events/CustomEventHandlerSuite.scala:
##########
@@ -0,0 +1,33 @@
+/*
+ * 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.kyuubi.events
+
+import org.apache.kyuubi.KyuubiFunSuite
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.config.KyuubiConf.ENGINE_EVENT_LOGGERS
+import org.apache.kyuubi.events.handler.EventHandlerLoader
+
+class CustomEventHandlerSuite extends KyuubiFunSuite {
Review Comment:
we can merge `Fake1EventHandlerProvider` and `Fake2EventHandlerProvider` into this file
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#issuecomment-1219115988
doc needed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] zhaomin1423 commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
zhaomin1423 commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r950212356
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/EventHandlerLoader.scala:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.kyuubi.events.handler
+
+import java.util.ServiceLoader
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+import scala.util.{Failure, Success, Try}
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+object EventHandlerLoader extends Logging {
+
+ def loadCustom(kyuubiConf: KyuubiConf): Seq[EventHandler[KyuubiEvent]] = {
+ val providers = ArrayBuffer[CustomEventHandlerProvider]()
+ ServiceLoader.load(
+ classOf[CustomEventHandlerProvider],
+ Thread.currentThread().getContextClassLoader)
+ .iterator()
+ .asScala
+ .foreach(provider => providers += provider)
+
+ providers.map { provider =>
+ Try {
+ provider.create(kyuubiConf)
+ } match {
+ case Success(value) =>
+ value
+ case Failure(exception) =>
+ warn(
+ s"Failed to create an EventHandler by the ${provider.toString}, it will be ignored.",
Review Comment:
yeah, update it to getClass.getName.
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/handler/CustomEventHandlerProvider.scala:
##########
@@ -0,0 +1,25 @@
+/*
+ * 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.kyuubi.events.handler
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.KyuubiEvent
+
+trait CustomEventHandlerProvider {
Review Comment:
added.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] zhaomin1423 commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
zhaomin1423 commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r952550848
##########
kyuubi-events/src/test/scala/org/apache/kyuubi/events/CustomEventHandlerSuite.scala:
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.kyuubi.events
+
+import org.apache.kyuubi.{KyuubiException, KyuubiFunSuite}
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.config.KyuubiConf.ENGINE_EVENT_LOGGERS
+import org.apache.kyuubi.events.handler.{CustomEventHandlerProvider, EventHandler, EventHandlerLoader}
+
+class CustomEventHandlerSuite extends KyuubiFunSuite {
+
+ test("load custom event handler") {
+ val kyuubiConf = new KyuubiConf()
+ kyuubiConf.set(ENGINE_EVENT_LOGGERS.key, "custom")
+ val providers = EventHandlerLoader.loadCustom(kyuubiConf)
+ assert(providers.head.getClass === classOf[Fake1EventHandler])
+ assert(providers(1).getClass === classOf[Fake2EventHandler])
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] codecov-commenter commented on pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#issuecomment-1217974292
# [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#3261](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (eb2c2cf) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/a3b6c6756781145f4a7a4f640d059a058ae21c3f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a3b6c67) will **increase** coverage by `0.00%`.
> The diff coverage is `80.00%`.
```diff
@@ Coverage Diff @@
## master #3261 +/- ##
=========================================
Coverage 51.24% 51.24%
Complexity 13 13
=========================================
Files 468 469 +1
Lines 26145 26156 +11
Branches 3627 3628 +1
=========================================
+ Hits 13398 13404 +6
Misses 11466 11466
- Partials 1281 1286 +5
```
| [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...rg/apache/kyuubi/events/EventHandlerRegister.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWV2ZW50cy9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9ldmVudHMvRXZlbnRIYW5kbGVyUmVnaXN0ZXIuc2NhbGE=) | `56.52% <57.14%> (-3.48%)` | :arrow_down: |
| [...che/kyuubi/events/handler/EventHandlerLoader.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWV2ZW50cy9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9ldmVudHMvaGFuZGxlci9FdmVudEhhbmRsZXJMb2FkZXIuc2NhbGE=) | `100.00% <100.00%> (ø)` | |
| [...rg/apache/kyuubi/ctl/cmd/log/LogBatchCommand.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWN0bC9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9jdGwvY21kL2xvZy9Mb2dCYXRjaENvbW1hbmQuc2NhbGE=) | `78.00% <0.00%> (-2.00%)` | :arrow_down: |
| [...ache/kyuubi/operation/KyuubiOperationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vS3l1dWJpT3BlcmF0aW9uTWFuYWdlci5zY2FsYQ==) | `80.82% <0.00%> (-1.37%)` | :arrow_down: |
| [...ain/scala/org/apache/kyuubi/engine/EngineRef.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvRW5naW5lUmVmLnNjYWxh) | `74.07% <0.00%> (-0.93%)` | :arrow_down: |
| [...he/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWhhL3NyYy9tYWluL3NjYWxhL29yZy9hcGFjaGUva3l1dWJpL2hhL2NsaWVudC9ldGNkL0V0Y2REaXNjb3ZlcnlDbGllbnQuc2NhbGE=) | `67.50% <0.00%> (-0.63%)` | :arrow_down: |
| [...a/org/apache/kyuubi/service/TFrontendService.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLWNvbW1vbi9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXJ2aWNlL1RGcm9udGVuZFNlcnZpY2Uuc2NhbGE=) | `91.17% <0.00%> (-0.30%)` | :arrow_down: |
| [...n/scala/org/apache/kyuubi/engine/ProcBuilder.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvUHJvY0J1aWxkZXIuc2NhbGE=) | `83.22% <0.00%> (+0.62%)` | :arrow_up: |
| [...apache/kyuubi/engine/JpsApplicationOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/3261/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvSnBzQXBwbGljYXRpb25PcGVyYXRpb24uc2NhbGE=) | `80.64% <0.00%> (+3.22%)` | :arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org
[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #3261: [KYUUBI #3089] [FEATURE] Support to load custom event handlers by ServiceLoader
Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #3261:
URL: https://github.com/apache/incubator-kyuubi/pull/3261#discussion_r947866348
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/EventHandlerRegister.scala:
##########
@@ -56,16 +57,19 @@ trait EventHandlerRegister extends Logging {
private def loadEventHandler(
eventLoggerType: EventLoggerType,
- kyuubiConf: KyuubiConf): EventHandler[KyuubiEvent] = {
+ kyuubiConf: KyuubiConf): List[EventHandler[KyuubiEvent]] = {
Review Comment:
`Seq[EventHandler[KyuubiEvent]]`
##########
kyuubi-events/src/main/scala/org/apache/kyuubi/events/EventHandlerRegister.scala:
##########
@@ -56,16 +57,19 @@ trait EventHandlerRegister extends Logging {
private def loadEventHandler(
eventLoggerType: EventLoggerType,
- kyuubiConf: KyuubiConf): EventHandler[KyuubiEvent] = {
+ kyuubiConf: KyuubiConf): List[EventHandler[KyuubiEvent]] = {
eventLoggerType match {
case EventLoggerType.SPARK =>
- createSparkEventHandler(kyuubiConf)
+ List[EventHandler[KyuubiEvent]](createSparkEventHandler(kyuubiConf))
Review Comment:
`createSparkEventHandler(kyuubiConf) :: Nil`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org