Skip to content
This repository was archived by the owner on Mar 10, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ limitations under the License.
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-cosmosdb-spark_2.4.0_2.11</artifactId>
<artifactId>azure-cosmosdb-spark_2.4.0_2.12</artifactId>
<packaging>jar</packaging>
<version>3.0.6</version>
<name>${project.groupId}:${project.artifactId}</name>
Expand All @@ -32,8 +32,8 @@ limitations under the License.
</license>
</licenses>
<properties>
<scala.version>2.11.12</scala.version>
<scala.binary.version>2.11</scala.binary.version>
<scala.version>2.12.11</scala.version>
<scala.binary.version>2.12</scala.binary.version>
<sonar.projectBaseDir>azure-cosmosdb-spark</sonar.projectBaseDir>
<scala.test.version>3.1.1</scala.test.version>
<spark.version>2.4.4</spark.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.apache.spark.rdd.RDD
import org.apache.spark.sql.sources.Filter
import org.apache.spark.sql.types.StructType
import org.apache.spark.sql.{DataFrame, Dataset, SparkSession}
import org.apache.spark.util.TaskCompletionListener
import org.apache.spark.{Partition, TaskContext}

import scala.collection.mutable
Expand Down Expand Up @@ -114,9 +115,11 @@ class CosmosDBRDD(
case cosmosDBPartition: CosmosDBPartition =>
logInfo(s"CosmosDBRDD:compute: Start CosmosDBRDD compute task for partition key range id ${cosmosDBPartition.partitionKeyRangeId}")

context.addTaskCompletionListener((ctx: TaskContext) => {
logInfo(s"CosmosDBRDD:compute: CosmosDBRDD compute task completed for partition key range id ${cosmosDBPartition.partitionKeyRangeId}")
})
val completionListener: TaskCompletionListener = new TaskCompletionListener() {
override def onTaskCompletion(context: TaskContext): Unit =
logInfo(s"CosmosDBRDD:compute: CosmosDBRDD compute task completed for partition key range id ${cosmosDBPartition.partitionKeyRangeId}")
}
context.addTaskCompletionListener(completionListener)

new CosmosDBRDDIterator(
hadoopConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.microsoft.azure.documentdb.internal.HttpConstants.SubStatusCodes
import org.apache.commons.lang3.StringUtils
import org.apache.spark._
import org.apache.spark.sql.sources.Filter
import org.apache.spark.util.TaskCompletionListener

import scala.collection.mutable

Expand Down Expand Up @@ -424,9 +425,13 @@ class CosmosDBRDDIterator(hadoopConfig: mutable.Map[String, String],
})

// Register an on-task-completion callback to close the input stream.
taskContext.addTaskCompletionListener((_: TaskContext) => {
closeIfNeeded()
})
val taskCompletionListerner = new TaskCompletionListener() {
override def onTaskCompletion(context: TaskContext): Unit = {
closeIfNeeded()
}
}

taskContext.addTaskCompletionListener(taskCompletionListerner)

if (!readingChangeFeed) {
queryDocuments
Expand Down