Skip to content

Commit

Permalink
[LIVY-491][LIVY-492][LIVY-493] Add Thriftserver module and implementa…
Browse files Browse the repository at this point in the history
…tion

## What changes were proposed in this pull request?

The PR contains an implementation of a JDBC API for Livy server based on the Hive Thriftserver. The implementation is based on the version 3.0 of Hive Thriftserver.

This initial PR contains the thriftserver module added to Livy and its implementation. It doesn't contain any binding for starting it, this will be added later.

Some Hive classes have been ported here because they needed come modifications in order to works properly in Livy. Long term solution is to get of them all by re-implementing the needed parts in the Livy thriftserver itself, without relying on Hive code (other than the PRC interface) anymore. Those classes/changes can be summarized in three categories:

 1. Changes to make the Hive classes easy to extend: for instance, some visibility modifiers were changes (moving from `private` or `package private` to `protected` or `public`);
 2. Changes in order to reduce the dependencies on Hive modules/classes: for instance all the classes in the `operation` package were modified in order to get rid of the usage of `HiveSession` and the `HiveServer2` was changed in order not to use `CLIService`.
 3. The UGI management which is currently performed in Livy is definitely very different from the Hive one, this required changes to the `HiveAuthFactory` in order not to interfere with the existing codebase.

## How was this patch tested?

added integration tests as UTs

Author: Marco Gaido <[email protected]>

Closes apache#104 from mgaido91/LIVY-491.
  • Loading branch information
mgaido91 authored and jerryshao committed Sep 10, 2018
1 parent 8027ca7 commit 7d8fa69
Show file tree
Hide file tree
Showing 35 changed files with 6,686 additions and 6 deletions.
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ env:
matrix:
include:
# Spark 2.2+ will only be verified using JDK8
- env: MVN_FLAG='-Pspark-2.2-it -DskipTests'
# Thriftserver requires JDK8
- env: MVN_FLAG='-Pthriftserver -Pspark-2.2-it -DskipTests'
jdk: oraclejdk8
- env: MVN_FLAG='-Pspark-2.2 -DskipITs'
- env: MVN_FLAG='-Pthriftserver -Pspark-2.2 -DskipITs'
jdk: oraclejdk8
- env: MVN_FLAG='-Pspark-2.3-it -DskipTests'
- env: MVN_FLAG='-Pthriftserver -Pspark-2.3-it -DskipTests'
jdk: oraclejdk8
- env: MVN_FLAG='-Pspark-2.3 -DskipITs'
- env: MVN_FLAG='-Pthriftserver -Pspark-2.3 -DskipITs'
jdk: oraclejdk8


Expand Down
1 change: 1 addition & 0 deletions checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress checks="." files="java[\\/]org[\\/]apache[\\/]hive[\\/]service"/>
</suppressions>
38 changes: 37 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<spark.scala-2.11.version>1.6.2</spark.scala-2.11.version>
<spark.scala-2.10.version>1.6.2</spark.scala-2.10.version>
<spark.version>${spark.scala-2.11.version}</spark.version>
<hive.version>3.0.0</hive.version>
<commons-codec.version>1.9</commons-codec.version>
<guava.version>15.0</guava.version>
<httpclient.version>4.5.3</httpclient.version>
Expand All @@ -92,6 +93,7 @@
<jetty.version>9.2.16.v20160414</jetty.version>
<json4s.version>3.2.10</json4s.version>
<junit.version>4.11</junit.version>
<libthrift.version>0.9.3</libthrift.version>
<kryo.version>2.22</kryo.version>
<metrics.version>3.1.0</metrics.version>
<mockito.version>1.9.5</mockito.version>
Expand Down Expand Up @@ -570,10 +572,11 @@
<version>${py4j.version}</version>
</dependency>

<!-- we need a version > 1.7.13 because of SLF4J-324 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.0</version>
<version>1.7.25</version>
</dependency>

</dependencies>
Expand Down Expand Up @@ -1077,6 +1080,39 @@
</distributionManagement>

<profiles>
<profile>
<id>thriftserver</id>
<modules>
<module>thriftserver/server</module>
</modules>
<properties>
<jetty.version>9.3.8.v20160314</jetty.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-java</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>1.8</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- Spark version profile -->
<profile>
<id>spark-1.6</id>
Expand Down
4 changes: 4 additions & 0 deletions server/src/main/scala/org/apache/livy/LivyConf.scala
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ object LivyConf {
val LAUNCH_KERBEROS_REFRESH_INTERVAL = Entry("livy.server.launch.kerberos.refresh-interval", "1h")
val KINIT_FAIL_THRESHOLD = Entry("livy.server.launch.kerberos.kinit-fail-threshold", 5)

val THRIFT_INCR_COLLECT_ENABLED = Entry("livy.server.thrift.incrementalCollect", false)
val THRIFT_SESSION_CREATION_TIMEOUT = Entry("livy.server.thrift.session.creationTimeout", "10m")
val THRIFT_SERVER_JAR_LOCATION = Entry("livy.server.thrift.jarLocation", null)

/**
* Recovery mode of Livy. Possible values:
* off: Default. Turn off recovery. Every time Livy shuts down, it stops and forgets all sessions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ class InteractiveSession(
id: Int,
appIdHint: Option[String],
appTag: String,
client: Option[RSCClient],
val client: Option[RSCClient],
initialState: SessionState,
val kind: Kind,
heartbeatTimeoutS: Int,
Expand Down
234 changes: 234 additions & 0 deletions thriftserver/server/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
<?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>
<artifactId>livy-main</artifactId>
<groupId>org.apache.livy</groupId>
<version>0.6.0-incubating-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>livy-thriftserver</artifactId>

<dependencies>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-service-rpc</artifactId>
<version>${hive.version}</version>
<exclusions>
<exclusion>
<groupId>tomcat</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-service</artifactId>
<version>${hive.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.hive</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-exec</artifactId>
<version>${hive.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.hive</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-1.2-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.hbase</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.livy</groupId>
<artifactId>livy-rsc</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.livy</groupId>
<artifactId>livy-core_${scala.binary.version}</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.livy</groupId>
<artifactId>livy-api</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.livy</groupId>
<artifactId>livy-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>${libthrift.version}</version>
</dependency>

<!-- needed for compiling successfully when using JobContext -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_${scala.binary.version}</artifactId>
<scope>provided</scope>
</dependency>

<!-- needed for testing -->
<dependency>
<groupId>org.apache.hive</groupId>
<artifactId>hive-jdbc</artifactId>
<version>${hive.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.hive</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<excludeArtifactIds>
jetty-util,
jetty-xml,
jetty-webapp
</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<outputDirectory>${project.build.directory}/jars</outputDirectory>
</configuration>
</plugin>

<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<executions>
<execution>
<id>download-spark-files</id>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<readTimeOut>60000</readTimeOut>
<retries>5</retries>
<url>${spark.bin.download.url}</url>
<outputDirectory>${project.build.directory}</outputDirectory>
<unpack>true</unpack>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<executions>
<!-- Unbind integration test from test phase and bind it to integration-test phase -->
<execution>
<id>test</id>
<phase>none</phase>
</execution>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<environmentVariables>
<LIVY_HOME>${execution.root}</LIVY_HOME>
<LIVY_TEST>false</LIVY_TEST>
<LIVY_INTEGRATION_TEST>true</LIVY_INTEGRATION_TEST>
<SPARK_HOME>${project.build.directory}/${spark.bin.name}</SPARK_HOME>
</environmentVariables>
<skipTests>${skipITs}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 7d8fa69

Please sign in to comment.