[KYUUBI #5696] [REST] Return remote session id and remote operation id

### _Why are the changes needed?_

 Not all the engine sessionIds/operationIds are unified between kyuubi server and kyuubi engines, so we need to expose  these remote details to provide more insights.

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.readthedocs.io/en/master/contributing/code/testing.html#running-tests) locally before make a pull request

### _Was this patch authored or co-authored using generative AI tooling?_

No.

Closes #5696 from turboFei/remote_id.

Closes #5696

4dc6e1df7 [fwang12] [REST] Return remote session id and remote operation id

Authored-by: fwang12 <fwang12@ebay.com>
Signed-off-by: fwang12 <fwang12@ebay.com>
This commit is contained in:
fwang12 2023-11-15 13:02:50 +08:00
parent 3c2291ef5c
commit 905170d7a5
3 changed files with 24 additions and 0 deletions

View File

@ -25,6 +25,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class OperationData {
private String identifier;
private String remoteId;
private String statement;
private String state;
private Long createTime;
@ -41,6 +42,7 @@ public class OperationData {
public OperationData(
String identifier,
String remoteId,
String statement,
String state,
Long createTime,
@ -53,6 +55,7 @@ public class OperationData {
String kyuubiInstance,
Map<String, String> metrics) {
this.identifier = identifier;
this.remoteId = remoteId;
this.statement = statement;
this.state = state;
this.createTime = createTime;
@ -74,6 +77,14 @@ public class OperationData {
this.identifier = identifier;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getStatement() {
return statement;
}

View File

@ -25,6 +25,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
public class SessionData {
private String identifier;
private String remoteId;
private String user;
private String ipAddr;
private Map<String, String> conf;
@ -40,6 +41,7 @@ public class SessionData {
public SessionData(
String identifier,
String remoteId,
String user,
String ipAddr,
Map<String, String> conf,
@ -51,6 +53,7 @@ public class SessionData {
String kyuubiInstance,
String engineId) {
this.identifier = identifier;
this.remoteId = remoteId;
this.user = user;
this.ipAddr = ipAddr;
this.conf = conf;
@ -71,6 +74,14 @@ public class SessionData {
this.identifier = identifier;
}
public String getRemoteId() {
return remoteId;
}
public void setRemoteId(String remoteId) {
this.remoteId = remoteId;
}
public String getUser() {
return user;
}

View File

@ -32,6 +32,7 @@ object ApiUtils extends Logging {
val sessionEvent = session.getSessionEvent
new SessionData(
session.handle.identifier.toString,
sessionEvent.map(_.remoteSessionId).getOrElse(""),
session.user,
session.ipAddress,
session.conf.asJava,
@ -48,6 +49,7 @@ object ApiUtils extends Logging {
val opEvent = KyuubiOperationEvent(operation)
new OperationData(
opEvent.statementId,
opEvent.remoteId,
opEvent.statement,
opEvent.state,
opEvent.createTime,