You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by GitBox <gi...@apache.org> on 2021/08/24 09:32:39 UTC

[GitHub] [incubator-kyuubi] hddong commented on a change in pull request #968: [KYUUBI #922] Add OperationEvent for server to track operation state

hddong commented on a change in pull request #968:
URL: https://github.com/apache/incubator-kyuubi/pull/968#discussion_r694683190



##########
File path: kyuubi-server/src/main/scala/org/apache/kyuubi/events/StatementEvent.scala
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.Utils
+import org.apache.kyuubi.operation.ExecuteStatement
+import org.apache.kyuubi.operation.OperationState.OperationState
+
+/**
+ *
+ * @param user: who connect to kyuubi server
+ * @param statementId: the identifier of operationHandler
+ * @param statement: the sql that you execute
+ * @param remoteIp: the ip of user
+ * @param sessionId: the identifier of a session
+ * @param createTime: the create time of this statement
+ * @param state: store each state that the sql has
+ * @param stateTime: the time that the sql's state change
+ * @param exception: caught exception if have
+ */
+case class StatementEvent(

Review comment:
       > This event type is conflict with engine's `StatementEvent` if we write into same path.
   
   `StatementEvent` is a path too, they have differnet file name under `statement`. 
   And add a check for this case. 
   ```
   ll /var/folders/xl/jv1jvw6s6hv42ht1ty6gnk100000gn/T/kyuubi-bb4a5f34-451c-4783-9f50-1906889386cf/statement/day=20210824/
   -rw-rw----  1 *  staff  9472 Aug 24 16:27 local-1629793620908.json
   -rw-rw----  1 *  staff  3588 Aug 24 16:27 server-172.20.144.37.json
   ```

##########
File path: kyuubi-common/src/main/scala/org/apache/kyuubi/events/EventLoggingService.scala
##########
@@ -0,0 +1,53 @@
+/*
+ * 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 scala.collection.mutable.ArrayBuffer
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.events.EventLoggerType.EventLoggerType
+import org.apache.kyuubi.service.CompositeService
+
+abstract class AbstractEventLoggingService[T <: KyuubiEvent]
+  extends CompositeService("EventLogging") {
+
+  private val eventLoggers = new ArrayBuffer[EventLogger[T]]()
+
+  /**
+   * Get configured event log type.
+   */
+  protected def getLoggers(conf: KyuubiConf): Seq[EventLoggerType]
+
+  def onEvent(event: T): Unit = {
+    eventLoggers.foreach(_.logEvent(event))
+  }
+
+  override def initialize(conf: KyuubiConf): Unit = {
+    getLoggers(conf).foreach(analyseEventLoggerType)

Review comment:
       yeah, change to override `initialize`.




-- 
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: commits-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org