From a89630537328abd56b28d4420c64a2e7da01a4a8 Mon Sep 17 00:00:00 2001 From: Saisai Shao Date: Sat, 3 Dec 2016 11:11:07 +0800 Subject: [PATCH] LIVY-256. Add Gzip support for HTTP response (#238) --- .../main/java/com/cloudera/livy/client/http/HttpConf.java | 6 ++++-- .../java/com/cloudera/livy/client/http/LivyConnection.java | 7 ++++++- .../scala/com/cloudera/livy/server/SessionServlet.scala | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/client-http/src/main/java/com/cloudera/livy/client/http/HttpConf.java b/client-http/src/main/java/com/cloudera/livy/client/http/HttpConf.java index d8f661778..0993346d0 100644 --- a/client-http/src/main/java/com/cloudera/livy/client/http/HttpConf.java +++ b/client-http/src/main/java/com/cloudera/livy/client/http/HttpConf.java @@ -25,12 +25,14 @@ class HttpConf extends ClientConf { static enum Entry implements ConfEntry { - CONNETION_TIMEOUT("connection.timeout", "10s"), + CONNECTION_TIMEOUT("connection.timeout", "10s"), CONNECTION_IDLE_TIMEOUT("connection.idle.timeout", "10m"), SOCKET_TIMEOUT("connection.socket.timeout", "5m"), JOB_INITIAL_POLL_INTERVAL("job.initial_poll_interval", "100ms"), - JOB_MAX_POLL_INTERVAL("job.max_poll_interval", "5s"); + JOB_MAX_POLL_INTERVAL("job.max_poll_interval", "5s"), + + CONTENT_COMPRESS_ENABLE("content.compress.enable", true); private final String key; private final Object dflt; diff --git a/client-http/src/main/java/com/cloudera/livy/client/http/LivyConnection.java b/client-http/src/main/java/com/cloudera/livy/client/http/LivyConnection.java index 12decc029..fa5626eae 100644 --- a/client-http/src/main/java/com/cloudera/livy/client/http/LivyConnection.java +++ b/client-http/src/main/java/com/cloudera/livy/client/http/LivyConnection.java @@ -71,7 +71,7 @@ class LivyConnection { RequestConfig reqConfig = new RequestConfig() { @Override public int getConnectTimeout() { - return (int) config.getTimeAsMs(CONNETION_TIMEOUT); + return (int) config.getTimeAsMs(CONNECTION_TIMEOUT); } @Override @@ -83,6 +83,11 @@ public int getSocketTimeout() { public boolean isAuthenticationEnabled() { return true; } + + @Override + public boolean isContentCompressionEnabled() { + return config.getBoolean(CONTENT_COMPRESS_ENABLE); + } }; Credentials dummyCredentials = new Credentials() { diff --git a/server/src/main/scala/com/cloudera/livy/server/SessionServlet.scala b/server/src/main/scala/com/cloudera/livy/server/SessionServlet.scala index 7454d7fb7..36f896d39 100644 --- a/server/src/main/scala/com/cloudera/livy/server/SessionServlet.scala +++ b/server/src/main/scala/com/cloudera/livy/server/SessionServlet.scala @@ -44,6 +44,7 @@ abstract class SessionServlet[S <: Session, R <: RecoveryMetadata]( with ApiVersioningSupport with MethodOverride with UrlGeneratorSupport + with GZipSupport { /** * Creates a new session based on the current request. The implementation is responsible for