turboFei commented on code in PR #4390:
URL: https://github.com/apache/kyuubi/pull/4390#discussion_r1112613748
##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala:
##########
@@ -210,22 +210,35 @@ private[v1] class BatchesResource extends
ApiRequestContext with Logging {
}
request.setBatchType(request.getBatchType.toUpperCase(Locale.ROOT))
- val userName = fe.getSessionUser(request.getConf.asScala.toMap)
- val ipAddress = fe.getIpAddress
- request.setConf(
- (request.getConf.asScala ++ Map(
- KYUUBI_CLIENT_IP_KEY -> ipAddress,
- KYUUBI_SERVER_IP_KEY -> fe.host,
- KYUUBI_SESSION_CONNECTION_URL_KEY -> fe.connectionUrl,
- KYUUBI_SESSION_BATCH_RESOURCE_UPLOADED_KEY ->
isResourceFromUpload.toString,
- KYUUBI_SESSION_REAL_USER_KEY -> fe.getRealUser())).asJava)
- val sessionHandle = sessionManager.openBatchSession(
- userName,
- "anonymous",
- ipAddress,
- request.getConf.asScala.toMap,
- request)
- buildBatch(sessionManager.getBatchSessionImpl(sessionHandle))
+ val userProvidedBatchId =
request.getConf.asScala.get(KYUUBI_SESSION_BATCH_ID_KEY)
+ // the user provides batch_id must be an UUID
+ .map { batchId => UUID.fromString(batchId); batchId }
+
+ userProvidedBatchId.flatMap { batchId =>
+ Option(sessionManager.getBatchFromMetadataStore(batchId))
+ } match {
+ case Some(batch) =>
+ warn(s"duplicated submission: ${batch.getId}, ignore and return the
existing batch.")
+ batch
+ case None =>
Review Comment:
mistake.
If batchId is specified,
- if the batch is existing, return the batch.
- if the batch does exist, use the specified batchId
If no batchId specified, generate a new one
##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala:
##########
@@ -210,22 +210,35 @@ private[v1] class BatchesResource extends
ApiRequestContext with Logging {
}
request.setBatchType(request.getBatchType.toUpperCase(Locale.ROOT))
- val userName = fe.getSessionUser(request.getConf.asScala.toMap)
- val ipAddress = fe.getIpAddress
- request.setConf(
- (request.getConf.asScala ++ Map(
- KYUUBI_CLIENT_IP_KEY -> ipAddress,
- KYUUBI_SERVER_IP_KEY -> fe.host,
- KYUUBI_SESSION_CONNECTION_URL_KEY -> fe.connectionUrl,
- KYUUBI_SESSION_BATCH_RESOURCE_UPLOADED_KEY ->
isResourceFromUpload.toString,
- KYUUBI_SESSION_REAL_USER_KEY -> fe.getRealUser())).asJava)
- val sessionHandle = sessionManager.openBatchSession(
- userName,
- "anonymous",
- ipAddress,
- request.getConf.asScala.toMap,
- request)
- buildBatch(sessionManager.getBatchSessionImpl(sessionHandle))
+ val userProvidedBatchId =
request.getConf.asScala.get(KYUUBI_SESSION_BATCH_ID_KEY)
+ // the user provides batch_id must be an UUID
+ .map { batchId => UUID.fromString(batchId); batchId }
Review Comment:
should be provide a more detail error message if the specified id is not an
UUID?
--
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]