[CALCITE-1700] Further cleanup on the StandaloneServer

* Remove unnecessary dependencies
* Consolidates shade-plugin configuration
* Removes confusing re-use of 'server' package
* Fixes log4j.properties


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/5ee43784
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/5ee43784
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/5ee43784

Branch: refs/heads/branch-1.12
Commit: 5ee4378454e6b2302841d0bd0b3aba0c70a39912
Parents: 8bac70e
Author: Josh Elser <[email protected]>
Authored: Sun Mar 19 19:26:57 2017 -0400
Committer: Josh Elser <[email protected]>
Committed: Sun Mar 19 19:26:57 2017 -0400

----------------------------------------------------------------------
 avatica/standalone-server/pom.xml               |  41 ++----
 .../avatica/server/StandaloneServer.java        | 137 ------------------
 .../calcite/avatica/server/package-info.java    |  26 ----
 .../avatica/standalone/StandaloneServer.java    | 138 +++++++++++++++++++
 .../avatica/standalone/package-info.java        |  26 ++++
 .../resources/META-INF/services/java.sql.Driver |   1 -
 .../src/main/resources/log4j.properties         |   6 +-
 7 files changed, 179 insertions(+), 196 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/5ee43784/avatica/standalone-server/pom.xml
----------------------------------------------------------------------
diff --git a/avatica/standalone-server/pom.xml 
b/avatica/standalone-server/pom.xml
index c5dd24e..88bfd3b 100644
--- a/avatica/standalone-server/pom.xml
+++ b/avatica/standalone-server/pom.xml
@@ -28,6 +28,7 @@ limitations under the License.
 
   <properties>
     <top.dir>${project.basedir}/..</top.dir>
+    <shaded.pkg>org.apache.calcite.avatica.standalone.shaded</shaded.pkg>
   </properties>
 
   <dependencies>
@@ -46,14 +47,6 @@ limitations under the License.
       <artifactId>jcommander</artifactId>
     </dependency>
     <dependency>
-      <groupId>net.hydromatic</groupId>
-      <artifactId>scott-data-hsqldb</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.hsqldb</groupId>
-      <artifactId>hsqldb</artifactId>
-    </dependency>
-    <dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
@@ -124,8 +117,6 @@ limitations under the License.
               <failOnWarning>true</failOnWarning>
               <!-- ignore "unused but declared" warnings -->
               <ignoredUnusedDeclaredDependencies>
-                
<ignoredUnusedDeclaredDependency>net.hydromatic:scott-data-hsqldb</ignoredUnusedDeclaredDependency>
-                
<ignoredUnusedDeclaredDependency>org.hsqldb:hsqldb</ignoredUnusedDeclaredDependency>
                 
<ignoredUnusedDeclaredDependency>org.slf4j:slf4j-log4j12</ignoredUnusedDeclaredDependency>
                 
<ignoredUnusedDeclaredDependency>org.slf4j:slf4j-api</ignoredUnusedDeclaredDependency>
               </ignoredUnusedDeclaredDependencies>
@@ -148,51 +139,43 @@ limitations under the License.
               <relocations>
                 <relocation>
                   <pattern>com.beust</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.com.beust</shadedPattern>
+                  <shadedPattern>${shaded.pkg}.com.beust</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>com.fasterxml</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.com.fasterxml</shadedPattern>
+                  <shadedPattern>${shaded.pkg}.com.fasterxml</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>com.google.common</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.com.google.common</shadedPattern>
+                  
<shadedPattern>${shaded.pkg}.com.google.common</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>com.google.protobuf</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.com.google.protobuf</shadedPattern>
+                  
<shadedPattern>${shaded.pkg}.com.google.protobuf</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>javax.servlet</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.javax.servlet</shadedPattern>
-                </relocation>
-                <relocation>
-                  <pattern>net.hydromatic</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.net.hydromatic</shadedPattern>
+                  <shadedPattern>${shaded.pkg}.javax.servlet</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>org.apache.log4j</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.org.apache.log4j</shadedPattern>
+                  <shadedPattern>${shaded.pkg}.org.apache.log4j</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>org.eclipse.jetty</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.org.eclipse.jetty</shadedPattern>
-                </relocation>
-                <relocation>
-                  <pattern>org.hsqldb</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.org.hsqldb</shadedPattern>
+                  
<shadedPattern>${shaded.pkg}.org.eclipse.jetty</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>org.slf4j</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.org.slf4j</shadedPattern>
+                  <shadedPattern>${shaded.pkg}.org.slf4j</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>org.apache.http</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.org.apache.http</shadedPattern>
+                  <shadedPattern>${shaded.pkg}.org.apache.http</shadedPattern>
                 </relocation>
                 <relocation>
                   <pattern>org.apache.commons</pattern>
-                  
<shadedPattern>org.apache.calcite.avatica.hsqldb.shaded.org.apache.commons</shadedPattern>
+                  
<shadedPattern>${shaded.pkg}.org.apache.commons</shadedPattern>
                 </relocation>
               </relocations>
               <shadedArtifactAttached>true</shadedArtifactAttached>
@@ -208,7 +191,7 @@ limitations under the License.
                   </resources>
                 </transformer>
                 <transformer 
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
-                  
<mainClass>org.apache.calcite.avatica.hsqldb.HsqldbServer</mainClass>
+                  
<mainClass>org.apache.calcite.avatica.server.StandaloneServer</mainClass>
                 </transformer>
                 <!-- Use a custom LICENSE file -->
                 <transformer 
implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">

http://git-wip-us.apache.org/repos/asf/calcite/blob/5ee43784/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/server/StandaloneServer.java
----------------------------------------------------------------------
diff --git 
a/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/server/StandaloneServer.java
 
b/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/server/StandaloneServer.java
deleted file mode 100644
index ee80285..0000000
--- 
a/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/server/StandaloneServer.java
+++ /dev/null
@@ -1,137 +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.calcite.avatica.server;
-
-import org.apache.calcite.avatica.jdbc.JdbcMeta;
-import org.apache.calcite.avatica.remote.Driver.Serialization;
-import org.apache.calcite.avatica.remote.LocalService;
-import org.apache.calcite.avatica.util.Unsafe;
-
-import com.beust.jcommander.IStringConverter;
-import com.beust.jcommander.JCommander;
-import com.beust.jcommander.Parameter;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Locale;
-
-/**
- * An Avatica server for arbitrary JDBC drivers.
- */
-public class StandaloneServer {
-  private static final Logger LOG = 
LoggerFactory.getLogger(StandaloneServer.class);
-
-  @Parameter(names = { "-u", "--url" }, required = true,
-      description = "JDBC driver url for the server")
-  private String url;
-
-  @Parameter(names = { "-p", "--port" }, required = false,
-      description = "Port the server should bind")
-  private int port = 0;
-
-  @Parameter(names = { "-s", "--serialization" }, required = false,
-      description = "Serialization method to use", converter = 
SerializationConverter.class)
-  private Serialization serialization = Serialization.PROTOBUF;
-
-  private HttpServer server;
-
-  public void start() {
-    if (null != server) {
-      LOG.error("The server was already started");
-      Unsafe.systemExit(ExitCodes.ALREADY_STARTED.ordinal());
-      return;
-    }
-
-    try {
-      JdbcMeta meta = new JdbcMeta(url);
-      LocalService service = new LocalService(meta);
-
-      // Construct the server
-      this.server = new HttpServer.Builder()
-          .withHandler(service, serialization)
-          .withPort(port)
-          .build();
-
-      // Then start it
-      server.start();
-
-      LOG.info("Started Avatica server on port {} with serialization {}", 
server.getPort(),
-          serialization);
-    } catch (Exception e) {
-      LOG.error("Failed to start Avatica server", e);
-      Unsafe.systemExit(ExitCodes.START_FAILED.ordinal());
-    }
-  }
-
-  public void stop() {
-    if (null != server) {
-      server.stop();
-      server = null;
-    }
-  }
-
-  public void join() throws InterruptedException {
-    server.join();
-  }
-
-  public static void main(String[] args) {
-    final StandaloneServer server = new StandaloneServer();
-    new JCommander(server, args);
-
-    server.start();
-
-    // Try to clean up when the server is stopped.
-    Runtime.getRuntime().addShutdownHook(
-        new Thread(new Runnable() {
-          @Override public void run() {
-            LOG.info("Stopping server");
-            server.stop();
-            LOG.info("Server stopped");
-          }
-        }));
-
-    try {
-      server.join();
-    } catch (InterruptedException e) {
-      // Reset interruption
-      Thread.currentThread().interrupt();
-      // And exit now.
-      return;
-    }
-  }
-
-  /**
-   * Converter from String to Serialization. Must be public for JCommander.
-   */
-  public static class SerializationConverter implements 
IStringConverter<Serialization> {
-    @Override public Serialization convert(String value) {
-      return Serialization.valueOf(value.toUpperCase(Locale.ROOT));
-    }
-  }
-
-  /**
-   * Codes for exit conditions
-   */
-  private enum ExitCodes {
-    NORMAL,
-    ALREADY_STARTED, // 1
-    START_FAILED;    // 2
-  }
-}
-
-// End StandaloneServer.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/5ee43784/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/server/package-info.java
----------------------------------------------------------------------
diff --git 
a/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/server/package-info.java
 
b/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/server/package-info.java
deleted file mode 100644
index 69a4c52..0000000
--- 
a/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/server/package-info.java
+++ /dev/null
@@ -1,26 +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.
- */
-
-/**
- * Avatica Server without any authentication for any JDBC driver.
- */
-@PackageMarker
-package org.apache.calcite.avatica.server;
-
-import org.apache.calcite.avatica.util.PackageMarker;
-
-// End package-info.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/5ee43784/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java
----------------------------------------------------------------------
diff --git 
a/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java
 
b/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java
new file mode 100644
index 0000000..f658f5e
--- /dev/null
+++ 
b/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/StandaloneServer.java
@@ -0,0 +1,138 @@
+/*
+ * 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.calcite.avatica.standalone;
+
+import org.apache.calcite.avatica.jdbc.JdbcMeta;
+import org.apache.calcite.avatica.remote.Driver.Serialization;
+import org.apache.calcite.avatica.remote.LocalService;
+import org.apache.calcite.avatica.server.HttpServer;
+import org.apache.calcite.avatica.util.Unsafe;
+
+import com.beust.jcommander.IStringConverter;
+import com.beust.jcommander.JCommander;
+import com.beust.jcommander.Parameter;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Locale;
+
+/**
+ * An Avatica server for arbitrary JDBC drivers.
+ */
+public class StandaloneServer {
+  private static final Logger LOG = 
LoggerFactory.getLogger(StandaloneServer.class);
+
+  @Parameter(names = { "-u", "--url" }, required = true,
+      description = "JDBC driver url for the server")
+  private String url;
+
+  @Parameter(names = { "-p", "--port" }, required = false,
+      description = "Port the server should bind")
+  private int port = 0;
+
+  @Parameter(names = { "-s", "--serialization" }, required = false,
+      description = "Serialization method to use", converter = 
SerializationConverter.class)
+  private Serialization serialization = Serialization.PROTOBUF;
+
+  private HttpServer server;
+
+  public void start() {
+    if (null != server) {
+      LOG.error("The server was already started");
+      Unsafe.systemExit(ExitCodes.ALREADY_STARTED.ordinal());
+      return;
+    }
+
+    try {
+      JdbcMeta meta = new JdbcMeta(url);
+      LocalService service = new LocalService(meta);
+
+      // Construct the server
+      this.server = new HttpServer.Builder()
+          .withHandler(service, serialization)
+          .withPort(port)
+          .build();
+
+      // Then start it
+      server.start();
+
+      LOG.info("Started Avatica server on port {} with serialization {}", 
server.getPort(),
+          serialization);
+    } catch (Exception e) {
+      LOG.error("Failed to start Avatica server", e);
+      Unsafe.systemExit(ExitCodes.START_FAILED.ordinal());
+    }
+  }
+
+  public void stop() {
+    if (null != server) {
+      server.stop();
+      server = null;
+    }
+  }
+
+  public void join() throws InterruptedException {
+    server.join();
+  }
+
+  public static void main(String[] args) {
+    final StandaloneServer server = new StandaloneServer();
+    new JCommander(server, args);
+
+    server.start();
+
+    // Try to clean up when the server is stopped.
+    Runtime.getRuntime().addShutdownHook(
+        new Thread(new Runnable() {
+          @Override public void run() {
+            LOG.info("Stopping server");
+            server.stop();
+            LOG.info("Server stopped");
+          }
+        }));
+
+    try {
+      server.join();
+    } catch (InterruptedException e) {
+      // Reset interruption
+      Thread.currentThread().interrupt();
+      // And exit now.
+      return;
+    }
+  }
+
+  /**
+   * Converter from String to Serialization. Must be public for JCommander.
+   */
+  public static class SerializationConverter implements 
IStringConverter<Serialization> {
+    @Override public Serialization convert(String value) {
+      return Serialization.valueOf(value.toUpperCase(Locale.ROOT));
+    }
+  }
+
+  /**
+   * Codes for exit conditions
+   */
+  private enum ExitCodes {
+    NORMAL,
+    ALREADY_STARTED, // 1
+    START_FAILED;    // 2
+  }
+}
+
+// End StandaloneServer.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/5ee43784/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/package-info.java
----------------------------------------------------------------------
diff --git 
a/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/package-info.java
 
b/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/package-info.java
new file mode 100644
index 0000000..1adb260
--- /dev/null
+++ 
b/avatica/standalone-server/src/main/java/org/apache/calcite/avatica/standalone/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+/**
+ * Avatica Server without any authentication for any JDBC driver.
+ */
+@PackageMarker
+package org.apache.calcite.avatica.standalone;
+
+import org.apache.calcite.avatica.util.PackageMarker;
+
+// End package-info.java

http://git-wip-us.apache.org/repos/asf/calcite/blob/5ee43784/avatica/standalone-server/src/main/resources/META-INF/services/java.sql.Driver
----------------------------------------------------------------------
diff --git 
a/avatica/standalone-server/src/main/resources/META-INF/services/java.sql.Driver
 
b/avatica/standalone-server/src/main/resources/META-INF/services/java.sql.Driver
deleted file mode 100644
index 7b95c3f..0000000
--- 
a/avatica/standalone-server/src/main/resources/META-INF/services/java.sql.Driver
+++ /dev/null
@@ -1 +0,0 @@
-org.apache.calcite.avatica.hsqldb.shaded.org.hsqldb.jdbcDriver
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/calcite/blob/5ee43784/avatica/standalone-server/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/avatica/standalone-server/src/main/resources/log4j.properties 
b/avatica/standalone-server/src/main/resources/log4j.properties
index bc1bda9..3a661ab 100644
--- a/avatica/standalone-server/src/main/resources/log4j.properties
+++ b/avatica/standalone-server/src/main/resources/log4j.properties
@@ -17,8 +17,8 @@
 log4j.rootLogger=INFO, A1
 
 # A1 goes to the console
-log4j.appender.A1=org.apache.calcite.avatica.hsqldb.shaded.org.apache.log4j.ConsoleAppender
+log4j.appender.A1=org.apache.calcite.avatica.standalone.shaded.org.apache.log4j.ConsoleAppender
 
 # Set the pattern for each log message
-log4j.appender.A1.layout=org.apache.calcite.avatica.hsqldb.shaded.org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{2} - %m%n
\ No newline at end of file
+log4j.appender.A1.layout=org.apache.calcite.avatica.standalone.shaded.org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=%d{ISO8601} [%t] %-5p %c{2} - %m%n

Reply via email to