[KYUUBI #6379] Return engine name and engine url within KyuubiSessionEvent/SessionData

# 🔍 Description
## Issue References 🔗

In this pr, engineName and engineUrl will return within KyuubiSessionEvent/SessionData, these information are helpful to get the session info straight forward.

## Types of changes 🔖

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklist 📝

- [x] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

**Be nice. Be informative.**

Closes #6379 from turboFei/app_name_session_event.

Closes #6379

f9c4b0dfe [Wang, Fei] refine
15b4cfc9d [Wang, Fei] engine info
4662878e6 [Wang, Fei] id name url
9e1d72b9c [Wang, Fei] id name url

Authored-by: Wang, Fei <fwang12@ebay.com>
Signed-off-by: Wang, Fei <fwang12@ebay.com>
This commit is contained in:
Wang, Fei 2024-05-09 14:10:31 -07:00
parent 88b24601d0
commit 42570cfd5b
6 changed files with 80 additions and 2 deletions

View File

@ -33,6 +33,10 @@ public class KyuubiSessionEvent {
private String engineId;
private String engineName;
private String engineUrl;
private String user;
private String clientIp;
@ -62,6 +66,8 @@ public class KyuubiSessionEvent {
String sessionName,
String remoteSessionId,
String engineId,
String engineName,
String engineUrl,
String user,
String clientIp,
String serverIp,
@ -78,6 +84,8 @@ public class KyuubiSessionEvent {
this.sessionName = sessionName;
this.remoteSessionId = remoteSessionId;
this.engineId = engineId;
this.engineName = engineName;
this.engineUrl = engineUrl;
this.user = user;
this.clientIp = clientIp;
this.serverIp = serverIp;
@ -107,6 +115,10 @@ public class KyuubiSessionEvent {
private String engineId;
private String engineName;
private String engineUrl;
private String user;
private String clientIp;
@ -160,6 +172,16 @@ public class KyuubiSessionEvent {
return this;
}
public KyuubiSessionEvent.KyuubiSessionEventBuilder engineName(final String engineName) {
this.engineName = engineName;
return this;
}
public KyuubiSessionEvent.KyuubiSessionEventBuilder engineUrl(final String engineUrl) {
this.engineUrl = engineUrl;
return this;
}
public KyuubiSessionEvent.KyuubiSessionEventBuilder user(final String user) {
this.user = user;
return this;
@ -218,6 +240,8 @@ public class KyuubiSessionEvent {
sessionName,
remoteSessionId,
engineId,
engineName,
engineUrl,
user,
clientIp,
serverIp,
@ -279,6 +303,22 @@ public class KyuubiSessionEvent {
this.engineId = engineId;
}
public String getEngineName() {
return engineName;
}
public void setEngineName(String engineName) {
this.engineName = engineName;
}
public String getEngineUrl() {
return engineUrl;
}
public void setEngineUrl(String engineUrl) {
this.engineUrl = engineUrl;
}
public String getUser() {
return user;
}

View File

@ -36,6 +36,8 @@ public class SessionData {
private String sessionType;
private String kyuubiInstance;
private String engineId;
private String engineName;
private String engineUrl;
private String sessionName;
private Integer totalOperations;
@ -54,6 +56,8 @@ public class SessionData {
String sessionType,
String kyuubiInstance,
String engineId,
String engineName,
String engineUrl,
String sessionName,
Integer totalOperations) {
this.identifier = identifier;
@ -68,6 +72,8 @@ public class SessionData {
this.sessionType = sessionType;
this.kyuubiInstance = kyuubiInstance;
this.engineId = engineId;
this.engineName = engineName;
this.engineUrl = engineUrl;
this.sessionName = sessionName;
this.totalOperations = totalOperations;
}
@ -171,6 +177,22 @@ public class SessionData {
this.engineId = engineId;
}
public String getEngineName() {
return engineName;
}
public void setEngineName(String engineName) {
this.engineName = engineName;
}
public String getEngineUrl() {
return engineUrl;
}
public void setEngineUrl(String engineUrl) {
this.engineUrl = engineUrl;
}
public String getSessionName() {
return sessionName;
}

View File

@ -52,6 +52,8 @@ case class KyuubiSessionEvent(
startTime: Long,
var remoteSessionId: String = "",
var engineId: String = "",
var engineName: String = "",
var engineUrl: String = "",
var openedTime: Long = -1L,
var endTime: Long = -1L,
var totalOperations: Int = 0,

View File

@ -165,8 +165,16 @@ class BatchJobSubmission(
private def setStateIfNotCanceled(newState: OperationState): Unit = withLockRequired {
if (state != CANCELED) {
setState(newState)
applicationId(_applicationInfo).foreach { appId =>
session.getSessionEvent.foreach(_.engineId = appId)
_applicationInfo.foreach { app =>
Option(app.id).filter(_.nonEmpty).foreach { appId =>
session.getSessionEvent.foreach(_.engineId = appId)
}
Option(app.name).filter(_.nonEmpty).foreach { appName =>
session.getSessionEvent.foreach(_.engineName = appName)
}
app.url.filter(_.nonEmpty).foreach { appUrl =>
session.getSessionEvent.foreach(_.engineUrl = appUrl)
}
}
if (newState == RUNNING) {
session.onEngineOpened()

View File

@ -41,6 +41,8 @@ object ApiUtils extends Logging {
.conf(event.conf.asJava)
.remoteSessionId(event.remoteSessionId)
.engineId(event.engineId)
.engineName(event.engineName)
.engineUrl(event.engineUrl)
.eventTime(event.eventTime)
.openedTime(event.openedTime)
.startTime(event.startTime)
@ -65,6 +67,8 @@ object ApiUtils extends Logging {
session.sessionType.toString,
session.connectionUrl,
sessionEvent.map(_.engineId).getOrElse(""),
sessionEvent.map(_.engineName).getOrElse(""),
sessionEvent.map(_.engineUrl).getOrElse(""),
session.name.getOrElse(""),
sessionEvent.map(_.totalOperations).getOrElse(0): Int)
}

View File

@ -222,6 +222,8 @@ class KyuubiSessionImpl(
sessionEvent.openedTime = System.currentTimeMillis()
sessionEvent.remoteSessionId = _engineSessionHandle.identifier.toString
_client.engineId.foreach(e => sessionEvent.engineId = e)
_client.engineName.foreach(e => sessionEvent.engineName = e)
_client.engineUrl.foreach(e => sessionEvent.engineUrl = e)
EventBus.post(sessionEvent)
}
}