ulysses-you commented on a change in pull request #861: URL: https://github.com/apache/incubator-kyuubi/pull/861#discussion_r675408600
########## File path: externals/kyuubi-spark-monitor/src/main/scala/org/apache/kyuubi/engine/spark/monitor/entity/KyuubiStageInfo.scala ########## @@ -0,0 +1,37 @@ +/* + * 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.engine.spark.monitor.entity + +import org.apache.spark.scheduler.StageInfo + +/** + * This object is used for storing the basic data for stage. + * StageInfo store the metrics in its running time. + * + * In this object, you can use jobId to get all stages that belong to this job and also + * you can use statementId to get all stages. + * + * @param stageId + * @param statementId + * @param stageInfo + */ +// TODO: kyuubi-851: Thread safe consider: for statementInfo, jobInfo and stageInfo +case class KyuubiStageInfo( + stageId: Int, + statementId: String, + stageInfo: StageInfo) Review comment: Can we merge all info bean into one file ? ########## File path: externals/kyuubi-spark-monitor/src/main/scala/org/apache/kyuubi/engine/spark/monitor/entity/KyuubiStageInfo.scala ########## @@ -0,0 +1,37 @@ +/* + * 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.engine.spark.monitor.entity + +import org.apache.spark.scheduler.StageInfo + +/** + * This object is used for storing the basic data for stage. + * StageInfo store the metrics in its running time. + * + * In this object, you can use jobId to get all stages that belong to this job and also + * you can use statementId to get all stages. + * + * @param stageId + * @param statementId + * @param stageInfo + */ +// TODO: kyuubi-851: Thread safe consider: for statementInfo, jobInfo and stageInfo +case class KyuubiStageInfo( + stageId: Int, + statementId: String, + stageInfo: StageInfo) Review comment: Do we need all fields of `StageInfo` ? ########## File path: externals/kyuubi-spark-sql-engine/src/main/scala/org/apache/spark/kyuubi/SparkSQLEngineListener.scala ########## @@ -112,6 +112,13 @@ class SparkSQLEngineListener(server: Serverable) extends SparkListener with Logg } } + override def onStageSubmitted(stageSubmitted: SparkListenerStageSubmitted): Unit = { + val statementId = stageSubmitted.properties.getProperty(KYUUBI_STATEMENT_ID_KEY) + val kyuubiStageInfo = KyuubiStageInfo( + stageSubmitted.stageInfo.stageId, statementId, stageSubmitted.stageInfo) + KyuubiStatementMonitor.putStageInfoIntoQueue(kyuubiStageInfo) + } + Review comment: Why we don't capture `SparkListenerStageCompleted` ? ########## File path: externals/kyuubi-spark-monitor/src/main/scala/org/apache/kyuubi/engine/spark/monitor/KyuubiStatementMonitor.scala ########## @@ -57,33 +56,43 @@ object KyuubiStatementMonitor extends Logging{ * a. time * b. this map's current size */ - // TODO: Capacity should make configurable private val kyuubiJobIdToJobInfoMap = new ConcurrentHashMap[Int, KyuubiJobInfo](maxCapacity) + /** + * This blockingQueue store kyuubiStageInfo. + * + * Notice: + * 1. When we remove items from this queue, we should ensure those stages have finished + * If not, we should put them into this queue again. + * 2. There have two kinds of threshold to trigger when to remove items from this queue: + * a. time + * b. this queue's current size + */ + private val kyuubiStageInfoQueue = new ArrayBlockingQueue[KyuubiStageInfo](maxCapacity) + /** * This method is used for putting kyuubiStatementInfo into blockingQueue(statementQueue). * Every time we put an item into this queue, we should judge this queue's current size at first. * If the size is less than threshold, we need to remove items from this queue. * * @param kyuubiStatementInfo */ - // TODO: Lack size type threshold and time type threshold + // TODO: kyuubi-850: Make threshold that trigger when to dump data into file configurable def putStatementInfoIntoQueue(kyuubiStatementInfo: KyuubiStatementInfo): Unit = { if (kyuubiStatementQueue.size() >= maxSize) { removeAndDumpStatementInfoFromQueue() } val isSuccess = kyuubiStatementQueue.add(kyuubiStatementInfo) - info(s"Add kyuubiStatementInfo into queue is [$isSuccess], " + + debug(s"Add kyuubiStatementInfo into queue is [$isSuccess], " + Review comment: It's better that move the unrelated code to a new PR. It can help reviewer get the main change of this PR. -- 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]
