This is an automated email from the ASF dual-hosted git repository.
liuxun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/submarine.git
The following commit(s) were added to refs/heads/master by this push:
new 239db3a SUBMARINE-318. create REST API for Metadata services
239db3a is described below
commit 239db3abed54a98516a70a4b95145bdb3df192c9
Author: xunix huang <[email protected]>
AuthorDate: Thu Dec 12 15:25:42 2019 +0800
SUBMARINE-318. create REST API for Metadata services
### What is this PR for?
create REST API for Metadata services
### What type of PR is it?
Feature
### Todos
* [*] - Add Rest API for Metadata services
* [*] - Add Rest API Unit Tests
### What is the Jira issue?
https://issues.apache.org/jira/projects/SUBMARINE/issues/SUBMARINE-318
### How should this be tested?
https://travis-ci.org/hhhizzz/submarine/builds/624023753
### Questions:
* Does the licenses files need an update? No
* Are there breaking changes for older versions? No
* Does this needs documentation? No
Author: xunix huang <[email protected]>
Closes #128 from hhhizzz/master and squashes the following commits:
b66316e [xunix huang] SUBMARINE-318. create REST API for Metadata services
---
submarine-commons/commons-metastore/pom.xml | 37 ++--
submarine-server/server-core/pom.xml | 94 +++++++-
.../apache/submarine/server/SubmarineServer.java | 4 +-
.../server/metastore/rest/MetaStoreApi.java | 240 +++++++++++++++++++++
.../server/metastore/rest/MetaStoreApiTest.java | 180 ++++++++++++++++
5 files changed, 527 insertions(+), 28 deletions(-)
diff --git a/submarine-commons/commons-metastore/pom.xml
b/submarine-commons/commons-metastore/pom.xml
index 4118545..dd7b685 100644
--- a/submarine-commons/commons-metastore/pom.xml
+++ b/submarine-commons/commons-metastore/pom.xml
@@ -47,18 +47,10 @@
<version>${hive.version}</version>
<exclusions>
<exclusion>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-core</artifactId>
- </exclusion>
- <exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</exclusion>
<exclusion>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-client</artifactId>
- </exclusion>
- <exclusion>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
</exclusion>
@@ -130,6 +122,18 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-annotations</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ </exclusion>
</exclusions>
</dependency>
@@ -238,6 +242,10 @@
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
+ <exclusion>
+ <artifactId>jdk.tools</artifactId>
+ <groupId>jdk.tools</groupId>
+ </exclusion>
</exclusions>
</dependency>
@@ -319,19 +327,6 @@
</filters>
<relocations>
<relocation>
- <pattern>org</pattern>
-
<shadedPattern>${shaded.dependency.prefix}.org</shadedPattern>
- <excludes>
- <exclude>org/apache/submarine/*</exclude>
- <exclude>org/apache/submarine/**/*</exclude>
- <exclude>org/slf4j/*</exclude>
- <exclude>org/slf4j/**/*</exclude>
- <exclude>org/apache/log4j/*</exclude>
- <exclude>org/apache/log4j/**/*</exclude>
- <exclude>**/pom.xml</exclude>
- </excludes>
- </relocation>
- <relocation>
<pattern>com.google</pattern>
<shadedPattern>${shaded.dependency.prefix}.com.google</shadedPattern>
</relocation>
diff --git a/submarine-server/server-core/pom.xml
b/submarine-server/server-core/pom.xml
index beb9435..fc4f4b2 100644
--- a/submarine-server/server-core/pom.xml
+++ b/submarine-server/server-core/pom.xml
@@ -40,6 +40,94 @@
<dependency>
<groupId>org.apache.submarine</groupId>
+ <artifactId>commons-metastore</artifactId>
+ <version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.ant</groupId>
+ <artifactId>ant</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-annotations</artifactId>
+ </exclusion>
+ <exclusion>
+ <artifactId>jetty-all</artifactId>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.protobuf</groupId>
+ <artifactId>protobuf-java</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.tukaani</groupId>
+ <artifactId>xz</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.hadoop</groupId>
+ <artifactId>hadoop-auth</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>apache-curator</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-client</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.eclipse.jetty.orbit</groupId>
+ <artifactId>javax.servlet</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-guice</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.calcite.avatica</groupId>
+ <artifactId>avatica</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jsp-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.submarine</groupId>
<artifactId>server-rpc</artifactId>
<version>${project.version}</version>
<exclusions>
@@ -125,12 +213,6 @@
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${guava.version}</version>
- </dependency>
-
- <dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
diff --git
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/SubmarineServer.java
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/SubmarineServer.java
index 85828d7..f2c5c9e 100644
---
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/SubmarineServer.java
+++
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/SubmarineServer.java
@@ -113,7 +113,9 @@ public class SubmarineServer extends ResourceConfig {
@Inject
public SubmarineServer() {
packages("org.apache.submarine.server.workbench.rest",
- "org.apache.submarine.server.jobserver.rest.api");
+ "org.apache.submarine.server.jobserver.rest.api",
+ "org.apache.submarine.server.metastore.rest"
+ );
}
private static void startServer() throws InterruptedException {
diff --git
a/submarine-server/server-core/src/main/java/org/apache/submarine/server/metastore/rest/MetaStoreApi.java
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/metastore/rest/MetaStoreApi.java
new file mode 100644
index 0000000..32df0e3
--- /dev/null
+++
b/submarine-server/server-core/src/main/java/org/apache/submarine/server/metastore/rest/MetaStoreApi.java
@@ -0,0 +1,240 @@
+/*
+ * 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.submarine.server.metastore.rest;
+
+import com.google.gson.Gson;
+import com.google.gson.JsonSyntaxException;
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.InvalidInputException;
+import org.apache.hadoop.hive.metastore.api.InvalidObjectException;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.apache.hadoop.hive.metastore.api.NoSuchObjectException;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.submarine.commons.metastore.SubmarineMetaStore;
+import org.apache.submarine.commons.utils.SubmarineConfiguration;
+import org.apache.submarine.server.response.JsonResponse;
+import org.apache.submarine.server.workbench.annotation.SubmarineApi;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Response;
+import java.util.List;
+
+@Path("/metaStore")
+@Produces("application/json")
+@Singleton
+public class MetaStoreApi {
+ private static final Logger LOG =
LoggerFactory.getLogger(MetaStoreApi.class);
+ private static final Gson gson = new Gson();
+ private static final SubmarineConfiguration submarineConf =
SubmarineConfiguration.getInstance();
+ private SubmarineMetaStore submarineMetaStore = new
SubmarineMetaStore(submarineConf);
+
+ @Inject
+ public MetaStoreApi() {
+ }
+
+ @POST
+ @Path("/database/create")
+ @SubmarineApi
+ public Response createDatabase(@QueryParam("database") String databaseJson) {
+ try {
+ Database database = gson.fromJson(databaseJson, Database.class);
+ submarineMetaStore.createDatabase(database);
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new
JsonResponse.Builder<String>(Response.Status.INTERNAL_SERVER_ERROR)
+ .success(false).build();
+ } catch (JsonSyntaxException | InvalidObjectException e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<String>(Response.Status.BAD_REQUEST)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).build();
+ }
+
+ @POST
+ @Path("/table/create")
+ @SubmarineApi
+ public Response createTable(@QueryParam("database") String tableJson) {
+ try {
+ Table table = gson.fromJson(tableJson, Table.class);
+ submarineMetaStore.createTable(table);
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new
JsonResponse.Builder<String>(Response.Status.INTERNAL_SERVER_ERROR)
+ .success(false).build();
+ } catch (JsonSyntaxException | InvalidObjectException e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<String>(Response.Status.BAD_REQUEST)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).build();
+ }
+
+ @GET
+ @Path("/database/count")
+ @SubmarineApi
+ public Response getDatabaseCount() {
+ int databaseCount = -1;
+ try {
+ databaseCount = submarineMetaStore.getDatabaseCount();
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<String>(
+ Response.Status.INTERNAL_SERVER_ERROR).success(false)
+ .result(databaseCount).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).result(databaseCount).build();
+ }
+
+ @GET
+ @Path("/database/list")
+ @SubmarineApi
+ public Response listDatabases() {
+ List<String> allDatabases;
+ try {
+ allDatabases = submarineMetaStore.getAllDatabases();
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new
JsonResponse.Builder<String>(Response.Status.INTERNAL_SERVER_ERROR)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).result(allDatabases).build();
+ }
+
+ @GET
+ @Path("/database")
+ @SubmarineApi
+ public Response getDatabase(@QueryParam("database") String name) {
+ Database database;
+ try {
+ database = submarineMetaStore.getDatabase(name);
+ } catch (NoSuchObjectException e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<String>(Response.Status.NOT_FOUND)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).result(database).build();
+ }
+
+ @DELETE
+ @Path("/database")
+ @SubmarineApi
+ public Response dropDatabase(@QueryParam("database") String name) {
+ try {
+ submarineMetaStore.dropDatabase(name);
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new
JsonResponse.Builder<String>(Response.Status.INTERNAL_SERVER_ERROR)
+ .success(false).build();
+ } catch (NoSuchObjectException e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<String>(Response.Status.NOT_FOUND)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).build();
+ }
+
+ @GET
+ @Path("/table/list")
+ @SubmarineApi
+ public Response listTables(@QueryParam("database") String databaseName) {
+ List<String> tables;
+ try {
+ tables = submarineMetaStore.getAllTables(databaseName);
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new
JsonResponse.Builder<String>(Response.Status.INTERNAL_SERVER_ERROR)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).result(tables).build();
+ }
+
+ @GET
+ @Path("/table/count")
+ @SubmarineApi
+ public Response getTableCount() {
+ int tableCount;
+ try {
+ tableCount = submarineMetaStore.getTableCount();
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new
JsonResponse.Builder<String>(Response.Status.INTERNAL_SERVER_ERROR)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).result(tableCount).build();
+ }
+
+ @GET
+ @Path("/table")
+ @SubmarineApi
+ public Response getTable(@QueryParam("database") String databaseName,
+ @QueryParam("table") String tableName) {
+ Table table;
+ try {
+ table = submarineMetaStore.getTable(databaseName, tableName);
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new
JsonResponse.Builder<String>(Response.Status.INTERNAL_SERVER_ERROR)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).result(table).build();
+ }
+
+ @DELETE
+ @Path("/table")
+ @SubmarineApi
+ public Response dropTable(@QueryParam("database") String databaseName,
+ @QueryParam("table") String tableName) {
+ try {
+ submarineMetaStore.dropTable(databaseName, tableName);
+ } catch (MetaException e) {
+ LOG.error(e.getMessage(), e);
+ return new
JsonResponse.Builder<String>(Response.Status.INTERNAL_SERVER_ERROR)
+ .success(false).build();
+ } catch (NoSuchObjectException e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<String>(Response.Status.NOT_FOUND)
+ .success(false).build();
+ } catch (InvalidInputException | InvalidObjectException e) {
+ LOG.error(e.getMessage(), e);
+ return new JsonResponse.Builder<String>(Response.Status.BAD_REQUEST)
+ .success(false).build();
+ }
+ return new JsonResponse.Builder<String>(Response.Status.OK)
+ .success(true).build();
+ }
+}
diff --git
a/submarine-server/server-core/src/test/java/org/apache/submarine/server/metastore/rest/MetaStoreApiTest.java
b/submarine-server/server-core/src/test/java/org/apache/submarine/server/metastore/rest/MetaStoreApiTest.java
new file mode 100644
index 0000000..35910ab
--- /dev/null
+++
b/submarine-server/server-core/src/test/java/org/apache/submarine/server/metastore/rest/MetaStoreApiTest.java
@@ -0,0 +1,180 @@
+/*
+ * 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.submarine.server.metastore.rest;
+
+import com.google.gson.Gson;
+import org.apache.hadoop.hive.metastore.api.Database;
+import org.apache.hadoop.hive.metastore.api.PrincipalType;
+import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
+import org.apache.hadoop.hive.metastore.api.Table;
+import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.hadoop.hive.metastore.api.SerDeInfo;
+import org.apache.submarine.commons.utils.SubmarineConfiguration;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.ws.rs.core.Response;
+import java.util.Date;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+public class MetaStoreApiTest {
+ private static MetaStoreApi metaStoreApi;
+
+ @BeforeClass
+ public static void init() {
+ SubmarineConfiguration submarineConf =
SubmarineConfiguration.getInstance();
+
submarineConf.setMetastoreJdbcUrl("jdbc:mysql://127.0.0.1:3306/metastore_test?"
+
+ "useUnicode=true&" +
+ "characterEncoding=UTF-8&" +
+ "autoReconnect=true&" +
+ "failOverReadOnly=false&" +
+
"zeroDateTimeBehavior=convertToNull&" +
+ "useSSL=false");
+ submarineConf.setMetastoreJdbcUserName("metastore_test");
+ submarineConf.setMetastoreJdbcPassword("password_test");
+ metaStoreApi = new MetaStoreApi();
+ }
+
+ @Before
+ public void createDatabase() {
+ Database database = new Database();
+ database.setName("testdb");
+ database.setDescription("testdb");
+ database.setLocationUri("hdfs://mycluster/user/hive/warehouse/testdb.db");
+ Map<String, String> map = new HashMap<>();
+ map.put("key", "value");
+ database.setParameters(map);
+ database.setOwnerName("root");
+ database.setOwnerType(PrincipalType.USER);
+
+ Gson gson = new Gson();
+ String databaseJson = gson.toJson(database);
+
+ metaStoreApi.createDatabase(databaseJson);
+ Response databaseCountResponse = metaStoreApi.getDatabaseCount();
+ assertEquals(databaseCountResponse.getStatus(),
Response.Status.OK.getStatusCode());
+ assertTrue(((String)
databaseCountResponse.getEntity()).contains("\"result\":1"));
+
+ Table table = new Table();
+ table.setTableName("testtable");
+ table.setDbName("testdb");
+ table.setOwner("root");
+ table.setCreateTime((int) new java.util.Date().getTime() / 1000);
+ table.setLastAccessTime((int) new Date().getTime() / 1000);
+ table.setRetention(0);
+ StorageDescriptor sd = new StorageDescriptor();
+ List<FieldSchema> fieldSchemas = new ArrayList<>();
+ FieldSchema fieldSchema = new FieldSchema();
+ fieldSchema.setName("a");
+ fieldSchema.setType("int");
+ fieldSchema.setComment("a");
+ fieldSchemas.add(fieldSchema);
+ sd.setCols(fieldSchemas);
+ sd.setLocation("hdfs://mycluster/user/hive/warehouse/testdb.db/testtable");
+ sd.setInputFormat("org.apache.hadoop.mapred.TextInputFormat");
+
sd.setOutputFormat("org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat");
+ sd.setCompressed(false);
+ sd.setNumBuckets(-1);
+ SerDeInfo serdeInfo = new SerDeInfo();
+ serdeInfo.setName("test");
+
serdeInfo.setSerializationLib("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe");
+ Map<String, String> parametersMap = new HashMap<>();
+ parametersMap.put("serialization.format", "|");
+ parametersMap.put("field.delim", "|");
+ serdeInfo.setParameters(parametersMap);
+ sd.setSerdeInfo(serdeInfo);
+ table.setSd(sd);
+ List<FieldSchema> partitionKeys = new ArrayList<>();
+ table.setPartitionKeys(partitionKeys);
+ Map<String, String> parameters = new HashMap<>();
+ table.setParameters(parameters);
+ String viewOriginalText = "";
+ table.setViewOriginalText(viewOriginalText);
+ String viewExpandedText = "";
+ table.setViewExpandedText(viewExpandedText);
+ String tableType = "MANAGED_TABLE";
+ table.setTableType(tableType);
+
+ String tableJson = gson.toJson(table);
+ metaStoreApi.createTable(tableJson);
+
+ Response tableResponse = metaStoreApi.getTable("testdb", "testtable");
+ assertEquals(tableResponse.getStatus(),
Response.Status.OK.getStatusCode());
+ assertTrue(((String)
tableResponse.getEntity()).contains("\"tableName\":\"testtable\""));
+ Response tableCountResponse = metaStoreApi.getTableCount();
+ assertEquals(tableCountResponse.getStatus(),
Response.Status.OK.getStatusCode());
+ assertTrue(((String)
tableCountResponse.getEntity()).contains("\"result\":1"));
+ }
+
+ @After
+ public void removeAllRecord() {
+ metaStoreApi.dropTable("testdb", "testtable");
+ Response tableCountResponse = metaStoreApi.getTableCount();
+ assertEquals(tableCountResponse.getStatus(),
Response.Status.OK.getStatusCode());
+ assertTrue(((String)
tableCountResponse.getEntity()).contains("\"result\":0"));
+
+ metaStoreApi.dropDatabase("testdb");
+ Response databaseCountResponse = metaStoreApi.getDatabaseCount();
+ assertEquals(databaseCountResponse.getStatus(),
Response.Status.OK.getStatusCode());
+ assertTrue(((String)
databaseCountResponse.getEntity()).contains("\"result\":0"));
+ }
+
+ @Test
+ public void getDatabaseCount() {
+ Response response = metaStoreApi.getDatabaseCount();
+ assertTrue(((String) response.getEntity()).contains("\"result\":1"));
+ }
+
+ @Test
+ public void listDatabases() {
+ Response response = metaStoreApi.listDatabases();
+ assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ assertTrue(((String) response.getEntity()).contains("testdb"));
+ }
+
+ @Test
+ public void getDatabase() {
+ Response response = metaStoreApi.getDatabase("testdb");
+ assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ assertTrue(((String) response.getEntity()).contains("testdb"));
+ }
+
+ @Test
+ public void getAllTables() {
+ Response response = metaStoreApi.listTables("testdb");
+ assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ assertTrue(((String) response.getEntity()).contains("testtable"));
+ }
+
+ @Test
+ public void getTableCount() {
+ Response response = metaStoreApi.getTableCount();
+ assertEquals(response.getStatus(), Response.Status.OK.getStatusCode());
+ assertTrue(((String) response.getEntity()).contains("\"result\":1"));
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]