You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by fe...@apache.org on 2022/05/17 09:59:46 UTC
[incubator-kyuubi] branch master updated: [KYUUBI #2668] [SUB-TASK][KPIP-4] Rewrite the rest DTO classes in java
This is an automated email from the ASF dual-hosted git repository.
feiwang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 31fdd7ec4 [KYUUBI #2668] [SUB-TASK][KPIP-4] Rewrite the rest DTO classes in java
31fdd7ec4 is described below
commit 31fdd7ec46737f670abb46766c108c64d0eb8935
Author: Fei Wang <fw...@ebay.com>
AuthorDate: Tue May 17 17:59:38 2022 +0800
[KYUUBI #2668] [SUB-TASK][KPIP-4] Rewrite the rest DTO classes in java
### _Why are the changes needed?_
To close #2674
Rewrite the rest DTO classes in java, which is the preparation for kyuubi rest sdk #2643
### _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.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #2668 from turboFei/client_do.
Closes #2668
e2bf779c [Fei Wang] revert by reformat
a23f65f6 [Fei Wang] address comments
6648ef90 [Fei Wang] regen the equals & hashCode without accepct subclasses as parameter to equals()
840866c9 [Fei Wang] add equals & hashCode for dto classes
1cc9afaa [Fei Wang] return empty collections
2d49db50 [Fei Wang] return empty batch info map by defaults
1bb399c0 [Fei Wang] only reserve slf4j-api
c6621ed8 [Fei Wang] fix ut
e15ea9f0 [Fei Wang] refactor
ef6dc16c [Fei Wang] add dependes into assembly
ffacf68d [Fei Wang] rewrite the dto classes in java
Authored-by: Fei Wang <fw...@ebay.com>
Signed-off-by: Fei Wang <fw...@ebay.com>
---
dev/kyuubi-codecov/pom.xml | 6 +
kyuubi-assembly/pom.xml | 6 +
kyuubi-rest-client/pom.xml | 78 ++++++++++++
.../org/apache/kyuubi/client/api/v1/dto/Batch.java | 101 +++++++++++++++
.../kyuubi/client/api/v1/dto/BatchRequest.java | 131 ++++++++++++++++++++
.../kyuubi/client/api/v1/dto/ColumnDesc.java | 113 +++++++++++++++++
.../client/api/v1/dto/ExecPoolStatistic.java | 62 ++++++++++
.../org/apache/kyuubi/client/api/v1/dto/Field.java | 62 ++++++++++
.../client/api/v1/dto/GetBatchesResponse.java | 78 ++++++++++++
.../client/api/v1/dto/GetColumnsRequest.java | 85 +++++++++++++
.../api/v1/dto/GetCrossReferenceRequest.java | 118 ++++++++++++++++++
.../client/api/v1/dto/GetFunctionsRequest.java | 73 +++++++++++
.../client/api/v1/dto/GetPrimaryKeysRequest.java | 73 +++++++++++
.../client/api/v1/dto/GetSchemasRequest.java | 62 ++++++++++
.../kyuubi/client/api/v1/dto/GetTablesRequest.java | 90 ++++++++++++++
.../kyuubi/client/api/v1/dto/InfoDetail.java | 62 ++++++++++
.../kyuubi/client/api/v1/dto/OpActionRequest.java | 51 ++++++++
.../kyuubi/client/api/v1/dto/OperationLog.java | 67 ++++++++++
.../kyuubi/client/api/v1/dto/ResultRowSet.java | 66 ++++++++++
.../client/api/v1/dto/ResultSetMetaData.java | 56 +++++++++
.../org/apache/kyuubi/client/api/v1/dto/Row.java | 56 +++++++++
.../kyuubi/client/api/v1/dto/SessionData.java | 123 +++++++++++++++++++
.../kyuubi/client/api/v1/dto/SessionHandle.java | 73 +++++++++++
.../kyuubi/client/api/v1/dto/SessionOpenCount.java | 51 ++++++++
.../client/api/v1/dto/SessionOpenRequest.java | 105 ++++++++++++++++
.../kyuubi/client/api/v1/dto/StatementRequest.java | 73 +++++++++++
.../kyuubi/client/api/v1/dto/VersionInfo.java | 51 ++++++++
kyuubi-server/pom.xml | 6 +
.../engine/spark/SparkBatchProcessBuilder.scala | 17 +--
.../kyuubi/operation/BatchJobSubmission.scala | 11 +-
.../kyuubi/operation/KyuubiOperationManager.scala | 2 +-
.../kyuubi/server/api/v1/ApiRootResource.scala | 1 +
.../kyuubi/server/api/v1/BatchesResource.scala | 17 +--
.../kyuubi/server/api/v1/OperationsResource.scala | 26 ++--
.../kyuubi/server/api/v1/SessionsResource.scala | 83 +++++++------
.../org/apache/kyuubi/server/api/v1/dto.scala | 135 ---------------------
.../kyuubi/session/KyuubiBatchSessionImpl.scala | 11 +-
.../kyuubi/session/KyuubiSessionManager.scala | 2 +-
.../org/apache/kyuubi/WithKyuubiServerOnYarn.scala | 18 +--
.../operation/KyuubiRestAuthenticationSuite.scala | 10 +-
.../server/KyuubiRestFrontendServiceSuite.scala | 4 +-
.../server/api/v1/BatchesResourceSuite.scala | 82 ++++++++-----
.../server/api/v1/OperationsResourceSuite.scala | 17 +--
.../server/api/v1/SessionsResourceSuite.scala | 66 +++++-----
pom.xml | 1 +
45 files changed, 2185 insertions(+), 296 deletions(-)
diff --git a/dev/kyuubi-codecov/pom.xml b/dev/kyuubi-codecov/pom.xml
index 8623a985a..083667f0d 100644
--- a/dev/kyuubi-codecov/pom.xml
+++ b/dev/kyuubi-codecov/pom.xml
@@ -69,6 +69,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.kyuubi</groupId>
+ <artifactId>kyuubi-rest-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.kyuubi</groupId>
<artifactId>kyuubi-server_${scala.binary.version}</artifactId>
diff --git a/kyuubi-assembly/pom.xml b/kyuubi-assembly/pom.xml
index 9eee0c0b4..a71d95887 100644
--- a/kyuubi-assembly/pom.xml
+++ b/kyuubi-assembly/pom.xml
@@ -52,6 +52,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.kyuubi</groupId>
+ <artifactId>kyuubi-rest-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.kyuubi</groupId>
<artifactId>kyuubi-server_${scala.binary.version}</artifactId>
diff --git a/kyuubi-rest-client/pom.xml b/kyuubi-rest-client/pom.xml
new file mode 100644
index 000000000..48c58dd72
--- /dev/null
+++ b/kyuubi-rest-client/pom.xml
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache.kyuubi</groupId>
+ <artifactId>kyuubi-parent</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>kyuubi-rest-client</artifactId>
+ <name>Kyuubi Project Rest Client</name>
+ <packaging>jar</packaging>
+ <url>https://kyuubi.apache.org/</url>
+
+ <properties>
+ <jars.target.dir>${project.build.directory}</jars.target.dir>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <outputDirectory>target/classes</outputDirectory>
+ <testOutputDirectory>target/test-classes</testOutputDirectory>
+
+ <plugins>
+ <plugin>
+ <groupId>net.alchim31.maven</groupId>
+ <artifactId>scala-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-scaladocs</id>
+ <phase>none</phase>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest-maven-plugin</artifactId>
+ <configuration>
+ <skipTests>true</skipTests>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.scalastyle</groupId>
+ <artifactId>scalastyle-maven-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Batch.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Batch.java
new file mode 100644
index 000000000..e318279e3
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Batch.java
@@ -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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+
+public class Batch {
+ private String id;
+ private String batchType;
+ private Map<String, String> batchInfo;
+ private String kyuubiInstance;
+ private String state;
+
+ public Batch() {}
+
+ public Batch(
+ String id,
+ String batchType,
+ Map<String, String> batchInfo,
+ String kyuubiInstance,
+ String state) {
+ this.id = id;
+ this.batchType = batchType;
+ this.batchInfo = batchInfo;
+ this.kyuubiInstance = kyuubiInstance;
+ this.state = state;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getBatchType() {
+ return batchType;
+ }
+
+ public void setBatchType(String batchType) {
+ this.batchType = batchType;
+ }
+
+ public Map<String, String> getBatchInfo() {
+ if (null == batchInfo) {
+ return Collections.emptyMap();
+ }
+ return batchInfo;
+ }
+
+ public void setBatchInfo(Map<String, String> batchInfo) {
+ this.batchInfo = batchInfo;
+ }
+
+ public String getKyuubiInstance() {
+ return kyuubiInstance;
+ }
+
+ public void setKyuubiInstance(String kyuubiInstance) {
+ this.kyuubiInstance = kyuubiInstance;
+ }
+
+ public String getState() {
+ return state;
+ }
+
+ public void setState(String state) {
+ this.state = state;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Batch batch = (Batch) o;
+ return Objects.equals(getId(), batch.getId());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getId());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/BatchRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/BatchRequest.java
new file mode 100644
index 000000000..c7e8add24
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/BatchRequest.java
@@ -0,0 +1,131 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+public class BatchRequest {
+ private String batchType;
+ private String resource;
+ private String className;
+ private String name;
+ private Map<String, String> conf;
+ private List<String> args;
+
+ public BatchRequest() {}
+
+ public BatchRequest(
+ String batchType,
+ String resource,
+ String className,
+ String name,
+ Map<String, String> conf,
+ List<String> args) {
+ this.batchType = batchType;
+ this.resource = resource;
+ this.className = className;
+ this.name = name;
+ this.conf = conf;
+ this.args = args;
+ }
+
+ public BatchRequest(String batchType, String resource, String className, String name) {
+ this.batchType = batchType;
+ this.resource = resource;
+ this.className = className;
+ this.name = name;
+ this.conf = Collections.emptyMap();
+ this.args = Collections.emptyList();
+ }
+
+ public String getBatchType() {
+ return batchType;
+ }
+
+ public void setBatchType(String batchType) {
+ this.batchType = batchType;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+
+ public String getClassName() {
+ return className;
+ }
+
+ public void setClassName(String className) {
+ this.className = className;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map<String, String> getConf() {
+ if (null == conf) {
+ return Collections.emptyMap();
+ }
+ return conf;
+ }
+
+ public void setConf(Map<String, String> conf) {
+ this.conf = conf;
+ }
+
+ public List<String> getArgs() {
+ if (null == args) {
+ return Collections.emptyList();
+ }
+ return args;
+ }
+
+ public void setArgs(List<String> args) {
+ this.args = args;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ BatchRequest that = (BatchRequest) o;
+ return Objects.equals(getBatchType(), that.getBatchType())
+ && Objects.equals(getResource(), that.getResource())
+ && Objects.equals(getClassName(), that.getClassName())
+ && Objects.equals(getName(), that.getName())
+ && Objects.equals(getConf(), that.getConf())
+ && Objects.equals(getArgs(), that.getArgs());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ getBatchType(), getResource(), getClassName(), getName(), getConf(), getArgs());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ColumnDesc.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ColumnDesc.java
new file mode 100644
index 000000000..3ba30b22e
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ColumnDesc.java
@@ -0,0 +1,113 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class ColumnDesc {
+ private String columnName;
+ private String dataType;
+ private int columnIndex;
+ private int precision;
+ private int scale;
+ private String comment;
+
+ public ColumnDesc() {}
+
+ public ColumnDesc(
+ String columnName,
+ String dataType,
+ int columnIndex,
+ int precision,
+ int scale,
+ String comment) {
+ this.columnName = columnName;
+ this.dataType = dataType;
+ this.columnIndex = columnIndex;
+ this.precision = precision;
+ this.scale = scale;
+ this.comment = comment;
+ }
+
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public void setColumnName(String columnName) {
+ this.columnName = columnName;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public int getColumnIndex() {
+ return columnIndex;
+ }
+
+ public void setColumnIndex(int columnIndex) {
+ this.columnIndex = columnIndex;
+ }
+
+ public int getPrecision() {
+ return precision;
+ }
+
+ public void setPrecision(int precision) {
+ this.precision = precision;
+ }
+
+ public int getScale() {
+ return scale;
+ }
+
+ public void setScale(int scale) {
+ this.scale = scale;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ColumnDesc that = (ColumnDesc) o;
+ return getColumnIndex() == that.getColumnIndex()
+ && getPrecision() == that.getPrecision()
+ && getScale() == that.getScale()
+ && Objects.equals(getColumnName(), that.getColumnName())
+ && Objects.equals(getDataType(), that.getDataType())
+ && Objects.equals(getComment(), that.getComment());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ getColumnName(), getDataType(), getColumnIndex(), getPrecision(), getScale(), getComment());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ExecPoolStatistic.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ExecPoolStatistic.java
new file mode 100644
index 000000000..e727a1baa
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ExecPoolStatistic.java
@@ -0,0 +1,62 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class ExecPoolStatistic {
+ private int execPoolSize;
+ private int execPoolActiveCount;
+
+ public ExecPoolStatistic() {}
+
+ public ExecPoolStatistic(int execPoolSize, int execPoolActiveCount) {
+ this.execPoolSize = execPoolSize;
+ this.execPoolActiveCount = execPoolActiveCount;
+ }
+
+ public int getExecPoolSize() {
+ return execPoolSize;
+ }
+
+ public void setExecPoolSize(int execPoolSize) {
+ this.execPoolSize = execPoolSize;
+ }
+
+ public int getExecPoolActiveCount() {
+ return execPoolActiveCount;
+ }
+
+ public void setExecPoolActiveCount(int execPoolActiveCount) {
+ this.execPoolActiveCount = execPoolActiveCount;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ExecPoolStatistic that = (ExecPoolStatistic) o;
+ return getExecPoolSize() == that.getExecPoolSize()
+ && getExecPoolActiveCount() == that.getExecPoolActiveCount();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getExecPoolSize(), getExecPoolActiveCount());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Field.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Field.java
new file mode 100644
index 000000000..9b95a56a5
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Field.java
@@ -0,0 +1,62 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class Field {
+ private String dataType;
+ private Object value;
+
+ public Field() {}
+
+ public Field(String dataType, Object value) {
+ this.dataType = dataType;
+ this.value = value;
+ }
+
+ public String getDataType() {
+ return dataType;
+ }
+
+ public void setDataType(String dataType) {
+ this.dataType = dataType;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Field field = (Field) o;
+ return Objects.equals(getDataType(), field.getDataType())
+ && Objects.equals(getValue(), field.getValue());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getDataType(), getValue());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetBatchesResponse.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetBatchesResponse.java
new file mode 100644
index 000000000..5c07354ab
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetBatchesResponse.java
@@ -0,0 +1,78 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+public class GetBatchesResponse {
+ private int from;
+ private int total;
+ private List<Batch> batches;
+
+ public GetBatchesResponse() {}
+
+ public GetBatchesResponse(int from, int total, List<Batch> batches) {
+ this.from = from;
+ this.total = total;
+ this.batches = batches;
+ }
+
+ public int getFrom() {
+ return from;
+ }
+
+ public void setFrom(int from) {
+ this.from = from;
+ }
+
+ public int getTotal() {
+ return total;
+ }
+
+ public void setTotal(int total) {
+ this.total = total;
+ }
+
+ public List<Batch> getBatches() {
+ if (null == batches) {
+ return Collections.emptyList();
+ }
+ return batches;
+ }
+
+ public void setBatches(List<Batch> batches) {
+ this.batches = batches;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ GetBatchesResponse that = (GetBatchesResponse) o;
+ return getFrom() == that.getFrom()
+ && getTotal() == that.getTotal()
+ && Objects.equals(getBatches(), that.getBatches());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getFrom(), getTotal(), getBatches());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetColumnsRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetColumnsRequest.java
new file mode 100644
index 000000000..f718ed8ef
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetColumnsRequest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class GetColumnsRequest {
+ private String catalogName;
+ private String schemaName;
+ private String tableName;
+ private String columnName;
+
+ public GetColumnsRequest() {}
+
+ public GetColumnsRequest(
+ String catalogName, String schemaName, String tableName, String columnName) {
+ this.catalogName = catalogName;
+ this.schemaName = schemaName;
+ this.tableName = tableName;
+ this.columnName = columnName;
+ }
+
+ public String getCatalogName() {
+ return catalogName;
+ }
+
+ public void setCatalogName(String catalogName) {
+ this.catalogName = catalogName;
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ public void setSchemaName(String schemaName) {
+ this.schemaName = schemaName;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public String getColumnName() {
+ return columnName;
+ }
+
+ public void setColumnName(String columnName) {
+ this.columnName = columnName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ GetColumnsRequest that = (GetColumnsRequest) o;
+ return Objects.equals(getCatalogName(), that.getCatalogName())
+ && Objects.equals(getSchemaName(), that.getSchemaName())
+ && Objects.equals(getTableName(), that.getTableName())
+ && Objects.equals(getColumnName(), that.getColumnName());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getCatalogName(), getSchemaName(), getTableName(), getColumnName());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetCrossReferenceRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetCrossReferenceRequest.java
new file mode 100644
index 000000000..374c6e0a7
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetCrossReferenceRequest.java
@@ -0,0 +1,118 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class GetCrossReferenceRequest {
+ private String primaryCatalog;
+ private String primarySchema;
+ private String primaryTable;
+ private String foreignCatalog;
+ private String foreignSchema;
+ private String foreignTable;
+
+ public GetCrossReferenceRequest() {}
+
+ public GetCrossReferenceRequest(
+ String primaryCatalog,
+ String primarySchema,
+ String primaryTable,
+ String foreignCatalog,
+ String foreignSchema,
+ String foreignTable) {
+ this.primaryCatalog = primaryCatalog;
+ this.primarySchema = primarySchema;
+ this.primaryTable = primaryTable;
+ this.foreignCatalog = foreignCatalog;
+ this.foreignSchema = foreignSchema;
+ this.foreignTable = foreignTable;
+ }
+
+ public String getPrimaryCatalog() {
+ return primaryCatalog;
+ }
+
+ public void setPrimaryCatalog(String primaryCatalog) {
+ this.primaryCatalog = primaryCatalog;
+ }
+
+ public String getPrimarySchema() {
+ return primarySchema;
+ }
+
+ public void setPrimarySchema(String primarySchema) {
+ this.primarySchema = primarySchema;
+ }
+
+ public String getPrimaryTable() {
+ return primaryTable;
+ }
+
+ public void setPrimaryTable(String primaryTable) {
+ this.primaryTable = primaryTable;
+ }
+
+ public String getForeignCatalog() {
+ return foreignCatalog;
+ }
+
+ public void setForeignCatalog(String foreignCatalog) {
+ this.foreignCatalog = foreignCatalog;
+ }
+
+ public String getForeignSchema() {
+ return foreignSchema;
+ }
+
+ public void setForeignSchema(String foreignSchema) {
+ this.foreignSchema = foreignSchema;
+ }
+
+ public String getForeignTable() {
+ return foreignTable;
+ }
+
+ public void setForeignTable(String foreignTable) {
+ this.foreignTable = foreignTable;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ GetCrossReferenceRequest that = (GetCrossReferenceRequest) o;
+ return Objects.equals(getPrimaryCatalog(), that.getPrimaryCatalog())
+ && Objects.equals(getPrimarySchema(), that.getPrimarySchema())
+ && Objects.equals(getPrimaryTable(), that.getPrimaryTable())
+ && Objects.equals(getForeignCatalog(), that.getForeignCatalog())
+ && Objects.equals(getForeignSchema(), that.getForeignSchema())
+ && Objects.equals(getForeignTable(), that.getForeignTable());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(
+ getPrimaryCatalog(),
+ getPrimarySchema(),
+ getPrimaryTable(),
+ getForeignCatalog(),
+ getForeignSchema(),
+ getForeignTable());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetFunctionsRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetFunctionsRequest.java
new file mode 100644
index 000000000..94ac700b2
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetFunctionsRequest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class GetFunctionsRequest {
+ private String catalogName;
+ private String schemaName;
+ private String functionName;
+
+ public GetFunctionsRequest() {}
+
+ public GetFunctionsRequest(String catalogName, String schemaName, String functionName) {
+ this.catalogName = catalogName;
+ this.schemaName = schemaName;
+ this.functionName = functionName;
+ }
+
+ public String getCatalogName() {
+ return catalogName;
+ }
+
+ public void setCatalogName(String catalogName) {
+ this.catalogName = catalogName;
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ public void setSchemaName(String schemaName) {
+ this.schemaName = schemaName;
+ }
+
+ public String getFunctionName() {
+ return functionName;
+ }
+
+ public void setFunctionName(String functionName) {
+ this.functionName = functionName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ GetFunctionsRequest that = (GetFunctionsRequest) o;
+ return Objects.equals(getCatalogName(), that.getCatalogName())
+ && Objects.equals(getSchemaName(), that.getSchemaName())
+ && Objects.equals(getFunctionName(), that.getFunctionName());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getCatalogName(), getSchemaName(), getFunctionName());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetPrimaryKeysRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetPrimaryKeysRequest.java
new file mode 100644
index 000000000..b43efac5e
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetPrimaryKeysRequest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class GetPrimaryKeysRequest {
+ private String catalogName;
+ private String schemaName;
+ private String tableName;
+
+ public GetPrimaryKeysRequest() {}
+
+ public GetPrimaryKeysRequest(String catalogName, String schemaName, String tableName) {
+ this.catalogName = catalogName;
+ this.schemaName = schemaName;
+ this.tableName = tableName;
+ }
+
+ public String getCatalogName() {
+ return catalogName;
+ }
+
+ public void setCatalogName(String catalogName) {
+ this.catalogName = catalogName;
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ public void setSchemaName(String schemaName) {
+ this.schemaName = schemaName;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ GetPrimaryKeysRequest that = (GetPrimaryKeysRequest) o;
+ return Objects.equals(getCatalogName(), that.getCatalogName())
+ && Objects.equals(getSchemaName(), that.getSchemaName())
+ && Objects.equals(getTableName(), that.getTableName());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getCatalogName(), getSchemaName(), getTableName());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetSchemasRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetSchemasRequest.java
new file mode 100644
index 000000000..80833b5f8
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetSchemasRequest.java
@@ -0,0 +1,62 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class GetSchemasRequest {
+ private String catalogName;
+ private String schemaName;
+
+ public GetSchemasRequest() {}
+
+ public GetSchemasRequest(String catalogName, String schemaName) {
+ this.catalogName = catalogName;
+ this.schemaName = schemaName;
+ }
+
+ public String getCatalogName() {
+ return catalogName;
+ }
+
+ public void setCatalogName(String catalogName) {
+ this.catalogName = catalogName;
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ public void setSchemaName(String schemaName) {
+ this.schemaName = schemaName;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ GetSchemasRequest that = (GetSchemasRequest) o;
+ return Objects.equals(getCatalogName(), that.getCatalogName())
+ && Objects.equals(getSchemaName(), that.getSchemaName());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getCatalogName(), getSchemaName());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetTablesRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetTablesRequest.java
new file mode 100644
index 000000000..5f98d12c5
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/GetTablesRequest.java
@@ -0,0 +1,90 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+public class GetTablesRequest {
+ private String catalogName;
+ private String schemaName;
+ private String tableName;
+ private List<String> tableTypes;
+
+ public GetTablesRequest() {}
+
+ public GetTablesRequest(
+ String catalogName, String schemaName, String tableName, List<String> tableTypes) {
+ this.catalogName = catalogName;
+ this.schemaName = schemaName;
+ this.tableName = tableName;
+ this.tableTypes = tableTypes;
+ }
+
+ public String getCatalogName() {
+ return catalogName;
+ }
+
+ public void setCatalogName(String catalogName) {
+ this.catalogName = catalogName;
+ }
+
+ public String getSchemaName() {
+ return schemaName;
+ }
+
+ public void setSchemaName(String schemaName) {
+ this.schemaName = schemaName;
+ }
+
+ public String getTableName() {
+ return tableName;
+ }
+
+ public void setTableName(String tableName) {
+ this.tableName = tableName;
+ }
+
+ public List<String> getTableTypes() {
+ if (null == tableTypes) {
+ return Collections.emptyList();
+ }
+ return tableTypes;
+ }
+
+ public void setTableTypes(List<String> tableTypes) {
+ this.tableTypes = tableTypes;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ GetTablesRequest that = (GetTablesRequest) o;
+ return Objects.equals(getCatalogName(), that.getCatalogName())
+ && Objects.equals(getSchemaName(), that.getSchemaName())
+ && Objects.equals(getTableName(), that.getTableName())
+ && Objects.equals(getTableTypes(), that.getTableTypes());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getCatalogName(), getSchemaName(), getTableName(), getTableTypes());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/InfoDetail.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/InfoDetail.java
new file mode 100644
index 000000000..520a78b9a
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/InfoDetail.java
@@ -0,0 +1,62 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class InfoDetail {
+ private String infoType;
+ private String infoValue;
+
+ public InfoDetail() {}
+
+ public InfoDetail(String infoType, String infoValue) {
+ this.infoType = infoType;
+ this.infoValue = infoValue;
+ }
+
+ public String getInfoType() {
+ return infoType;
+ }
+
+ public void setInfoType(String infoType) {
+ this.infoType = infoType;
+ }
+
+ public String getInfoValue() {
+ return infoValue;
+ }
+
+ public void setInfoValue(String infoValue) {
+ this.infoValue = infoValue;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ InfoDetail that = (InfoDetail) o;
+ return Objects.equals(getInfoType(), that.getInfoType())
+ && Objects.equals(getInfoValue(), that.getInfoValue());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getInfoType(), getInfoValue());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/OpActionRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/OpActionRequest.java
new file mode 100644
index 000000000..69c17c748
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/OpActionRequest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class OpActionRequest {
+ private String action;
+
+ public OpActionRequest() {}
+
+ public OpActionRequest(String action) {
+ this.action = action;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ OpActionRequest that = (OpActionRequest) o;
+ return Objects.equals(getAction(), that.getAction());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getAction());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/OperationLog.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/OperationLog.java
new file mode 100644
index 000000000..6ef68d25f
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/OperationLog.java
@@ -0,0 +1,67 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+public class OperationLog {
+ private List<String> logRowSet;
+ private int rowCount;
+
+ public OperationLog() {}
+
+ public OperationLog(List<String> logRowSet, int rowCount) {
+ this.logRowSet = logRowSet;
+ this.rowCount = rowCount;
+ }
+
+ public List<String> getLogRowSet() {
+ if (null == logRowSet) {
+ return Collections.emptyList();
+ }
+ return logRowSet;
+ }
+
+ public void setLogRowSet(List<String> logRowSet) {
+ this.logRowSet = logRowSet;
+ }
+
+ public int getRowCount() {
+ return rowCount;
+ }
+
+ public void setRowCount(int rowCount) {
+ this.rowCount = rowCount;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ OperationLog that = (OperationLog) o;
+ return getRowCount() == that.getRowCount()
+ && Objects.equals(getLogRowSet(), that.getLogRowSet());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getLogRowSet(), getRowCount());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ResultRowSet.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ResultRowSet.java
new file mode 100644
index 000000000..67422fe5d
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ResultRowSet.java
@@ -0,0 +1,66 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+public class ResultRowSet {
+ private List<Row> rows;
+ private int rowCount;
+
+ public ResultRowSet() {}
+
+ public ResultRowSet(List<Row> rows, int rowCount) {
+ this.rows = rows;
+ this.rowCount = rowCount;
+ }
+
+ public List<Row> getRows() {
+ if (null == rows) {
+ return Collections.emptyList();
+ }
+ return rows;
+ }
+
+ public void setRows(List<Row> rows) {
+ this.rows = rows;
+ }
+
+ public int getRowCount() {
+ return rowCount;
+ }
+
+ public void setRowCount(int rowCount) {
+ this.rowCount = rowCount;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ResultRowSet that = (ResultRowSet) o;
+ return getRowCount() == that.getRowCount() && Objects.equals(getRows(), that.getRows());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getRows(), getRowCount());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ResultSetMetaData.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ResultSetMetaData.java
new file mode 100644
index 000000000..0914b68ea
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/ResultSetMetaData.java
@@ -0,0 +1,56 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+public class ResultSetMetaData {
+ private List<ColumnDesc> columns;
+
+ public ResultSetMetaData() {}
+
+ public ResultSetMetaData(List<ColumnDesc> columns) {
+ this.columns = columns;
+ }
+
+ public List<ColumnDesc> getColumns() {
+ if (null == columns) {
+ return Collections.emptyList();
+ }
+ return columns;
+ }
+
+ public void setColumns(List<ColumnDesc> columns) {
+ this.columns = columns;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ResultSetMetaData that = (ResultSetMetaData) o;
+ return Objects.equals(getColumns(), that.getColumns());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getColumns());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Row.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Row.java
new file mode 100644
index 000000000..86778381b
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/Row.java
@@ -0,0 +1,56 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+
+public class Row {
+ private List<Field> fields;
+
+ public Row() {}
+
+ public Row(List<Field> fields) {
+ this.fields = fields;
+ }
+
+ public List<Field> getFields() {
+ if (null == fields) {
+ return Collections.emptyList();
+ }
+ return fields;
+ }
+
+ public void setFields(List<Field> fields) {
+ this.fields = fields;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Row row = (Row) o;
+ return Objects.equals(getFields(), row.getFields());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getFields());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionData.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionData.java
new file mode 100644
index 000000000..864ca625c
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionData.java
@@ -0,0 +1,123 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+
+public class SessionData {
+ private SessionHandle sessionHandle;
+ private String user;
+ private String ipAddr;
+ private Map<String, String> conf;
+ private Long createTime;
+ private Long duration;
+ private Long idleTime;
+
+ public SessionData() {}
+
+ public SessionData(
+ SessionHandle sessionHandle,
+ String user,
+ String ipAddr,
+ Map<String, String> conf,
+ Long createTime,
+ Long duration,
+ Long idleTime) {
+ this.sessionHandle = sessionHandle;
+ this.user = user;
+ this.ipAddr = ipAddr;
+ this.conf = conf;
+ this.createTime = createTime;
+ this.duration = duration;
+ this.idleTime = idleTime;
+ }
+
+ public SessionHandle getSessionHandle() {
+ return sessionHandle;
+ }
+
+ public void setSessionHandle(SessionHandle sessionHandle) {
+ this.sessionHandle = sessionHandle;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public Map<String, String> getConf() {
+ if (null == conf) {
+ return Collections.emptyMap();
+ }
+ return conf;
+ }
+
+ public void setConf(Map<String, String> conf) {
+ this.conf = conf;
+ }
+
+ public Long getCreateTime() {
+ return createTime;
+ }
+
+ public void setCreateTime(Long createTime) {
+ this.createTime = createTime;
+ }
+
+ public Long getDuration() {
+ return duration;
+ }
+
+ public void setDuration(Long duration) {
+ this.duration = duration;
+ }
+
+ public Long getIdleTime() {
+ return idleTime;
+ }
+
+ public void setIdleTime(Long idleTime) {
+ this.idleTime = idleTime;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SessionData that = (SessionData) o;
+ return Objects.equals(getSessionHandle(), that.getSessionHandle());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getSessionHandle());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionHandle.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionHandle.java
new file mode 100644
index 000000000..ca10f2f93
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionHandle.java
@@ -0,0 +1,73 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+import java.util.UUID;
+
+public class SessionHandle {
+ private UUID publicId;
+ private UUID secretId;
+ private int protocolVersion;
+
+ public SessionHandle() {}
+
+ public SessionHandle(UUID publicId, UUID secretId, int protocolVersion) {
+ this.publicId = publicId;
+ this.secretId = secretId;
+ this.protocolVersion = protocolVersion;
+ }
+
+ public UUID getPublicId() {
+ return publicId;
+ }
+
+ public void setPublicId(UUID publicId) {
+ this.publicId = publicId;
+ }
+
+ public UUID getSecretId() {
+ return secretId;
+ }
+
+ public void setSecretId(UUID secretId) {
+ this.secretId = secretId;
+ }
+
+ public int getProtocolVersion() {
+ return protocolVersion;
+ }
+
+ public void setProtocolVersion(int protocolVersion) {
+ this.protocolVersion = protocolVersion;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SessionHandle that = (SessionHandle) o;
+ return Objects.equals(getPublicId(), that.getPublicId())
+ && Objects.equals(getSecretId(), that.getSecretId());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getPublicId(), getSecretId());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenCount.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenCount.java
new file mode 100644
index 000000000..99310489b
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenCount.java
@@ -0,0 +1,51 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class SessionOpenCount {
+ private int openSessionCount;
+
+ public SessionOpenCount() {}
+
+ public SessionOpenCount(int openSessionCount) {
+ this.openSessionCount = openSessionCount;
+ }
+
+ public int getOpenSessionCount() {
+ return openSessionCount;
+ }
+
+ public void setOpenSessionCount(int openSessionCount) {
+ this.openSessionCount = openSessionCount;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SessionOpenCount that = (SessionOpenCount) o;
+ return getOpenSessionCount() == that.getOpenSessionCount();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getOpenSessionCount());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenRequest.java
new file mode 100644
index 000000000..4a6ef1515
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/SessionOpenRequest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Objects;
+
+public class SessionOpenRequest {
+ private int protocolVersion;
+ private String user;
+ private String password;
+ private String ipAddr;
+ private Map<String, String> configs;
+
+ public SessionOpenRequest() {}
+
+ public SessionOpenRequest(
+ int protocolVersion,
+ String user,
+ String password,
+ String ipAddr,
+ Map<String, String> configs) {
+ this.protocolVersion = protocolVersion;
+ this.user = user;
+ this.password = password;
+ this.ipAddr = ipAddr;
+ this.configs = configs;
+ }
+
+ public int getProtocolVersion() {
+ return protocolVersion;
+ }
+
+ public void setProtocolVersion(int protocolVersion) {
+ this.protocolVersion = protocolVersion;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getIpAddr() {
+ return ipAddr;
+ }
+
+ public void setIpAddr(String ipAddr) {
+ this.ipAddr = ipAddr;
+ }
+
+ public Map<String, String> getConfigs() {
+ if (null == configs) {
+ return Collections.emptyMap();
+ }
+ return configs;
+ }
+
+ public void setConfigs(Map<String, String> configs) {
+ this.configs = configs;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ SessionOpenRequest that = (SessionOpenRequest) o;
+ return getProtocolVersion() == that.getProtocolVersion()
+ && Objects.equals(getUser(), that.getUser())
+ && Objects.equals(getPassword(), that.getPassword())
+ && Objects.equals(getIpAddr(), that.getIpAddr())
+ && Objects.equals(getConfigs(), that.getConfigs());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getProtocolVersion(), getUser(), getPassword(), getIpAddr(), getConfigs());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/StatementRequest.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/StatementRequest.java
new file mode 100644
index 000000000..079b8f16d
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/StatementRequest.java
@@ -0,0 +1,73 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class StatementRequest {
+ private String statement;
+ private boolean runAsync;
+ private Long queryTimeout;
+
+ public StatementRequest() {}
+
+ public StatementRequest(String statement, boolean runAsync, Long queryTimeout) {
+ this.statement = statement;
+ this.runAsync = runAsync;
+ this.queryTimeout = queryTimeout;
+ }
+
+ public String getStatement() {
+ return statement;
+ }
+
+ public void setStatement(String statement) {
+ this.statement = statement;
+ }
+
+ public boolean isRunAsync() {
+ return runAsync;
+ }
+
+ public void setRunAsync(boolean runAsync) {
+ this.runAsync = runAsync;
+ }
+
+ public Long getQueryTimeout() {
+ return queryTimeout;
+ }
+
+ public void setQueryTimeout(Long queryTimeout) {
+ this.queryTimeout = queryTimeout;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ StatementRequest that = (StatementRequest) o;
+ return isRunAsync() == that.isRunAsync()
+ && Objects.equals(getStatement(), that.getStatement())
+ && Objects.equals(getQueryTimeout(), that.getQueryTimeout());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getStatement(), isRunAsync(), getQueryTimeout());
+ }
+}
diff --git a/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/VersionInfo.java b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/VersionInfo.java
new file mode 100644
index 000000000..7144a3e50
--- /dev/null
+++ b/kyuubi-rest-client/src/main/java/org/apache/kyuubi/client/api/v1/dto/VersionInfo.java
@@ -0,0 +1,51 @@
+/*
+ * 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.kyuubi.client.api.v1.dto;
+
+import java.util.Objects;
+
+public class VersionInfo {
+ private String version;
+
+ public VersionInfo() {}
+
+ public VersionInfo(String version) {
+ this.version = version;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ VersionInfo that = (VersionInfo) o;
+ return Objects.equals(getVersion(), that.getVersion());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(getVersion());
+ }
+}
diff --git a/kyuubi-server/pom.xml b/kyuubi-server/pom.xml
index f7cf5fcd0..28d834bc9 100644
--- a/kyuubi-server/pom.xml
+++ b/kyuubi-server/pom.xml
@@ -68,6 +68,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.kyuubi</groupId>
+ <artifactId>kyuubi-rest-client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client-api</artifactId>
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala
index 399a5f25f..4e1826399 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/spark/SparkBatchProcessBuilder.scala
@@ -17,11 +17,12 @@
package org.apache.kyuubi.engine.spark
+import scala.collection.JavaConverters._
import scala.collection.mutable.ArrayBuffer
+import org.apache.kyuubi.client.api.v1.dto.BatchRequest
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.operation.log.OperationLog
-import org.apache.kyuubi.server.api.v1.BatchRequest
class SparkBatchProcessBuilder(
override val proxyUser: String,
@@ -32,9 +33,9 @@ class SparkBatchProcessBuilder(
extends SparkProcessBuilder(proxyUser, conf, extraEngineLog) {
import SparkProcessBuilder._
- override def mainClass: String = batchRequest.className
+ override def mainClass: String = batchRequest.getClassName
- override def mainResource: Option[String] = Option(batchRequest.resource)
+ override def mainResource: Option[String] = Option(batchRequest.getResource)
override protected val commands: Array[String] = {
val buffer = new ArrayBuffer[String]()
@@ -44,9 +45,9 @@ class SparkBatchProcessBuilder(
buffer += cla
}
- val batchJobTag = batchRequest.conf.get(TAG_KEY).map(_ + ",").getOrElse("") + batchId
+ val batchJobTag = batchRequest.getConf.asScala.get(TAG_KEY).map(_ + ",").getOrElse("") + batchId
- val allConf = batchRequest.conf ++ Map(TAG_KEY -> batchJobTag) ++ sparkAppNameConf()
+ val allConf = batchRequest.getConf.asScala ++ Map(TAG_KEY -> batchJobTag) ++ sparkAppNameConf()
allConf.foreach { case (k, v) =>
buffer += CONF
@@ -59,13 +60,13 @@ class SparkBatchProcessBuilder(
assert(mainResource.isDefined)
buffer += mainResource.get
- batchRequest.args.foreach { arg => buffer += arg }
+ batchRequest.getArgs.asScala.foreach { arg => buffer += arg }
buffer.toArray
}
private def sparkAppNameConf(): Map[String, String] = {
- Option(batchRequest.name).filterNot(_.isEmpty).map { appName =>
+ Option(batchRequest.getName).filterNot(_.isEmpty).map { appName =>
Map(APP_KEY -> appName)
}.getOrElse(Map())
}
@@ -73,6 +74,6 @@ class SparkBatchProcessBuilder(
override protected def module: String = "kyuubi-spark-batch-submit"
override def clusterManager(): Option[String] = {
- batchRequest.conf.get(MASTER_KEY).orElse(defaultMaster)
+ batchRequest.getConf.asScala.get(MASTER_KEY).orElse(defaultMaster)
}
}
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala
index 42ff2e0b8..3dd24ffbe 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala
@@ -26,12 +26,12 @@ import scala.collection.JavaConverters._
import org.apache.hive.service.rpc.thrift._
import org.apache.kyuubi.{KyuubiException, KyuubiSQLException}
+import org.apache.kyuubi.client.api.v1.dto.BatchRequest
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.engine.{ApplicationOperation, KillResponse, ProcBuilder}
import org.apache.kyuubi.engine.spark.SparkBatchProcessBuilder
import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation
import org.apache.kyuubi.operation.log.OperationLog
-import org.apache.kyuubi.server.api.v1.BatchRequest
import org.apache.kyuubi.session.{KyuubiBatchSessionImpl, KyuubiSessionManager}
import org.apache.kyuubi.util.ThriftUtils
@@ -49,21 +49,22 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
private[kyuubi] val batchId: String = session.handle.identifier.toString
- private[kyuubi] val batchType: String = batchRequest.batchType
+ private[kyuubi] val batchType: String = batchRequest.getBatchType
private val builder: ProcBuilder = {
Option(batchType).map(_.toUpperCase(Locale.ROOT)) match {
case Some("SPARK") =>
val batchSparkConf = session.sessionConf.getBatchConf("spark")
+ batchRequest.setConf((batchSparkConf ++ batchRequest.getConf.asScala).asJava)
new SparkBatchProcessBuilder(
session.user,
session.sessionConf,
batchId,
- batchRequest.copy(conf = batchSparkConf ++ batchRequest.conf),
+ batchRequest,
getOperationLog)
case _ =>
- throw new UnsupportedOperationException(s"Batch type ${batchRequest.batchType} unsupported")
+ throw new UnsupportedOperationException(s"Batch type $batchType unsupported")
}
}
@@ -111,7 +112,7 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
private def submitBatchJob(): Unit = {
try {
- info(s"Submitting ${batchRequest.batchType} batch job: $builder")
+ info(s"Submitting $batchType batch job: $builder")
val process = builder.start
var applicationStatus = currentApplicationState
while (!applicationFailed(applicationStatus) && process.isAlive) {
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/KyuubiOperationManager.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/KyuubiOperationManager.scala
index 69ebbb584..d50b6afb3 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/KyuubiOperationManager.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/operation/KyuubiOperationManager.scala
@@ -21,12 +21,12 @@ import java.util.concurrent.TimeUnit
import org.apache.hive.service.rpc.thrift.TRowSet
+import org.apache.kyuubi.client.api.v1.dto.BatchRequest
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.config.KyuubiConf.OPERATION_QUERY_TIMEOUT
import org.apache.kyuubi.metrics.MetricsConstants.OPERATION_OPEN
import org.apache.kyuubi.metrics.MetricsSystem
import org.apache.kyuubi.operation.FetchOrientation.FetchOrientation
-import org.apache.kyuubi.server.api.v1.BatchRequest
import org.apache.kyuubi.session.{KyuubiBatchSessionImpl, KyuubiSessionImpl, Session}
import org.apache.kyuubi.util.ThriftUtils
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/ApiRootResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/ApiRootResource.scala
index c555f647e..5c2639766 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/ApiRootResource.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/ApiRootResource.scala
@@ -28,6 +28,7 @@ import org.glassfish.jersey.server.ResourceConfig
import org.glassfish.jersey.servlet.ServletContainer
import org.apache.kyuubi.KYUUBI_VERSION
+import org.apache.kyuubi.client.api.v1.dto._
import org.apache.kyuubi.server.KyuubiRestFrontendService
import org.apache.kyuubi.server.api.{ApiRequestContext, FrontendServiceContext, OpenAPIConfig}
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
index ba3f4e090..901af8ae9 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/BatchesResource.scala
@@ -29,6 +29,7 @@ import io.swagger.v3.oas.annotations.tags.Tag
import org.apache.hive.service.rpc.thrift.TProtocolVersion
import org.apache.kyuubi.Logging
+import org.apache.kyuubi.client.api.v1.dto._
import org.apache.kyuubi.operation.FetchOrientation
import org.apache.kyuubi.server.api.ApiRequestContext
import org.apache.kyuubi.server.api.v1.BatchesResource.REST_BATCH_PROTOCOL
@@ -48,10 +49,10 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
private def buildBatch(session: KyuubiBatchSessionImpl): Batch = {
val batchOp = session.batchJobSubmissionOp
- Batch(
+ new Batch(
batchOp.batchId,
batchOp.batchType,
- batchOp.currentApplicationState.getOrElse(Map.empty),
+ batchOp.currentApplicationState.getOrElse(Map.empty).asJava,
fe.connectionUrl,
batchOp.getStatus.state.toString)
}
@@ -65,16 +66,16 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
@POST
@Consumes(Array(MediaType.APPLICATION_JSON))
def openBatchSession(request: BatchRequest): Batch = {
- require(request.batchType != null, "batchType is a required parameter")
- require(request.resource != null, "resource is a required parameter")
- val userName = fe.getUserName(request.conf)
+ require(request.getBatchType != null, "batchType is a required parameter")
+ require(request.getResource != null, "resource is a required parameter")
+ val userName = fe.getUserName(request.getConf.asScala.toMap)
val ipAddress = AuthenticationFilter.getUserIpAddress
val sessionHandle = sessionManager.openBatchSession(
REST_BATCH_PROTOCOL,
userName,
"anonymous",
ipAddress,
- request.conf,
+ request.getConf.asScala.toMap,
request)
buildBatch(sessionHandle)
}
@@ -115,7 +116,7 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
val batchSession = session.asInstanceOf[KyuubiBatchSessionImpl]
buildBatch(batchSession)
}
- GetBatchesResponse(from, batches.size, batches)
+ new GetBatchesResponse(from, batches.size, batches.asJava)
}
@ApiResponse(
@@ -138,7 +139,7 @@ private[v1] class BatchesResource extends ApiRequestContext with Logging {
from,
size)
val logRowSet = rowSet.getColumns.get(0).getStringVal.getValues.asScala
- OperationLog(logRowSet, logRowSet.size)
+ new OperationLog(logRowSet.asJava, logRowSet.size)
} catch {
case NonFatal(e) =>
val errorMsg = s"Error getting operation log for batchId: $batchId"
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala
index 2beaf861f..3c7ce87d0 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/OperationsResource.scala
@@ -20,7 +20,7 @@ package org.apache.kyuubi.server.api.v1
import javax.ws.rs._
import javax.ws.rs.core.{MediaType, Response}
-import scala.collection.JavaConverters.asScalaBufferConverter
+import scala.collection.JavaConverters._
import scala.util.control.NonFatal
import io.swagger.v3.oas.annotations.media.{Content, Schema}
@@ -30,6 +30,7 @@ import org.apache.hive.service.rpc.thrift._
import org.apache.kyuubi.KyuubiSQLException
import org.apache.kyuubi.Logging
+import org.apache.kyuubi.client.api.v1.dto._
import org.apache.kyuubi.events.KyuubiOperationEvent
import org.apache.kyuubi.operation.{FetchOrientation, KyuubiOperation}
import org.apache.kyuubi.operation.OperationHandle.parseOperationHandle
@@ -75,15 +76,16 @@ private[v1] class OperationsResource extends ApiRequestContext with Logging {
@PathParam("operationHandle") operationHandleStr: String): Response = {
try {
val operationHandle = parseOperationHandle(operationHandleStr)
- request.action.toLowerCase() match {
+ request.getAction.toLowerCase() match {
case "cancel" => fe.be.cancelOperation(operationHandle)
case "close" => fe.be.closeOperation(operationHandle)
- case _ => throw KyuubiSQLException(s"Invalid action ${request.action}")
+ case _ => throw KyuubiSQLException(s"Invalid action ${request.getAction}")
}
Response.ok().build()
} catch {
case NonFatal(e) =>
- val errorMsg = s"Error applying ${request.action} for operation handle $operationHandleStr"
+ val errorMsg =
+ s"Error applying ${request.getAction} for operation handle $operationHandleStr"
error(errorMsg, e)
throw new NotFoundException(errorMsg)
}
@@ -102,7 +104,7 @@ private[v1] class OperationsResource extends ApiRequestContext with Logging {
@PathParam("operationHandle") operationHandleStr: String): ResultSetMetaData = {
try {
val operationHandle = parseOperationHandle(operationHandleStr)
- ResultSetMetaData(
+ new ResultSetMetaData(
fe.be.getResultSetMetadata(operationHandle).getColumns.asScala.map(c => {
val tPrimitiveTypeEntry = c.getTypeDesc.getTypes.get(0).getPrimitiveEntry
var precision = 0
@@ -113,14 +115,14 @@ private[v1] class OperationsResource extends ApiRequestContext with Logging {
precision = qualifiers.getOrDefault("precision", defaultValue).getI32Value
scale = qualifiers.getOrDefault("scale", defaultValue).getI32Value
}
- ColumnDesc(
+ new ColumnDesc(
c.getColumnName,
tPrimitiveTypeEntry.getType.toString,
c.getPosition,
precision,
scale,
c.getComment)
- }))
+ }).asJava)
} catch {
case NonFatal(e) =>
val errorMsg = s"Error getting result set metadata for operation handle $operationHandleStr"
@@ -147,7 +149,7 @@ private[v1] class OperationsResource extends ApiRequestContext with Logging {
FetchOrientation.FETCH_NEXT,
maxRows)
val logRowSet = rowSet.getColumns.get(0).getStringVal.getValues.asScala
- OperationLog(logRowSet, logRowSet.size)
+ new OperationLog(logRowSet.asJava, logRowSet.size)
} catch {
case NonFatal(e) =>
val errorMsg = s"Error getting operation log for operation handle $operationHandleStr"
@@ -175,8 +177,8 @@ private[v1] class OperationsResource extends ApiRequestContext with Logging {
FetchOrientation.withName(fetchOrientation),
maxRows)
val rows = rowSet.getRows.asScala.map(i => {
- Row(i.getColVals.asScala.map(i => {
- Field(
+ new Row(i.getColVals.asScala.map(i => {
+ new Field(
i.getSetField.name(),
i.getSetField match {
case TColumnValue._Fields.STRING_VAL =>
@@ -194,9 +196,9 @@ private[v1] class OperationsResource extends ApiRequestContext with Logging {
case TColumnValue._Fields.I64_VAL =>
i.getI64Val.getFieldValue(TI64Value._Fields.VALUE)
})
- }))
+ }).asJava)
})
- ResultRowSet(rows, rows.size)
+ new ResultRowSet(rows.asJava, rows.size)
} catch {
case NonFatal(e) =>
val errorMsg = s"Error getting result row set for operation handle $operationHandleStr"
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
index 098f337ed..650c3c28b 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/SessionsResource.scala
@@ -20,6 +20,7 @@ package org.apache.kyuubi.server.api.v1
import javax.ws.rs._
import javax.ws.rs.core.{MediaType, Response}
+import scala.collection.JavaConverters._
import scala.util.control.NonFatal
import io.swagger.v3.oas.annotations.media.{ArraySchema, Content, Schema}
@@ -28,11 +29,12 @@ import io.swagger.v3.oas.annotations.tags.Tag
import org.apache.hive.service.rpc.thrift.{TGetInfoType, TProtocolVersion}
import org.apache.kyuubi.Logging
+import org.apache.kyuubi.client.api.v1.dto._
import org.apache.kyuubi.events.KyuubiEvent
import org.apache.kyuubi.operation.OperationHandle
import org.apache.kyuubi.server.api.ApiRequestContext
import org.apache.kyuubi.server.http.authentication.AuthenticationFilter
-import org.apache.kyuubi.session.{KyuubiSession, SessionHandle}
+import org.apache.kyuubi.session.KyuubiSession
import org.apache.kyuubi.session.SessionHandle.parseSessionHandle
@Tag(name = "Session")
@@ -50,11 +52,14 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
@GET
def sessions(): Seq[SessionData] = {
sessionManager.allSessions().map { session =>
- SessionData(
- session.handle,
+ new SessionData(
+ new SessionHandle(
+ session.handle.identifier.publicId,
+ session.handle.identifier.secretId,
+ session.handle.protocol.getValue),
session.user,
session.ipAddress,
- session.conf,
+ session.conf.asJava,
session.createTime,
session.lastAccessTime - session.createTime,
session.getNoOperationTime)
@@ -95,7 +100,7 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
try {
val info = TGetInfoType.findByValue(infoType)
val infoValue = fe.be.getInfo(parseSessionHandle(sessionHandleStr), info)
- InfoDetail(info.toString, infoValue.getStringValue)
+ new InfoDetail(info.toString, infoValue.getStringValue)
} catch {
case NonFatal(e) =>
error(s"Unrecognized GetInfoType value: $infoType", e)
@@ -112,7 +117,7 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
@GET
@Path("count")
def sessionCount(): SessionOpenCount = {
- SessionOpenCount(sessionManager.getOpenSessionCount)
+ new SessionOpenCount(sessionManager.getOpenSessionCount)
}
@ApiResponse(
@@ -124,7 +129,7 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
@GET
@Path("execPool/statistic")
def execPoolStatistic(): ExecPoolStatistic = {
- ExecPoolStatistic(
+ new ExecPoolStatistic(
sessionManager.getExecPoolSize,
sessionManager.getActiveCount)
}
@@ -138,14 +143,18 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
@POST
@Consumes(Array(MediaType.APPLICATION_JSON))
def openSession(request: SessionOpenRequest): SessionHandle = {
- val userName = fe.getUserName(request.configs)
+ val userName = fe.getUserName(request.getConfigs.asScala.toMap)
val ipAddress = AuthenticationFilter.getUserIpAddress
- fe.be.openSession(
- TProtocolVersion.findByValue(request.protocolVersion),
+ val handle = fe.be.openSession(
+ TProtocolVersion.findByValue(request.getProtocolVersion),
userName,
- request.password,
+ request.getPassword,
ipAddress,
- Option(request.configs).getOrElse(Map.empty[String, String]))
+ Option(request.getConfigs.asScala.toMap).getOrElse(Map.empty[String, String]))
+ new SessionHandle(
+ handle.identifier.publicId,
+ handle.identifier.secretId,
+ handle.protocol.getValue)
}
@ApiResponse(
@@ -174,10 +183,10 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
try {
fe.be.executeStatement(
parseSessionHandle(sessionHandleStr),
- request.statement,
+ request.getStatement,
Map.empty,
- request.runAsync,
- request.queryTimeout)
+ request.isRunAsync,
+ request.getQueryTimeout)
} catch {
case NonFatal(e) =>
val errorMsg = "Error executing statement"
@@ -239,8 +248,8 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
val sessionHandle = parseSessionHandle(sessionHandleStr)
val operationHandle = fe.be.getSchemas(
sessionHandle,
- request.catalogName,
- request.schemaName)
+ request.getCatalogName,
+ request.getSchemaName)
operationHandle
} catch {
case NonFatal(e) =>
@@ -264,10 +273,10 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
try {
fe.be.getTables(
parseSessionHandle(sessionHandleStr),
- request.catalogName,
- request.schemaName,
- request.tableName,
- request.tableTypes)
+ request.getCatalogName,
+ request.getSchemaName,
+ request.getTableName,
+ request.getTableTypes)
} catch {
case NonFatal(e) =>
val errorMsg = "Error getting tables"
@@ -309,10 +318,10 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
try {
fe.be.getColumns(
parseSessionHandle(sessionHandleStr),
- request.catalogName,
- request.schemaName,
- request.tableName,
- request.columnName)
+ request.getCatalogName,
+ request.getSchemaName,
+ request.getTableName,
+ request.getColumnName)
} catch {
case NonFatal(e) =>
val errorMsg = "Error getting columns"
@@ -335,9 +344,9 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
try {
fe.be.getFunctions(
parseSessionHandle(sessionHandleStr),
- request.catalogName,
- request.schemaName,
- request.functionName)
+ request.getCatalogName,
+ request.getSchemaName,
+ request.getFunctionName)
} catch {
case NonFatal(e) =>
val errorMsg = "Error getting functions"
@@ -360,9 +369,9 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
try {
fe.be.getPrimaryKeys(
parseSessionHandle(sessionHandleStr),
- request.catalogName,
- request.schemaName,
- request.tableName)
+ request.getCatalogName,
+ request.getSchemaName,
+ request.getTableName)
} catch {
case NonFatal(e) =>
val errorMsg = "Error getting primary keys"
@@ -385,12 +394,12 @@ private[v1] class SessionsResource extends ApiRequestContext with Logging {
try {
fe.be.getCrossReference(
parseSessionHandle(sessionHandleStr),
- request.primaryCatalog,
- request.primarySchema,
- request.primaryTable,
- request.foreignCatalog,
- request.foreignSchema,
- request.foreignTable)
+ request.getPrimaryCatalog,
+ request.getPrimarySchema,
+ request.getPrimaryTable,
+ request.getForeignCatalog,
+ request.getForeignSchema,
+ request.getForeignTable)
} catch {
case NonFatal(e) =>
val errorMsg = "Error getting cross reference"
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/dto.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/dto.scala
deleted file mode 100644
index 2b1fc4bd5..000000000
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/server/api/v1/dto.scala
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * 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.kyuubi.server.api.v1
-
-import org.apache.kyuubi.session.SessionHandle
-
-class VersionInfo(val version: String = org.apache.kyuubi.KYUUBI_VERSION)
-
-case class SessionOpenCount(openSessionCount: Int)
-
-case class ExecPoolStatistic(execPoolSize: Int, execPoolActiveCount: Int)
-
-case class SessionData(
- sessionHandle: SessionHandle,
- user: String,
- ipAddr: String,
- conf: Map[String, String],
- createTime: Long,
- duration: Long,
- idleTime: Long)
-
-case class InfoDetail(
- infoType: String,
- infoValue: String)
-
-case class SessionOpenRequest(
- protocolVersion: Int,
- user: String,
- password: String,
- ipAddr: String,
- configs: Map[String, String])
-
-case class StatementRequest(
- statement: String,
- runAsync: Boolean,
- queryTimeout: Long)
-
-case class GetSchemasRequest(
- catalogName: String,
- schemaName: String)
-
-case class GetTablesRequest(
- catalogName: String,
- schemaName: String,
- tableName: String,
- tableTypes: java.util.List[String])
-
-case class GetColumnsRequest(
- catalogName: String,
- schemaName: String,
- tableName: String,
- columnName: String)
-
-case class GetFunctionsRequest(
- catalogName: String,
- schemaName: String,
- functionName: String)
-
-case class GetPrimaryKeysRequest(
- catalogName: String,
- schemaName: String,
- tableName: String)
-
-case class GetCrossReferenceRequest(
- primaryCatalog: String,
- primarySchema: String,
- primaryTable: String,
- foreignCatalog: String,
- foreignSchema: String,
- foreignTable: String)
-
-case class OpActionRequest(action: String)
-
-case class ResultSetMetaData(columns: Seq[ColumnDesc])
-
-case class ColumnDesc(
- columnName: String,
- dataType: String,
- columnIndex: Int,
- precision: Int,
- scale: Int,
- comment: String)
-
-case class OperationLog(logRowSet: Seq[String], rowCount: Int)
-
-case class ResultRowSet(rows: Seq[Row], rowCount: Int)
-
-case class Row(fields: Seq[Field])
-
-case class Field(dataType: String, value: Any)
-
-/**
- * The request body for batch job submission.
- *
- * @param batchType the batch job type, such as spark, flink, etc. required.
- * @param resource the main resource jar, required.
- * @param className the main class name, optional.
- * @param name a name of your batch job, optional.
- * @param conf arbitrary configuration properties, optional.
- * @param args comma-separated list of batch job arguments, optional.
- */
-case class BatchRequest(
- batchType: String,
- resource: String,
- className: String,
- name: String,
- conf: Map[String, String] = Map.empty,
- args: Seq[String] = Seq.empty)
-
-case class GetBatchesResponse(
- from: Int,
- total: Int,
- batches: Seq[Batch])
-
-case class Batch(
- id: String,
- batchType: String,
- batchInfo: Map[String, String],
- kyuubiInstance: String,
- state: String)
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSessionImpl.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSessionImpl.scala
index ea21261e5..0253046c5 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSessionImpl.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiBatchSessionImpl.scala
@@ -17,14 +17,16 @@
package org.apache.kyuubi.session
+import scala.collection.JavaConverters._
+
import com.codahale.metrics.MetricRegistry
import org.apache.hive.service.rpc.thrift.TProtocolVersion
+import org.apache.kyuubi.client.api.v1.dto.BatchRequest
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.events.{EventBus, KyuubiSessionEvent}
import org.apache.kyuubi.metrics.MetricsConstants.{CONN_OPEN, CONN_TOTAL}
import org.apache.kyuubi.metrics.MetricsSystem
-import org.apache.kyuubi.server.api.v1.BatchRequest
class KyuubiBatchSessionImpl(
protocol: TProtocolVersion,
@@ -40,10 +42,13 @@ class KyuubiBatchSessionImpl(
// TODO: Support batch conf advisor
override val normalizedConf: Map[String, String] =
- sessionManager.validateBatchConf(Option(batchRequest.conf).getOrElse(Map.empty))
+ sessionManager.validateBatchConf(Option(batchRequest.getConf.asScala.toMap)
+ .getOrElse(Map.empty))
+
+ batchRequest.setConf(normalizedConf.asJava)
private[kyuubi] lazy val batchJobSubmissionOp = sessionManager.operationManager
- .newBatchJobSubmissionOperation(this, batchRequest.copy(conf = normalizedConf))
+ .newBatchJobSubmissionOperation(this, batchRequest)
private val sessionEvent = KyuubiSessionEvent(this)
EventBus.post(sessionEvent)
diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
index 8b8382cd1..9062eb8b2 100644
--- a/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
+++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/session/KyuubiSessionManager.scala
@@ -24,6 +24,7 @@ import org.apache.hive.service.rpc.thrift.TProtocolVersion
import org.apache.kyuubi.KyuubiSQLException
import org.apache.kyuubi.cli.HandleIdentifier
+import org.apache.kyuubi.client.api.v1.dto.BatchRequest
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.config.KyuubiConf._
import org.apache.kyuubi.credentials.HadoopCredentialsManager
@@ -32,7 +33,6 @@ import org.apache.kyuubi.metrics.MetricsConstants._
import org.apache.kyuubi.metrics.MetricsSystem
import org.apache.kyuubi.operation.KyuubiOperationManager
import org.apache.kyuubi.plugin.{PluginLoader, SessionConfAdvisor}
-import org.apache.kyuubi.server.api.v1.BatchRequest
class KyuubiSessionManager private (name: String) extends SessionManager(name) {
import KyuubiSessionManager._
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/WithKyuubiServerOnYarn.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/WithKyuubiServerOnYarn.scala
index e5057f088..7eb840d01 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/WithKyuubiServerOnYarn.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/WithKyuubiServerOnYarn.scala
@@ -22,6 +22,7 @@ import scala.concurrent.duration._
import org.apache.hive.service.rpc.thrift.TProtocolVersion
+import org.apache.kyuubi.client.api.v1.dto.BatchRequest
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.config.KyuubiConf._
import org.apache.kyuubi.engine.YarnApplicationOperation
@@ -29,7 +30,6 @@ import org.apache.kyuubi.engine.spark.SparkProcessBuilder
import org.apache.kyuubi.operation.{FetchOrientation, HiveJDBCTestHelper, OperationState}
import org.apache.kyuubi.operation.OperationState.ERROR
import org.apache.kyuubi.server.MiniYarnService
-import org.apache.kyuubi.server.api.v1.BatchRequest
import org.apache.kyuubi.session.{KyuubiBatchSessionImpl, KyuubiSessionManager}
/**
@@ -105,7 +105,7 @@ class KyuubiOperationYarnClusterSuite extends WithKyuubiServerOnYarn with HiveJD
test("open batch session") {
val sparkProcessBuilder = new SparkProcessBuilder("kyuubi", conf)
- val batchRequest = BatchRequest(
+ val batchRequest = new BatchRequest(
"spark",
sparkProcessBuilder.mainResource.get,
sparkProcessBuilder.mainClass,
@@ -114,15 +114,15 @@ class KyuubiOperationYarnClusterSuite extends WithKyuubiServerOnYarn with HiveJD
"spark.master" -> "yarn",
"spark.app.name" -> "customName",
s"spark.${ENGINE_SPARK_MAX_LIFETIME.key}" -> "5000",
- s"spark.${ENGINE_CHECK_INTERVAL.key}" -> "1000"),
- Seq.empty[String])
+ s"spark.${ENGINE_CHECK_INTERVAL.key}" -> "1000").asJava,
+ Seq.empty[String].asJava)
val sessionHandle = sessionManager.openBatchSession(
TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1,
"kyuubi",
"passwd",
"localhost",
- batchRequest.conf,
+ batchRequest.getConf.asScala.toMap,
batchRequest)
assert(sessionHandle.identifier.secretId === KyuubiSessionManager.STATIC_BATCH_SECRET_UUID)
@@ -172,7 +172,7 @@ class KyuubiOperationYarnClusterSuite extends WithKyuubiServerOnYarn with HiveJD
test("prevent dead loop if the batch job submission process it not alive") {
val sparkProcessBuilder = new SparkProcessBuilder("kyuubi", conf)
- val batchRequest = BatchRequest(
+ val batchRequest = new BatchRequest(
"spark",
sparkProcessBuilder.mainResource.get,
sparkProcessBuilder.mainClass,
@@ -180,15 +180,15 @@ class KyuubiOperationYarnClusterSuite extends WithKyuubiServerOnYarn with HiveJD
Map(
"spark.master" -> "invalid",
s"spark.${ENGINE_SPARK_MAX_LIFETIME.key}" -> "5000",
- s"spark.${ENGINE_CHECK_INTERVAL.key}" -> "1000"),
- Seq.empty[String])
+ s"spark.${ENGINE_CHECK_INTERVAL.key}" -> "1000").asJava,
+ Seq.empty[String].asJava)
val sessionHandle = sessionManager.openBatchSession(
TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V1,
"kyuubi",
"passwd",
"localhost",
- batchRequest.conf,
+ batchRequest.getConf.asScala.toMap,
batchRequest)
val session = sessionManager.getSession(sessionHandle).asInstanceOf[KyuubiBatchSessionImpl]
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala
index ce1c6c3b6..8bc5b076f 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/operation/KyuubiRestAuthenticationSuite.scala
@@ -22,13 +22,15 @@ import javax.servlet.http.HttpServletResponse
import javax.ws.rs.client.Entity
import javax.ws.rs.core.MediaType
+import scala.collection.JavaConverters._
+
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.security.UserGroupInformation
import org.apache.hive.service.rpc.thrift.TProtocolVersion
import org.apache.kyuubi.{KerberizedTestHelper, RestFrontendTestHelper}
+import org.apache.kyuubi.client.api.v1.dto.{SessionOpenCount, SessionOpenRequest}
import org.apache.kyuubi.config.KyuubiConf
-import org.apache.kyuubi.server.api.v1.{SessionOpenCount, SessionOpenRequest}
import org.apache.kyuubi.server.http.authentication.AuthenticationHandler.AUTHORIZATION_HEADER
import org.apache.kyuubi.service.authentication.{UserDefineAuthenticationProviderImpl, WithLdapServer}
@@ -83,7 +85,7 @@ class KyuubiRestAuthenticationSuite extends RestFrontendTestHelper with Kerberiz
assert(HttpServletResponse.SC_OK == response.getStatus)
val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
- assert(openedSessionCount.openSessionCount == 0)
+ assert(openedSessionCount.getOpenSessionCount == 0)
}
test("test with CUSTOM authorization") {
@@ -155,12 +157,12 @@ class KyuubiRestAuthenticationSuite extends RestFrontendTestHelper with Kerberiz
test("test with ugi wrapped open session") {
UserGroupInformation.loginUserFromKeytab(testPrincipal, testKeytab)
val token = generateToken(hostName)
- val sessionOpenRequest = SessionOpenRequest(
+ val sessionOpenRequest = new SessionOpenRequest(
TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V11.getValue,
"kyuubi",
"pass",
"localhost",
- Map.empty[String, String])
+ Map.empty[String, String].asJava)
val response = webTarget.path("api/v1/sessions")
.request()
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala
index 94a938478..1f0f0642a 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/KyuubiRestFrontendServiceSuite.scala
@@ -18,13 +18,13 @@
package org.apache.kyuubi.server
import org.apache.kyuubi.{KYUUBI_VERSION, RestFrontendTestHelper}
-import org.apache.kyuubi.server.api.v1.VersionInfo
+import org.apache.kyuubi.client.api.v1.dto.VersionInfo
class KyuubiRestFrontendServiceSuite extends RestFrontendTestHelper {
test("version") {
val resp = v1Call("version")
- assert(resp.readEntity(classOf[VersionInfo]).version === KYUUBI_VERSION)
+ assert(resp.readEntity(classOf[VersionInfo]).getVersion === KYUUBI_VERSION)
}
test("kyuubi REST frontend service http basic") {
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/BatchesResourceSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/BatchesResourceSuite.scala
index fec579793..856812a28 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/BatchesResourceSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/BatchesResourceSuite.scala
@@ -23,12 +23,14 @@ import java.util.UUID
import javax.ws.rs.client.Entity
import javax.ws.rs.core.MediaType
+import scala.collection.JavaConverters._
import scala.collection.mutable.ArrayBuffer
import scala.concurrent.duration.DurationInt
import org.apache.hive.service.rpc.thrift.TProtocolVersion
import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
+import org.apache.kyuubi.client.api.v1.dto._
import org.apache.kyuubi.config.KyuubiConf.{ENGINE_CHECK_INTERVAL, ENGINE_SPARK_MAX_LIFETIME}
import org.apache.kyuubi.engine.spark.SparkProcessBuilder
import org.apache.kyuubi.server.http.authentication.AuthenticationHandler.AUTHORIZATION_HEADER
@@ -54,7 +56,7 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
test("open batch session") {
val sparkProcessBuilder = new SparkProcessBuilder("kyuubi", conf)
val appName = "spark-batch-submission"
- val requestObj = BatchRequest(
+ val requestObj = new BatchRequest(
"spark",
sparkProcessBuilder.mainResource.get,
sparkProcessBuilder.mainClass,
@@ -62,31 +64,32 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
Map(
"spark.master" -> "local",
s"spark.${ENGINE_SPARK_MAX_LIFETIME.key}" -> "5000",
- s"spark.${ENGINE_CHECK_INTERVAL.key}" -> "1000"),
- Seq.empty[String])
+ s"spark.${ENGINE_CHECK_INTERVAL.key}" -> "1000").asJava,
+ Seq.empty[String].asJava)
val response = webTarget.path("api/v1/batches")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
assert(200 == response.getStatus)
var batch = response.readEntity(classOf[Batch])
- assert(batch.kyuubiInstance === fe.connectionUrl)
- assert(batch.batchType === "spark")
+ assert(batch.getKyuubiInstance === fe.connectionUrl)
+ assert(batch.getBatchType === "spark")
- val proxyUserRequest = requestObj.copy(conf = requestObj.conf ++
- Map(KyuubiAuthenticationFactory.HS2_PROXY_USER -> "root"))
+ requestObj.setConf((requestObj.getConf.asScala ++
+ Map(KyuubiAuthenticationFactory.HS2_PROXY_USER -> "root")).asJava)
+ val proxyUserRequest = requestObj
val proxyUserResponse = webTarget.path("api/v1/batches")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(proxyUserRequest, MediaType.APPLICATION_JSON_TYPE))
assert(500 == proxyUserResponse.getStatus)
- var getBatchResponse = webTarget.path(s"api/v1/batches/${batch.id}")
+ var getBatchResponse = webTarget.path(s"api/v1/batches/${batch.getId()}")
.request(MediaType.APPLICATION_JSON_TYPE)
.get()
assert(200 == getBatchResponse.getStatus)
batch = getBatchResponse.readEntity(classOf[Batch])
- assert(batch.kyuubiInstance === fe.connectionUrl)
- assert(batch.batchType === "spark")
+ assert(batch.getKyuubiInstance === fe.connectionUrl)
+ assert(batch.getBatchType === "spark")
// invalid batchId
getBatchResponse = webTarget.path(s"api/v1/batches/invalidBatchId")
@@ -95,26 +98,26 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(404 == getBatchResponse.getStatus)
// get batch log
- var logResponse = webTarget.path(s"api/v1/batches/${batch.id}/localLog")
+ var logResponse = webTarget.path(s"api/v1/batches/${batch.getId()}/localLog")
.queryParam("from", "0")
.queryParam("size", "1")
.request(MediaType.APPLICATION_JSON_TYPE)
.get()
var log = logResponse.readEntity(classOf[OperationLog])
- val head = log.logRowSet.head
- assert(log.rowCount == 1)
+ val head = log.getLogRowSet.asScala.head
+ assert(log.getRowCount == 1)
val logs = new ArrayBuffer[String]
logs.append(head)
eventually(timeout(10.seconds), interval(1.seconds)) {
- logResponse = webTarget.path(s"api/v1/batches/${batch.id}/localLog")
+ logResponse = webTarget.path(s"api/v1/batches/${batch.getId()}/localLog")
.queryParam("from", "0")
.queryParam("size", "100")
.request(MediaType.APPLICATION_JSON_TYPE)
.get()
log = logResponse.readEntity(classOf[OperationLog])
- if (log.rowCount > 0) {
- log.logRowSet.foreach(logs.append(_))
+ if (log.getRowCount > 0) {
+ log.getLogRowSet.asScala.foreach(logs.append(_))
}
// check both kyuubi log and engine log
@@ -123,8 +126,9 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
}
// invalid user name
- val encodeAuthorization = new String(Base64.getEncoder.encode(batch.id.getBytes()), "UTF-8")
- var deleteBatchResponse = webTarget.path(s"api/v1/batches/${batch.id}")
+ val encodeAuthorization =
+ new String(Base64.getEncoder.encode(batch.getId().getBytes()), "UTF-8")
+ var deleteBatchResponse = webTarget.path(s"api/v1/batches/${batch.getId()}")
.queryParam("killApp", "true")
.request(MediaType.APPLICATION_JSON_TYPE)
.header(AUTHORIZATION_HEADER, s"BASIC $encodeAuthorization")
@@ -146,14 +150,14 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(404 == deleteBatchResponse.getStatus)
// invalid proxy user
- deleteBatchResponse = webTarget.path(s"api/v1/batches/${batch.id}")
+ deleteBatchResponse = webTarget.path(s"api/v1/batches/${batch.getId()}")
.queryParam("hive.server2.proxy.user", "invalidProxy")
.request(MediaType.APPLICATION_JSON_TYPE)
.delete()
assert(405 == deleteBatchResponse.getStatus)
// killApp is true
- deleteBatchResponse = webTarget.path(s"api/v1/batches/${batch.id}")
+ deleteBatchResponse = webTarget.path(s"api/v1/batches/${batch.getId()}")
.queryParam("killApp", "true")
.request(MediaType.APPLICATION_JSON_TYPE)
.delete()
@@ -161,7 +165,7 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(deleteBatchResponse.hasEntity)
// close the closed batch session
- deleteBatchResponse = webTarget.path(s"api/v1/batches/${batch.id}")
+ deleteBatchResponse = webTarget.path(s"api/v1/batches/${batch.getId()}")
.request(MediaType.APPLICATION_JSON_TYPE)
.delete()
assert(404 == deleteBatchResponse.getStatus)
@@ -181,7 +185,7 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(response.getStatus == 200)
val getBatchListResponse = response.readEntity(classOf[GetBatchesResponse])
- assert(getBatchListResponse.batches.isEmpty && getBatchListResponse.total == 0)
+ assert(getBatchListResponse.getBatches.isEmpty && getBatchListResponse.getTotal == 0)
sessionManager.openBatchSession(
TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2,
@@ -189,7 +193,11 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
"kyuubi",
InetAddress.getLocalHost.getCanonicalHostName,
Map.empty,
- BatchRequest("spark", "", "", "", Map.empty, Seq.empty))
+ new BatchRequest(
+ "spark",
+ "",
+ "",
+ ""))
sessionManager.openSession(
TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V11,
"",
@@ -208,14 +216,22 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
"kyuubi",
InetAddress.getLocalHost.getCanonicalHostName,
Map.empty,
- BatchRequest("spark", "", "", "", Map.empty, Seq.empty))
+ new BatchRequest(
+ "spark",
+ "",
+ "",
+ ""))
sessionManager.openBatchSession(
TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2,
"kyuubi",
"kyuubi",
InetAddress.getLocalHost.getCanonicalHostName,
Map.empty,
- BatchRequest("spark", "", "", "", Map.empty, Seq.empty))
+ new BatchRequest(
+ "spark",
+ "",
+ "",
+ ""))
val response2 = webTarget.path("api/v1/batches")
.queryParam("batchType", "spark")
@@ -227,7 +243,7 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(response2.getStatus == 200)
val getBatchListResponse2 = response2.readEntity(classOf[GetBatchesResponse])
- assert(getBatchListResponse2.total == 2)
+ assert(getBatchListResponse2.getTotal == 2)
val response3 = webTarget.path("api/v1/batches")
.queryParam("batchType", "spark")
@@ -239,7 +255,7 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(response3.getStatus == 200)
val getBatchListResponse3 = response3.readEntity(classOf[GetBatchesResponse])
- assert(getBatchListResponse3.total == 1)
+ assert(getBatchListResponse3.getTotal == 1)
val response4 = webTarget.path("api/v1/batches")
.queryParam("batchType", "spark")
@@ -250,7 +266,7 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(response4.getStatus == 200)
val getBatchListResponse4 = response4.readEntity(classOf[GetBatchesResponse])
- assert(getBatchListResponse4.batches.isEmpty && getBatchListResponse4.total == 0)
+ assert(getBatchListResponse4.getBatches.isEmpty && getBatchListResponse4.getTotal == 0)
val response5 = webTarget.path("api/v1/batches")
.queryParam("batchType", "mock")
@@ -262,7 +278,7 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(response5.getStatus == 200)
val getBatchListResponse5 = response5.readEntity(classOf[GetBatchesResponse])
- assert(getBatchListResponse5.total == 0)
+ assert(getBatchListResponse5.getTotal == 0)
// TODO add more test when add more batchType
val response6 = webTarget.path("api/v1/batches")
@@ -273,7 +289,7 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(response6.getStatus == 200)
val getBatchListResponse6 = response6.readEntity(classOf[GetBatchesResponse])
- assert(getBatchListResponse6.total == 1)
+ assert(getBatchListResponse6.getTotal == 1)
sessionManager.allSessions().map(_.close())
}
@@ -283,21 +299,21 @@ class BatchesResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
// open batch session
Seq(
(
- BatchRequest(
+ new BatchRequest(
null,
sparkProcessBuilder.mainResource.get,
sparkProcessBuilder.mainClass,
"test-name"),
"batchType is a required parameter"),
(
- BatchRequest(
+ new BatchRequest(
"sp",
sparkProcessBuilder.mainResource.get,
sparkProcessBuilder.mainClass,
"test-name"),
"due to Batch type sp unsupported"),
(
- BatchRequest(
+ new BatchRequest(
"SPARK",
null,
sparkProcessBuilder.mainClass,
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala
index 87240cb6f..594196b1a 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/OperationsResourceSuite.scala
@@ -20,11 +20,14 @@ package org.apache.kyuubi.server.api.v1
import javax.ws.rs.client.Entity
import javax.ws.rs.core.MediaType
+import scala.collection.JavaConverters._
+
import org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2
import org.scalatest.concurrent.PatienceConfiguration.Timeout
import org.scalatest.time.SpanSugar.convertIntToGrainOfTime
import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
+import org.apache.kyuubi.client.api.v1.dto._
import org.apache.kyuubi.events.KyuubiOperationEvent
import org.apache.kyuubi.operation.{ExecuteStatement, OperationState, OperationType}
import org.apache.kyuubi.operation.OperationState.{FINISHED, OperationState}
@@ -64,13 +67,13 @@ class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper
s"${op.getHandle.typ.toString}"
var response = webTarget.path(s"api/v1/operations/$opHandleStr")
.request(MediaType.APPLICATION_JSON_TYPE)
- .put(Entity.entity(OpActionRequest("cancel"), MediaType.APPLICATION_JSON_TYPE))
+ .put(Entity.entity(new OpActionRequest("cancel"), MediaType.APPLICATION_JSON_TYPE))
assert(200 == response.getStatus)
checkOpState(opHandleStr, OperationState.CANCELED)
response = webTarget.path(s"api/v1/operations/$opHandleStr")
.request(MediaType.APPLICATION_JSON_TYPE)
- .put(Entity.entity(OpActionRequest("close"), MediaType.APPLICATION_JSON_TYPE))
+ .put(Entity.entity(new OpActionRequest("close"), MediaType.APPLICATION_JSON_TYPE))
assert(200 == response.getStatus)
response = webTarget.path(s"api/v1/operations/$opHandleStr/event")
.request(MediaType.APPLICATION_JSON_TYPE).get()
@@ -84,7 +87,7 @@ class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper
.request(MediaType.APPLICATION_JSON_TYPE).get()
assert(200 == response.getStatus)
val resultSetMetaData = response.readEntity(classOf[ResultSetMetaData])
- assert(resultSetMetaData.columns(1).columnName.equals("tableName"))
+ assert(resultSetMetaData.getColumns.get(1).getColumnName.equals("tableName"))
}
test("get operation log") {
@@ -96,8 +99,8 @@ class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper
.request(MediaType.APPLICATION_JSON).get()
assert(200 == response.getStatus)
val logRowSet = response.readEntity(classOf[OperationLog])
- assert(logRowSet.logRowSet.exists(_.contains("show tables")))
- assert(logRowSet.rowCount === 10)
+ assert(logRowSet.getLogRowSet.asScala.exists(_.contains("show tables")))
+ assert(logRowSet.getRowCount === 10)
}
test("test get result row set") {
@@ -111,8 +114,8 @@ class OperationsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper
.request(MediaType.APPLICATION_JSON).get()
assert(200 == response.getStatus)
val logRowSet = response.readEntity(classOf[ResultRowSet])
- assert("test".equals(logRowSet.rows.head.fields.head.value))
- assert(logRowSet.rowCount == 1)
+ assert("test".equals(logRowSet.getRows.asScala.head.getFields.asScala.head.getValue))
+ assert(logRowSet.getRowCount == 1)
}
def getOpHandleStr(typ: OperationType, statement: String = "show tables"): String = {
diff --git a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
index 5fe1361a2..e024d9a51 100644
--- a/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
+++ b/kyuubi-server/src/test/scala/org/apache/kyuubi/server/api/v1/SessionsResourceSuite.scala
@@ -21,24 +21,26 @@ import java.util
import javax.ws.rs.client.Entity
import javax.ws.rs.core.{MediaType, Response}
+import scala.collection.JavaConverters._
+
import org.apache.hive.service.rpc.thrift.TProtocolVersion.HIVE_CLI_SERVICE_PROTOCOL_V2
import org.apache.kyuubi.{KyuubiFunSuite, RestFrontendTestHelper}
+import org.apache.kyuubi.client.api.v1.dto._
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.events.KyuubiSessionEvent
import org.apache.kyuubi.operation.{OperationHandle, OperationType}
import org.apache.kyuubi.server.KyuubiServer
-import org.apache.kyuubi.session.SessionHandle
class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
test("open/close and count session") {
- val requestObj = SessionOpenRequest(
+ val requestObj = new SessionOpenRequest(
1,
"admin",
"123456",
"localhost",
- Map("testConfig" -> "testValue"))
+ Map("testConfig" -> "testValue").asJava)
var response = webTarget.path("api/v1/sessions")
.request(MediaType.APPLICATION_JSON_TYPE)
@@ -48,35 +50,37 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
val sessionHandle = response.readEntity(classOf[SessionHandle])
- assert(sessionHandle.protocol.getValue == 1)
- assert(sessionHandle.identifier != null)
+ assert(sessionHandle.getProtocolVersion == 1)
+ assert(sessionHandle.getPublicId != null)
+ assert(sessionHandle.getSecretId != null)
val statistic = webTarget.path("api/v1/sessions/execPool/statistic").request().get()
val execPoolStatistic1 = statistic.readEntity(classOf[ExecPoolStatistic])
- assert(execPoolStatistic1.execPoolSize == 1 && execPoolStatistic1.execPoolActiveCount == 1)
+ assert(execPoolStatistic1.getExecPoolSize == 1 &&
+ execPoolStatistic1.getExecPoolActiveCount == 1)
response = webTarget.path("api/v1/sessions/count").request().get()
val openedSessionCount = response.readEntity(classOf[SessionOpenCount])
- assert(openedSessionCount.openSessionCount == 1)
+ assert(openedSessionCount.getOpenSessionCount == 1)
// close an opened session
- val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
- s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+ val serializedSessionHandle = s"${sessionHandle.getPublicId}|" +
+ s"${sessionHandle.getSecretId}|${sessionHandle.getProtocolVersion}"
response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
assert(200 == response.getStatus)
response = webTarget.path("api/v1/sessions/count").request().get()
val openedSessionCount2 = response.readEntity(classOf[SessionOpenCount])
- assert(openedSessionCount2.openSessionCount == 0)
+ assert(openedSessionCount2.getOpenSessionCount == 0)
}
test("getSessionList") {
- val requestObj = SessionOpenRequest(
+ val requestObj = new SessionOpenRequest(
1,
"admin",
"123456",
"localhost",
- Map("testConfig" -> "testValue"))
+ Map("testConfig" -> "testValue").asJava)
var response = webTarget.path("api/v1/sessions")
.request(MediaType.APPLICATION_JSON_TYPE)
@@ -90,8 +94,8 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
// close an opened session
val sessionHandle = response.readEntity(classOf[SessionHandle])
- val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
- s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+ val serializedSessionHandle = s"${sessionHandle.getPublicId}|" +
+ s"${sessionHandle.getSecretId}|${sessionHandle.getProtocolVersion}"
response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle").request().delete()
assert(200 == response.getStatus)
@@ -132,27 +136,27 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
}
test("get infoType") {
- val requestObj = SessionOpenRequest(
+ val requestObj = new SessionOpenRequest(
1,
"admin",
"123456",
"localhost",
- Map("testConfig" -> "testValue"))
+ Map("testConfig" -> "testValue").asJava)
var response: Response = webTarget.path("api/v1/sessions")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
val sessionHandle = response.readEntity(classOf[SessionHandle])
- val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
- s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+ val serializedSessionHandle = s"${sessionHandle.getPublicId}|" +
+ s"${sessionHandle.getSecretId}|${sessionHandle.getProtocolVersion}"
response = webTarget.path(s"api/v1/sessions/$serializedSessionHandle/info/13")
.request().get()
assert(200 == response.getStatus)
val sessions = response.readEntity(classOf[InfoDetail])
- assert(sessions.infoType.equals("CLI_SERVER_NAME") &&
- sessions.infoValue.equals("Apache Kyuubi (Incubating)"))
+ assert(sessions.getInfoType.equals("CLI_SERVER_NAME") &&
+ sessions.getInfoValue.equals("Apache Kyuubi (Incubating)"))
// Invalid sessionHandleStr
val handle = "b88d6b56-d200-4bb6-bf0a-5da0ea572e11|0c4aad4e-ccf7-4abd-9305-943d4bfd2d9a|0"
response = webTarget.path(s"api/v1/sessions/$handle/info/13").request().get()
@@ -170,24 +174,24 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
}
test("submit operation and get operation handle") {
- val requestObj = SessionOpenRequest(
+ val requestObj = new SessionOpenRequest(
1,
"admin",
"123456",
"localhost",
- Map("testConfig" -> "testValue"))
+ Map("testConfig" -> "testValue").asJava)
var response: Response = webTarget.path("api/v1/sessions")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(requestObj, MediaType.APPLICATION_JSON_TYPE))
val sessionHandle = response.readEntity(classOf[SessionHandle])
- val serializedSessionHandle = s"${sessionHandle.identifier.publicId}|" +
- s"${sessionHandle.identifier.secretId}|${sessionHandle.protocol.getValue}"
+ val serializedSessionHandle = s"${sessionHandle.getPublicId}|" +
+ s"${sessionHandle.getSecretId}|${sessionHandle.getProtocolVersion}"
val pathPrefix = s"api/v1/sessions/$serializedSessionHandle"
- val statementReq = StatementRequest("show tables", true, 3000)
+ val statementReq = new StatementRequest("show tables", true, 3000)
response = webTarget
.path(s"$pathPrefix/operations/statement").request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(statementReq, MediaType.APPLICATION_JSON_TYPE))
@@ -208,7 +212,7 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
operationHandle = response.readEntity(classOf[OperationHandle])
assert(operationHandle.typ == OperationType.GET_CATALOGS)
- val getSchemasReq = GetSchemasRequest("spark_catalog", "default")
+ val getSchemasReq = new GetSchemasRequest("spark_catalog", "default")
response = webTarget.path(s"$pathPrefix/operations/schemas")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(getSchemasReq, MediaType.APPLICATION_JSON_TYPE))
@@ -217,7 +221,7 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
assert(operationHandle.typ == OperationType.GET_SCHEMAS)
val tableTypes = new util.ArrayList[String]()
- val getTablesReq = GetTablesRequest("spark_catalog", "default", "default", tableTypes)
+ val getTablesReq = new GetTablesRequest("spark_catalog", "default", "default", tableTypes)
response = webTarget.path(s"$pathPrefix/operations/tables")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(getTablesReq, MediaType.APPLICATION_JSON_TYPE))
@@ -231,7 +235,7 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
operationHandle = response.readEntity(classOf[OperationHandle])
assert(operationHandle.typ == OperationType.GET_TABLE_TYPES)
- val getColumnsReq = GetColumnsRequest("spark_catalog", "default", "default", "default")
+ val getColumnsReq = new GetColumnsRequest("spark_catalog", "default", "default", "default")
response = webTarget.path(s"$pathPrefix/operations/columns")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(getColumnsReq, MediaType.APPLICATION_JSON_TYPE))
@@ -239,7 +243,7 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
operationHandle = response.readEntity(classOf[OperationHandle])
assert(operationHandle.typ == OperationType.GET_COLUMNS)
- val getFunctionsReq = GetFunctionsRequest("default", "default", "default")
+ val getFunctionsReq = new GetFunctionsRequest("default", "default", "default")
response = webTarget.path(s"$pathPrefix/operations/functions")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(getFunctionsReq, MediaType.APPLICATION_JSON_TYPE))
@@ -247,13 +251,13 @@ class SessionsResourceSuite extends KyuubiFunSuite with RestFrontendTestHelper {
operationHandle = response.readEntity(classOf[OperationHandle])
assert(operationHandle.typ == OperationType.GET_FUNCTIONS)
- val getPrimaryKeysReq = GetPrimaryKeysRequest("spark_catalog", "default", "default")
+ val getPrimaryKeysReq = new GetPrimaryKeysRequest("spark_catalog", "default", "default")
response = webTarget.path(s"$pathPrefix/operations/primaryKeys")
.request(MediaType.APPLICATION_JSON_TYPE)
.post(Entity.entity(getPrimaryKeysReq, MediaType.APPLICATION_JSON_TYPE))
assert(404 == response.getStatus)
- val getCrossReferenceReq = GetCrossReferenceRequest(
+ val getCrossReferenceReq = new GetCrossReferenceRequest(
"spark_catalog",
"default",
"default",
diff --git a/pom.xml b/pom.xml
index 52f98dea6..d4af8b78e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -85,6 +85,7 @@
<module>kyuubi-hive-jdbc</module>
<module>kyuubi-hive-jdbc-shaded</module>
<module>kyuubi-metrics</module>
+ <module>kyuubi-rest-client</module>
<module>kyuubi-server</module>
<module>kyuubi-zookeeper</module>
</modules>