Revert "[KYUUBI #1000] Use underscore instead hyphen in path"

This reverts commit 92c2ebcbf3.
This commit is contained in:
ulysses-you 2021-08-30 17:09:16 +08:00
parent 92c2ebcbf3
commit 7cef74e85d
2 changed files with 0 additions and 140 deletions

View File

@ -1,32 +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.kyuubi.events
import java.util.Locale
trait KyuubiEvent extends Product {
final lazy val eventType: String = {
this.getClass.getSimpleName.stripSuffix("Event")
.replaceAll("(.)([A-Z])", "$1_$2")
.toLowerCase(Locale.ROOT)
}
def partitions: Seq[(String, String)]
final def toJson: String = JsonProtocol.productToJson(this)
}

View File

@ -1,108 +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.kyuubi.events
import java.net.InetAddress
import java.nio.file.Paths
import org.apache.kyuubi.{Utils, WithKyuubiServer}
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.operation.JDBCTestUtils
import org.apache.kyuubi.operation.OperationState._
class EventLoggingServiceSuite extends WithKyuubiServer with JDBCTestUtils {
private val logRoot = Utils.createTempDir()
private val currentDate = Utils.getDateFromTimestamp(System.currentTimeMillis())
override protected val conf: KyuubiConf = {
KyuubiConf()
.set(KyuubiConf.SERVER_EVENT_LOGGERS, Seq("JSON"))
.set(KyuubiConf.SERVER_EVENT_JSON_LOG_PATH, logRoot.toString)
.set(KyuubiConf.ENGINE_EVENT_LOGGERS, Seq("JSON"))
.set(KyuubiConf.ENGINE_EVENT_JSON_LOG_PATH, logRoot.toString)
}
override protected def jdbcUrl: String = getJdbcUrl
test("statementEvent: generate, dump and query") {
val hostName = InetAddress.getLocalHost.getCanonicalHostName
val serverStatementEventPath =
Paths.get(logRoot.toString, "kyuubi_statement", s"day=$currentDate", s"server-$hostName.json")
val engineStatementEventPath =
Paths.get(logRoot.toString, "spark_statement", s"day=$currentDate", "*.json")
val sql = "select timestamp'2021-06-01'"
withJdbcStatement() { statement =>
statement.execute(sql)
// check server statement events
val serverTable = serverStatementEventPath.getParent
val resultSet = statement.executeQuery(s"SELECT * FROM `json`.`${serverTable}`" +
"where statement = \"" + sql + "\"")
val states = Array(INITIALIZED, PENDING, RUNNING, FINISHED, CLOSED)
var stateIndex = 0
while (resultSet.next()) {
assert(resultSet.getString("user") == Utils.currentUser)
assert(resultSet.getString("statement") == sql)
assert(resultSet.getString("state") == states(stateIndex).toString)
stateIndex += 1
}
// check engine statement events
val engineTable = engineStatementEventPath.getParent
val resultSet2 = statement.executeQuery(s"SELECT * FROM `json`.`${engineTable}`" +
"where statement = \"" + sql + "\"")
val engineStates = Array(INITIALIZED, PENDING, RUNNING, COMPILED, FINISHED)
stateIndex = 0
while (resultSet2.next()) {
assert(resultSet2.getString("Event") ==
"org.apache.kyuubi.engine.spark.events.SparkStatementEvent")
assert(resultSet2.getString("statement") == sql)
assert(resultSet2.getString("state") == engineStates(stateIndex).toString)
stateIndex += 1
}
}
}
test("test Kyuubi session event") {
withSessionConf()(Map.empty)(Map(KyuubiConf.SESSION_NAME.key -> "test1")) {
withJdbcStatement() { statement =>
statement.execute("SELECT 1")
}
}
val eventPath =
Paths.get(logRoot.toString, "kyuubi-session", s"day=$currentDate")
withSessionConf()(Map.empty)(Map("spark.sql.shuffle.partitions" -> "2")) {
withJdbcStatement() { statement =>
val res = statement.executeQuery(
s"SELECT * FROM `json`.`$eventPath` where sessionName = 'test1' order by totalOperations")
assert(res.next())
assert(res.getString("user") == Utils.currentUser)
assert(res.getString("sessionName") == "test1")
assert(res.getLong("startTime") > 0)
assert(res.getInt("totalOperations") == 0)
assert(res.next())
assert(res.getInt("totalOperations") == 1)
assert(res.getLong("endTime") > 0)
assert(!res.next())
}
}
}
}