Skip to content

Commit

Permalink
[KYUUBI #6379] Return engine name and engine url within KyuubiSession…
Browse files Browse the repository at this point in the history
…Event/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

f9c4b0d [Wang, Fei] refine
15b4cfc [Wang, Fei] engine info
4662878 [Wang, Fei] id name url
9e1d72b [Wang, Fei] id name url

Authored-by: Wang, Fei <fwang12@ebay.com>
Signed-off-by: Wang, Fei <fwang12@ebay.com>
  • Loading branch information
turboFei committed May 9, 2024
1 parent 88b2460 commit 42570cf
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 2 deletions.
Expand Up @@ -33,6 +33,10 @@ public class KyuubiSessionEvent {

private String engineId;

private String engineName;

private String engineUrl;

private String user;

private String clientIp;
Expand Down Expand Up @@ -62,6 +66,8 @@ public KyuubiSessionEvent(
String sessionName,
String remoteSessionId,
String engineId,
String engineName,
String engineUrl,
String user,
String clientIp,
String serverIp,
Expand All @@ -78,6 +84,8 @@ public 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;
Expand Down Expand Up @@ -107,6 +115,10 @@ public static class KyuubiSessionEventBuilder {

private String engineId;

private String engineName;

private String engineUrl;

private String user;

private String clientIp;
Expand Down Expand Up @@ -160,6 +172,16 @@ public KyuubiSessionEvent.KyuubiSessionEventBuilder engineId(final String engine
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;
Expand Down Expand Up @@ -218,6 +240,8 @@ public KyuubiSessionEvent build() {
sessionName,
remoteSessionId,
engineId,
engineName,
engineUrl,
user,
clientIp,
serverIp,
Expand Down Expand Up @@ -279,6 +303,22 @@ public void setEngineId(String engineId) {
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;
}
Expand Down
Expand Up @@ -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;

Expand All @@ -54,6 +56,8 @@ public SessionData(
String sessionType,
String kyuubiInstance,
String engineId,
String engineName,
String engineUrl,
String sessionName,
Integer totalOperations) {
this.identifier = identifier;
Expand All @@ -68,6 +72,8 @@ public SessionData(
this.sessionType = sessionType;
this.kyuubiInstance = kyuubiInstance;
this.engineId = engineId;
this.engineName = engineName;
this.engineUrl = engineUrl;
this.sessionName = sessionName;
this.totalOperations = totalOperations;
}
Expand Down Expand Up @@ -171,6 +177,22 @@ public void setEngineId(String engineId) {
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;
}
Expand Down
Expand Up @@ -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,
Expand Down
Expand Up @@ -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()
Expand Down
Expand Up @@ -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)
Expand All @@ -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)
}
Expand Down
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 42570cf

Please sign in to comment.