stream2000 commented on code in PR #7300:
URL: https://github.com/apache/hudi/pull/7300#discussion_r1031398013
##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/procedures/RunClusteringProcedure.scala:
##########
@@ -105,37 +105,39 @@ class RunClusteringProcedure extends BaseProcedure
logInfo(s"Pending clustering instants: ${pendingClustering.mkString(",")}")
val client = HoodieCLIUtils.createHoodieClientFromPath(sparkSession,
basePath, conf)
- val instantTime = HoodieActiveTimeline.createNewInstantTime
- if (client.scheduleClusteringAtInstant(instantTime, HOption.empty())) {
- pendingClustering ++= Seq(instantTime)
- }
- logInfo(s"Clustering instants to run: ${pendingClustering.mkString(",")}.")
-
- val startTs = System.currentTimeMillis()
- pendingClustering.foreach(client.cluster(_, true))
- logInfo(s"Finish clustering all the instants:
${pendingClustering.mkString(",")}," +
- s" time cost: ${System.currentTimeMillis() - startTs}ms.")
-
- val clusteringInstants =
metaClient.reloadActiveTimeline().getInstants.iterator().asScala
- .filter(p => p.getAction == HoodieTimeline.REPLACE_COMMIT_ACTION &&
pendingClustering.contains(p.getTimestamp))
- .toSeq
- .sortBy(f => f.getTimestamp)
- .reverse
-
- val clusteringPlans = clusteringInstants.map(instant =>
- ClusteringUtils.getClusteringPlan(metaClient, instant)
- )
-
- if (showInvolvedPartitions) {
- clusteringPlans.map { p =>
- Row(p.get().getLeft.getTimestamp,
p.get().getRight.getInputGroups.size(),
- p.get().getLeft.getState.name(),
HoodieCLIUtils.extractPartitions(p.get().getRight.getInputGroups.asScala))
+ try {
+ val instantTime = HoodieActiveTimeline.createNewInstantTime
+ if (client.scheduleClusteringAtInstant(instantTime, HOption.empty())) {
+ pendingClustering ++= Seq(instantTime)
}
- } else {
- clusteringPlans.map { p =>
- Row(p.get().getLeft.getTimestamp,
p.get().getRight.getInputGroups.size(), p.get().getLeft.getState.name(), "*")
+ logInfo(s"Clustering instants to run:
${pendingClustering.mkString(",")}.")
+
+ val startTs = System.currentTimeMillis()
+ pendingClustering.foreach(client.cluster(_, true))
+ logInfo(s"Finish clustering all the instants:
${pendingClustering.mkString(",")}," +
+ s" time cost: ${System.currentTimeMillis() - startTs}ms.")
+
+ val clusteringInstants =
metaClient.reloadActiveTimeline().getInstants.iterator().asScala
+ .filter(p => p.getAction == HoodieTimeline.REPLACE_COMMIT_ACTION &&
pendingClustering.contains(p.getTimestamp))
+ .toSeq
+ .sortBy(f => f.getTimestamp)
+ .reverse
+
+ val clusteringPlans = clusteringInstants.map(instant =>
+ ClusteringUtils.getClusteringPlan(metaClient, instant)
+ )
+
+ if (showInvolvedPartitions) {
+ clusteringPlans.map { p =>
+ Row(p.get().getLeft.getTimestamp,
p.get().getRight.getInputGroups.size(),
+ p.get().getLeft.getState.name(),
HoodieCLIUtils.extractPartitions(p.get().getRight.getInputGroups.asScala))
+ }
+ } else {
+ clusteringPlans.map { p =>
+ Row(p.get().getLeft.getTimestamp,
p.get().getRight.getInputGroups.size(), p.get().getLeft.getState.name(), "*")
+ }
}
- }
+ } finally if (client != null) client.close()
Review Comment:
fixed
--
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]