ulysses-you commented on a change in pull request #1378:
URL: https://github.com/apache/incubator-kyuubi/pull/1378#discussion_r753956950



##########
File path: 
kyuubi-server/src/main/scala/org/apache/kyuubi/events/KyuubiServerInfoEvent.scala
##########
@@ -0,0 +1,78 @@
+/*
+ * 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
+
+import org.apache.kyuubi.Utils
+import org.apache.kyuubi.server.KyuubiServer
+import org.apache.kyuubi.service.ServiceState
+
+/**
+ * A [[KyuubiServerInfoEvent]] is used to get server level info when 
KyuubiServer start or stop
+ *
+ * @param serverName the server name
+ * @param startTime the time when the server started
+ * @param eventTime the time when the event made
+ * @param state the server states
+ * @param serverIP the server ip
+ * @param serverConf the server config
+ * @param serverEnv the server environment
+ */
+case class KyuubiServerInfoEvent private(
+    serverName: String,
+    startTime: Long,
+    eventTime: Long,
+    state: String,
+    serverIP: String,
+    serverConf: Map[String, String],
+    serverEnv: Map[String, String]) extends KyuubiServerEvent {
+
+  val BUILD_USER: String = kyuubi.BUILD_USER
+  val BUILD_DATE: String = kyuubi.BUILD_DATE
+  val REPO_URL: String = kyuubi.REPO_URL
+
+  val VERSION_INFO = Map(
+    "KYUUBI_VERSION"         -> kyuubi.KYUUBI_VERSION,
+    "JAVA_COMPILE_VERSION"   -> kyuubi.JAVA_COMPILE_VERSION,
+    "SCALA_COMPILE_VERSION"  -> kyuubi.SCALA_COMPILE_VERSION,
+    "SPARK_COMPILE_VERSION"  -> kyuubi.SPARK_COMPILE_VERSION,
+    "HIVE_COMPILE_VERSION"   -> kyuubi.HIVE_COMPILE_VERSION,
+    "HADOOP_COMPILE_VERSION" -> kyuubi.HADOOP_COMPILE_VERSION)
+
+  override def partitions: Seq[(String, String)] =
+    ("day", Utils.getDateFromTimestamp(startTime)) :: Nil
+}
+
+object KyuubiServerInfoEvent {
+  def apply(server: KyuubiServer, state: ServiceState.ServiceState): 
KyuubiServerInfoEvent = {
+    server.getServiceState match {
+      // Only server is started that we can log event
+      case ServiceState.STARTED =>

Review comment:
       we can `assert(server.getServiceState == ServiceState.STARTED)` at 
first, otherwise return null is dangerous.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to