venkata91 commented on code in PR #57016: URL: https://github.com/apache/spark/pull/57016#discussion_r3561716423
########## sql/connect/server/src/main/scala/org/apache/spark/status/api/v1/connect/ConnectResource.scala: ########## @@ -0,0 +1,101 @@ +/* + * 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.spark.status.api.v1.connect + +import jakarta.ws.rs._ +import jakarta.ws.rs.core.MediaType + +import org.apache.spark.sql.connect.ui.{ExecutionInfo, SessionInfo, SparkConnectServerAppStatusStore} +import org.apache.spark.status.api.v1.{BadParameterException, BaseAppResource, NotFoundException} + +@Produces(Array(MediaType.APPLICATION_JSON)) +private[v1] class ConnectResource extends BaseAppResource { + + @GET + @Path("sessions") + def sessionList( + @DefaultValue("0") @QueryParam("offset") offset: Int, + @DefaultValue("-1") @QueryParam("length") length: Int): Seq[SessionData] = withUI { ui => + val store = new SparkConnectServerAppStatusStore(ui.store.store) + val sessions = + if (length <= 0) store.getSessionList else store.getSessionList(offset, length) + sessions.map(prepareSessionData) + } + + @GET + @Path("sessions/{sessionId}") Review Comment: You're right that `(userId, sessionId)` is the true Connect session identity and that keying on `sessionId` alone collapses same-UUID sessions from different users. I'd like to scope that fix to a separate JIRA, though, because it's a pre-existing issue in the Connect UI listener/store rather than something this PR introduces: - `SessionInfo` has been keyed by `sessionId` alone since the Connect UI was added in [SPARK-44394](https://issues.apache.org/jira/browse/SPARK-44394) (`f8786f01ad6`, 2023); `SparkConnectServerListener` tracks live sessions the same way. This PR doesn't modify either -- it only widens their visibility to `private[spark]` and reads the existing store. - The existing Connect UI already surfaces the collapsed row: `SparkConnectServerSessionPage` looks sessions up by `getSession(sessionId)` with the `id` request parameter only. So the merge is observable today, independent of this REST API. Properly preserving the composite identity means changing `SessionInfo`'s natural key and the listener's session tracking (which also backs the UI), plus a store-version/migration story for existing History Server disk stores -- a self-contained change that's better reviewed on its own. Happy to file that follow-up and reference it here. Does splitting it out sound reasonable to you? -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
