tkaymak commented on code in PR #40103:
URL: https://github.com/apache/beam/pull/40103#discussion_r3995414480
##########
runners/spark/src/main/java/org/apache/beam/runners/spark/structuredstreaming/translation/SparkSessionFactory.java:
##########
@@ -113,15 +115,47 @@ public class SparkSessionFactory {
"/com.esotericsoftware/kryo-shaded",
"/com/esotericsoftware/kryo-shaded");
+ // Users per session created here, guarded by the class lock.
+ private static final Map<SparkSession, Integer> OWNED_SESSIONS = new
HashMap<>();
+
/**
- * Gets active {@link SparkSession} or creates one using {@link
- * SparkStructuredStreamingPipelineOptions}.
+ * Returns the {@link SparkSession} for a pipeline, pair with {@link
#release}. Without {@code
+ * useActiveSparkSession} the session is created here unless a usable one
exists, only sessions
+ * created here are stopped on release.
*/
- public static SparkSession
getOrCreateSession(SparkStructuredStreamingPipelineOptions options) {
+ public static synchronized SparkSession
acquire(SparkStructuredStreamingPipelineOptions options) {
if (options.getUseActiveSparkSession()) {
return SparkSession.active();
}
- return sessionBuilder(options.getSparkMaster(), options).getOrCreate();
+ // Spark 3 also returns stopped sessions.
Review Comment:
Will do: getOrCreate adopts an existing session, a pipeline must not stop
one it did not create, and the next pipeline needs the previous one's session
gone to get its own config.
--
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]