You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by ar...@apache.org on 2016/03/10 19:29:14 UTC
[2/4] incubator-trafodion git commit: Removed the unused and declared
dependencies.
Removed the unused and declared dependencies.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/7fe6dd13
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/7fe6dd13
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/7fe6dd13
Branch: refs/heads/master
Commit: 7fe6dd13600a931986769fb30c886ca6efb7c7ee
Parents: e24ea17
Author: Anuradha Hegde <an...@esgyn.com>
Authored: Sat Mar 5 17:24:44 2016 +0000
Committer: Anuradha Hegde <an...@esgyn.com>
Committed: Sat Mar 5 17:24:44 2016 +0000
----------------------------------------------------------------------
dcs/bin/dcs | 20 -
dcs/bin/dcs-config.sh | 21 -
dcs/bin/dcs-daemon.sh | 21 -
dcs/bin/dcs-daemons.sh | 20 -
dcs/pom.xml | 151 +-----
dcs/src/assembly/all.xml | 11 +-
.../org/trafodion/dcs/master/DcsMaster.java | 2 -
.../dcs/master/MasterStatusServlet.java | 22 +-
.../java/org/trafodion/dcs/rest/DcsRest.java | 215 --------
.../trafodion/dcs/rest/GetStatusResponse.java | 50 --
.../org/trafodion/dcs/rest/RESTServlet.java | 172 ------
.../org/trafodion/dcs/rest/ResourceBase.java | 34 --
.../org/trafodion/dcs/rest/ResourceConfig.java | 31 --
.../org/trafodion/dcs/rest/RestConstants.java | 63 ---
.../org/trafodion/dcs/rest/RootResource.java | 102 ----
.../org/trafodion/dcs/rest/ServerConnector.java | 79 ---
.../org/trafodion/dcs/rest/ServerResource.java | 158 ------
.../org/trafodion/dcs/rest/VersionResource.java | 122 -----
.../trafodion/dcs/rest/WorkloadResource.java | 140 -----
.../org/trafodion/dcs/rest/client/Client.java | 504 ------------------
.../org/trafodion/dcs/rest/client/Cluster.java | 102 ----
.../org/trafodion/dcs/rest/client/Response.java | 129 -----
.../trafodion/dcs/rest/model/ServerModel.java | 530 -------------------
.../trafodion/dcs/rest/model/VersionModel.java | 193 -------
.../dcs/rest/model/WorkloadListModel.java | 225 --------
.../trafodion/dcs/rest/model/WorkloadModel.java | 139 -----
.../dcs/rest/provider/JAXBContextResolver.java | 84 ---
.../producer/PlainTextMessageBodyProducer.java | 92 ----
.../dcs-webapps/master/aggr_querystats.html | 88 ---
.../dcs-webapps/master/aggr_querystats.jsp | 85 ---
.../resources/dcs-webapps/master/explain.html | 62 ---
.../resources/dcs-webapps/master/queryPlan.jsp | 77 ---
.../dcs-webapps/master/querystats.html | 89 ----
.../resources/dcs-webapps/master/querystats.jsp | 89 ----
.../resources/dcs-webapps/master/repository.jsp | 114 ----
.../resources/dcs-webapps/master/sessions.html | 87 ---
.../resources/dcs-webapps/master/sessions.jsp | 89 ----
37 files changed, 15 insertions(+), 4197 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/bin/dcs
----------------------------------------------------------------------
diff --git a/dcs/bin/dcs b/dcs/bin/dcs
index 5c506fe..84246d0 100755
--- a/dcs/bin/dcs
+++ b/dcs/bin/dcs
@@ -21,26 +21,6 @@
#
#* @@@ END COPYRIGHT @@@
# */
-#/**
-# * Copyright 2007 The Apache Software Foundation
-# *
-# * 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.
-# */
-#
# The dcs command script.
#
# Environment Variables:
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/bin/dcs-config.sh
----------------------------------------------------------------------
diff --git a/dcs/bin/dcs-config.sh b/dcs/bin/dcs-config.sh
index 023521a..aec9e57 100755
--- a/dcs/bin/dcs-config.sh
+++ b/dcs/bin/dcs-config.sh
@@ -21,27 +21,6 @@
# # @@@ END COPYRIGHT @@@
# */
#
-#/**
-# * Copyright 2007 The Apache Software Foundation
-# *
-# * 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.
-# */
-
-#
# should not be executable directly
# also should not be passed any arguments, since we need original $*
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/bin/dcs-daemon.sh
----------------------------------------------------------------------
diff --git a/dcs/bin/dcs-daemon.sh b/dcs/bin/dcs-daemon.sh
index 0061aec..530d356 100755
--- a/dcs/bin/dcs-daemon.sh
+++ b/dcs/bin/dcs-daemon.sh
@@ -21,27 +21,6 @@
#
# @@@ END COPYRIGHT @@@
# */
-#
-#/**
-# * Copyright 2007 The Apache Software Foundation
-# *
-# * 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.
-# */
-#
# Runs a DCS command as a daemon.
#
# Environment Variables
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/bin/dcs-daemons.sh
----------------------------------------------------------------------
diff --git a/dcs/bin/dcs-daemons.sh b/dcs/bin/dcs-daemons.sh
index 09fc671..1af1cad 100755
--- a/dcs/bin/dcs-daemons.sh
+++ b/dcs/bin/dcs-daemons.sh
@@ -22,26 +22,6 @@
# @@@ END COPYRIGHT @@@
# */
#
-#/**
-# * Copyright 2007 The Apache Software Foundation
-# *
-# * 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.
-# */
-#
usage="Usage: dcs-daemons.sh [--config <dcs-confdir>] \
[--hosts serversfile] [start|stop] command args..."
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/pom.xml
----------------------------------------------------------------------
diff --git a/dcs/pom.xml b/dcs/pom.xml
index 1fb2938..351c5ca 100644
--- a/dcs/pom.xml
+++ b/dcs/pom.xml
@@ -182,13 +182,6 @@
outputdir="${generated.sources}/java"
package="org.trafodion.dcs.generated.server"
webxml="${build.webapps}/server/WEB-INF/web.xml"/>
-<!--
- <mkdir dir="${build.webapps}/rest/WEB-INF"/>
- <jspcompiler uriroot="${src.webapps}/rest"
- outputdir="${generated.sources}/java"
- package="org.trafodion.dcs.generated.rest"
- webxml="${build.webapps}/rest/WEB-INF/web.xml"/>
--->
<exec executable="sh">
<arg line="${basedir}/src/saveVersion.sh ${project.version} ${generated.sources}/java"/>
</exec>
@@ -498,7 +491,7 @@
<compileSource>1.6</compileSource>
<!-- Dependencies -->
- <hadoop.version>2.6.0</hadoop.version>
+ <hadoop.version>2.6.0</hadoop.version>
<commons-cli.version>1.2</commons-cli.version>
<commons-codec.version>1.4</commons-codec.version>
<commons-io.version>2.1</commons-io.version>
@@ -508,7 +501,7 @@
<commons-configuration.version>1.6</commons-configuration.version>
<metrics-core.version>2.1.2</metrics-core.version>
<guava.version>11.0.2</guava.version>
- <jackson.version>1.8.8</jackson.version>
+ <jackson.version>1.9.13</jackson.version>
<jasper.version>5.5.23</jasper.version>
<jamon.runtime.version>2.4.0</jamon.runtime.version>
<jaxb-api.version>2.1</jaxb-api.version>
@@ -516,7 +509,7 @@
<jetty.jspapi.version>6.1.14</jetty.jspapi.version>
<jersey.version>1.8</jersey.version>
<junit.version>4.10</junit.version>
- <slf4j.version>1.4.3</slf4j.version>
+ <slf4j.version>1.4.3</slf4j.version>
<log4j.version>1.2.16</log4j.version>
<zookeeper.version>3.4.5</zookeeper.version>
<jython-standalone.version>2.5.3</jython-standalone.version>
@@ -566,16 +559,6 @@
</dependency>
<!-- General dependencies -->
- <dependency>
- <groupId>com.yammer.metrics</groupId>
- <artifactId>metrics-core</artifactId>
- <version>${metrics-core.version}</version>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${guava.version}</version>
- </dependency>
<dependency>
<groupId>org.python</groupId>
<artifactId>jython-standalone</artifactId>
@@ -587,26 +570,11 @@
<version>${commons-cli.version}</version>
</dependency>
<dependency>
- <groupId>commons-configuration</groupId>
- <artifactId>commons-configuration</artifactId>
- <version>${commons-configuration.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>${commons-codec.version}</version>
- </dependency>
- <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
<dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>${commons-lang.version}</version>
- </dependency>
- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${commons-logging.version}</version>
@@ -671,34 +639,14 @@
<version>${jetty.jspapi.version}</version>
</dependency>
<dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>servlet-api-2.5</artifactId>
- <version>${jetty.jspapi.version}</version>
+ <groupId>displaytag</groupId>
+ <artifactId>displaytag</artifactId>
+ <version>${displaytag.version}</version>
</dependency>
<!-- While jackson is also a dependency of both jersey and avro, these
can bring in jars from different, incompatible versions. We force
the same version with these dependencies -->
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
- <version>${jackson.version}</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>${jackson.version}</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-jaxrs</artifactId>
- <version>${jackson.version}</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-xc</artifactId>
- <version>${jackson.version}</version>
- </dependency>
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
@@ -708,98 +656,13 @@
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
- <dependency>
- <!--If this is not in the runtime lib, we get odd
- "2009-02-27 11:38:39.504::WARN: failed jsp
- java.lang.NoSuchFieldError: IS_SECURITY_ENABLED"
- exceptions out of jetty deploying webapps.
- St.Ack Thu May 20 01:04:41 PDT 2010
- -->
- <groupId>tomcat</groupId>
- <artifactId>jasper-compiler</artifactId>
- <version>${jasper.version}</version>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>ant</groupId>
- <artifactId>ant</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>tomcat</groupId>
- <artifactId>jasper-runtime</artifactId>
- <version>${jasper.version}</version>
- <scope>runtime</scope>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+
<dependency>
<groupId>org.jamon</groupId>
<artifactId>jamon-runtime</artifactId>
<version>${jamon.runtime.version}</version>
</dependency>
-
- <!-- REST dependencies -->
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-core</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-json</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>com.sun.jersey</groupId>
- <artifactId>jersey-server</artifactId>
- <version>${jersey.version}</version>
- </dependency>
- <dependency>
- <groupId>javax.xml.bind</groupId>
- <artifactId>jaxb-api</artifactId>
- <version>${jaxb-api.version}</version>
- <exclusions>
- <exclusion>
- <groupId>javax.xml.stream</groupId>
- <artifactId>stax-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.jettison</groupId>
- <artifactId>jettison</artifactId>
- <version>${jettison.version}</version>
- </dependency>
- <dependency>
- <groupId>displaytag</groupId>
- <artifactId>displaytag</artifactId>
- <version>${displaytag.version}</version>
- </dependency>
- <dependency>
- <groupId>displaytag</groupId>
- <artifactId>displaytag-export-poi</artifactId>
- <version>${displaytag.version}</version>
- </dependency>
</dependencies>
-
<profiles>
<!-- JDBC drivers needed for compile, but not site docs
This allows turning off dependency on command line (-P '!jdbc') -->
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/assembly/all.xml
----------------------------------------------------------------------
diff --git a/dcs/src/assembly/all.xml b/dcs/src/assembly/all.xml
index 34f2636..391cf11 100644
--- a/dcs/src/assembly/all.xml
+++ b/dcs/src/assembly/all.xml
@@ -78,10 +78,13 @@
<outputDirectory>/lib</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
- <excludes>
- <exclude>tomcat:jasper-runtime</exclude>
- <exclude>org.trafodion:dcs</exclude>
- </excludes>
+ <includes>
+ <include>displaytag:displaytag</include>
+ <include>org.python:jython-standalone</include>
+ <include>org.slf4j:slf4j-log4j12</include>
+ <include>org.slf4j:slf4j-api</include>
+ <include>org.mortbay.jetty</include>
+ </includes>
<fileMode>0644</fileMode>
<directoryMode>0644</directoryMode>
</dependencySet>
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java b/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java
index 1c35065..719c3d3 100644
--- a/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java
+++ b/dcs/src/main/java/org/trafodion/dcs/master/DcsMaster.java
@@ -61,7 +61,6 @@ import org.trafodion.dcs.util.VersionInfo;
import org.trafodion.dcs.zookeeper.ZkClient;
import org.trafodion.dcs.zookeeper.ZKConfig;
import org.trafodion.dcs.master.listener.ListenerService;
-import org.trafodion.dcs.rest.DcsRest;
public class DcsMaster implements Runnable {
private static final Log LOG = LogFactory.getLog(DcsMaster.class);
@@ -74,7 +73,6 @@ public class DcsMaster implements Runnable {
private int port;
private int portRange;
private InfoServer infoServer;
- private DcsRest restServer;
private String serverName;
private int infoPort;
private long startTime;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java b/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java
index 6b02123..4a031b8 100644
--- a/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java
+++ b/dcs/src/main/java/org/trafodion/dcs/master/MasterStatusServlet.java
@@ -19,27 +19,7 @@ specific language governing permissions and limitations
under the License.
* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2007 The Apache Software Foundation
- *
- * 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.trafodion.dcs.master;
import java.io.IOException;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/DcsRest.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/DcsRest.java b/dcs/src/main/java/org/trafodion/dcs/rest/DcsRest.java
deleted file mode 100644
index 046b308..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/DcsRest.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2011 The Apache Software Foundation
- *
- * 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.trafodion.dcs.rest;
-
-import java.util.List;
-import java.util.ArrayList;
-import java.io.IOException;
-import java.lang.InterruptedException;
-
-import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.Options;
-import org.apache.commons.cli.PosixParser;
-import org.apache.commons.cli.ParseException;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.net.DNS;
-
-import org.trafodion.dcs.util.DcsConfiguration;
-import org.trafodion.dcs.util.Strings;
-import org.trafodion.dcs.util.VersionInfo;
-
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.ServletHolder;
-import org.mortbay.thread.QueuedThreadPool;
-
-import com.sun.jersey.spi.container.servlet.ServletContainer;
-
-public class DcsRest implements Runnable, RestConstants {
- private static final Log LOG = LogFactory.getLog(DcsRest.class.getName());
- private Configuration conf;
- private Thread thrd;
- private String[] args;
- private RESTServlet servlet;
-
- private static void printUsageAndExit(Options options, int exitCode) {
- HelpFormatter formatter = new HelpFormatter();
- formatter.printHelp("bin/dcs rest start", "", options,
- "\nTo run the REST server as a daemon, execute " +
- "bin/dcs-daemon.sh start|stop rest [--infoport <port>] [-p <port>] [-ro]\n", true);
- System.exit(exitCode);
- }
-
- public DcsRest(String[] args) {
- this.args = args;
- conf = DcsConfiguration.create();
-
- Options options = new Options();
- options.addOption("p", "port", true, "Port to bind to [default: 8080]");
- options.addOption("ro", "readonly", false, "Respond only to GET HTTP " +
- "method requests [default: false]");
- options.addOption(null, "infoport", true, "Port for web UI");
-
- try {
- servlet = RESTServlet.getInstance(conf);
- } catch (IOException e) {
- LOG.error("Exception " + e);
- e.printStackTrace();
- }
-
- CommandLine commandLine = null;
- try {
- commandLine = new PosixParser().parse(options, args);
- } catch (ParseException e) {
- LOG.error("Could not parse: ", e);
- printUsageAndExit(options, -1);
- }
-
- // check for user-defined port setting, if so override the conf
- if (commandLine != null && commandLine.hasOption("port")) {
- String val = commandLine.getOptionValue("port");
- servlet.getConfiguration().setInt("dcs.rest.port", Integer.valueOf(val));
- LOG.debug("port set to " + val);
- }
-
- // check if server should only process GET requests, if so override the conf
- if (commandLine != null && commandLine.hasOption("readonly")) {
- servlet.getConfiguration().setBoolean("dcs.rest.readonly", true);
- LOG.debug("readonly set to true");
- }
-
- // check for user-defined info server port setting, if so override the conf
- if (commandLine != null && commandLine.hasOption("infoport")) {
- String val = commandLine.getOptionValue("infoport");
- servlet.getConfiguration().setInt("dcs.rest.info.port", Integer.valueOf(val));
- LOG.debug("Web UI port set to " + val);
- }
-
- @SuppressWarnings("unchecked")
- List<String> remainingArgs = commandLine != null ? commandLine.getArgList() : new ArrayList<String>();
- if (remainingArgs.size() != 1) {
- printUsageAndExit(options, 1);
- }
-
- String command = remainingArgs.get(0);
- if ("start".equals(command)) {
- // continue and start container
- } else if ("stop".equals(command)) {
- System.exit(1);
- } else {
- printUsageAndExit(options, 1);
- }
-
- thrd = new Thread(this);
- thrd.start();
- }
-
- public DcsRest(Configuration conf) {
- try {
- servlet = RESTServlet.getInstance(conf);
- } catch (IOException e) {
- LOG.error("Exception " + e);
- e.printStackTrace();
- return;
- }
-
- thrd = new Thread(this);
- thrd.start();
- }
-
- public void run() {
- VersionInfo.logVersion();
-
- // set up the Jersey servlet container for Jetty
- ServletHolder sh = new ServletHolder(ServletContainer.class);
- sh.setInitParameter(
- "com.sun.jersey.config.property.resourceConfigClass",
- ResourceConfig.class.getCanonicalName());
- sh.setInitParameter("com.sun.jersey.config.property.packages","org.trafodion.dcs.rest");
-
- // set up Jetty and run the embedded server
- Server server = new Server();
-
- Connector connector = new SelectChannelConnector();
- connector.setPort(servlet.getConfiguration().getInt("dcs.rest.port", 8080));
- connector.setHost(servlet.getConfiguration().get("dcs.rest.host", "0.0.0.0"));
-
- server.addConnector(connector);
-
- // Set the default max thread number to 100 to limit
- // the number of concurrent requests so that REST server doesn't OOM easily.
- // Jetty set the default max thread number to 250, if we don't set it.
- //
- // Our default min thread number 2 is the same as that used by Jetty.
- int maxThreads = servlet.getConfiguration().getInt("dcs.rest.threads.max", 100);
- int minThreads = servlet.getConfiguration().getInt("dcs.rest.threads.min", 2);
- QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads);
- threadPool.setMinThreads(minThreads);
- server.setThreadPool(threadPool);
- server.setSendServerVersion(false);
- server.setSendDateHeader(false);
- server.setStopAtShutdown(true);
-
- Context context = new Context(server, "/", Context.SESSIONS);
- context.addServlet(sh, "/*");
-
- try {
- server.start();
- server.join();
- } catch (InterruptedException e) {
- LOG.error("InterruptedException " + e);
- } catch (Exception e) {
- LOG.error("Exception " + e);
- }
- }
-
- public static void main(String[] args) throws Exception {
- DcsRest server = new DcsRest(args);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/GetStatusResponse.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/GetStatusResponse.java b/dcs/src/main/java/org/trafodion/dcs/rest/GetStatusResponse.java
deleted file mode 100644
index c8ee6c4..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/GetStatusResponse.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-package org.trafodion.dcs.rest;
-
-import java.io.IOException;
-
-import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlElement;
-
-@XmlRootElement
-public class GetStatusResponse {
- private String workloadId;
-
- public GetStatusResponse(){
- };
-
- public GetStatusResponse(String value){
- workloadId = value;
- };
-
- @XmlElement
- public String getWorkloadId() {
- return workloadId;
- }
-
- public void setWorkloadId(String value) {
- this.workloadId = value;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/RESTServlet.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/RESTServlet.java b/dcs/src/main/java/org/trafodion/dcs/rest/RESTServlet.java
deleted file mode 100644
index 13016b4..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/RESTServlet.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2007 The Apache Software Foundation
- *
- * 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.trafodion.dcs.rest;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.StringTokenizer;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.trafodion.dcs.Constants;
-import org.trafodion.dcs.rest.ServerConnector;
-import org.trafodion.dcs.rest.RestConstants;
-import org.trafodion.dcs.zookeeper.ZkClient;
-
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.ZooDefs;
-
-import org.apache.hadoop.conf.Configuration;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-/**
- * Singleton class encapsulating global REST servlet state and functions.
- */
-public class RESTServlet implements RestConstants {
- private static final Log LOG = LogFactory.getLog(RESTServlet.class);
- private static RESTServlet INSTANCE;
- private final Configuration conf;
- private static ZkClient zkc;
- private String parentZnode;
- private Map<String, ServerConnector> m = new HashMap<String, ServerConnector>();
-
- /**
- * @return the RESTServlet singleton instance
- * @throws IOException
- */
- public synchronized static RESTServlet getInstance()
- throws IOException {
- assert(INSTANCE != null);
- return INSTANCE;
- }
-
- /**
- * @param conf Existing configuration to use in rest servlet
- * @return the RESTServlet singleton instance
- * @throws IOException
- */
- public synchronized static RESTServlet getInstance(Configuration conf)
- throws IOException {
- if (INSTANCE == null) {
- INSTANCE = new RESTServlet(conf);
- }
- return INSTANCE;
- }
-
- public ZkClient getZk(){
- return this.zkc;
- }
-
- public String getParentZnode(){
- return this.parentZnode;
- }
-
- public synchronized static void stop() {
- if (INSTANCE != null) INSTANCE = null;
- }
-
- /**
- * Constructor with existing configuration
- * @param conf existing configuration
- * @throws IOException.
- */
- RESTServlet(Configuration conf) throws IOException {
- this.conf = conf;
- this.parentZnode = conf.get(Constants.ZOOKEEPER_ZNODE_PARENT,Constants.DEFAULT_ZOOKEEPER_ZNODE_PARENT);
-
- }
-
- private void openZk() throws IOException {
- try {
- if(zkc == null)
- zkc = new ZkClient();//CTRL-C...set sessionTimeout,maxRetries,retryIntervalMillis
- zkc.connect();
- } catch (InterruptedException e) {
- LOG.error(e);
- }
- }
-
- public synchronized List<String> getChildren(String znode) throws IOException {
- List<String> s = null;
-
- try {
- openZk();
- s = zkc.getChildren(znode,null);
- } catch (InterruptedException e) {
- LOG.error(e);
- } catch (KeeperException e) {
- LOG.error(e);
- } catch (NullPointerException e) {
- LOG.error(e);
- }
-
- return s;
- }
-
- public synchronized List<String> getMaster() throws IOException {
- return getChildren(parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER);
- }
- public synchronized List<String> getRunning() throws IOException {
- return getChildren(parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING);
- }
- public synchronized List<String> getRegistered() throws IOException {
- return getChildren(parentZnode + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_REGISTERED);
- }
-
- Configuration getConfiguration() {
- return conf;
- }
-
- /**
- * Helper method to determine if server should
- * only respond to GET HTTP method requests.
- * @return boolean for server read-only state
- */
- boolean isReadOnly() {
- return getConfiguration().getBoolean("dcs.rest.readonly", false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/ResourceBase.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/ResourceBase.java b/dcs/src/main/java/org/trafodion/dcs/rest/ResourceBase.java
deleted file mode 100644
index 00d64eb..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/ResourceBase.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-package org.trafodion.dcs.rest;
-
-import java.io.IOException;
-
-public class ResourceBase implements RestConstants {
-
- RESTServlet servlet;
-
- public ResourceBase() throws IOException {
- servlet = RESTServlet.getInstance();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/ResourceConfig.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/ResourceConfig.java b/dcs/src/main/java/org/trafodion/dcs/rest/ResourceConfig.java
deleted file mode 100644
index 32a211e..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/ResourceConfig.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-package org.trafodion.dcs.rest;
-
-import com.sun.jersey.api.core.PackagesResourceConfig;
-
-public class ResourceConfig extends PackagesResourceConfig {
- public ResourceConfig() {
- super("org.trafodion.dcs.rest");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/RestConstants.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/RestConstants.java b/dcs/src/main/java/org/trafodion/dcs/rest/RestConstants.java
deleted file mode 100644
index 1eee4df..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/RestConstants.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-/**
- * Copyright 2007 The Apache Software Foundation
- *
- * 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.trafodion.dcs.rest;
-
-/**
- * Common constants for org.trafodion.dcs.rest
- */
-public interface RestConstants {
- public static final String VERSION_STRING = "0.0.2";
-
- public static final int DEFAULT_MAX_AGE = 60 * 60 * 4; // 4 hours
-
- public static final int DEFAULT_LISTEN_PORT = 8080;
-
- public static final String MIMETYPE_TEXT = "text/plain";
- public static final String MIMETYPE_HTML = "text/html";
- public static final String MIMETYPE_XML = "text/xml";
- public static final String MIMETYPE_BINARY = "application/octet-stream";
- public static final String MIMETYPE_PROTOBUF = "application/x-protobuf";
- public static final String MIMETYPE_PROTOBUF_IETF = "application/protobuf";
- public static final String MIMETYPE_JSON = "application/json";
-
- public static final String CRLF = "\r\n";
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/RootResource.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/RootResource.java b/dcs/src/main/java/org/trafodion/dcs/rest/RootResource.java
deleted file mode 100644
index eb9d0dc..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/RootResource.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-package org.trafodion.dcs.rest;
-
-import java.io.*;
-import java.util.*;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.trafodion.dcs.Constants;
-import org.trafodion.dcs.util.Bytes;
-import org.trafodion.dcs.rest.RestConstants;
-
-@Path("/")
-public class RootResource extends ResourceBase {
- private static final Log LOG = LogFactory.getLog(RootResource.class);
-
- static CacheControl cacheControl;
- static {
- cacheControl = new CacheControl();
- cacheControl.setNoCache(true);
- cacheControl.setNoTransform(false);
- }
-
- public RootResource() throws IOException {
- super();
- }
-
- @GET
- @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON})
- public Response get(final @Context UriInfo uriInfo) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("GET " + uriInfo.getAbsolutePath());
- }
-
- try {
- return new WorkloadResource().get(uriInfo);
- } catch (IOException e) {
- return Response.status(Response.Status.SERVICE_UNAVAILABLE)
- .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
- .build();
- }
-
- }
-
- @Path("/v1/servers")
- public ServerResource getServerResource() throws IOException {
- //To test:
- //curl -v -X GET -H "Accept: application/json" http://<DcsMaster IP address>:8080/v1/servers
- //
- return new ServerResource();
- }
-
- @Path("/v1/workloads")
- public WorkloadResource getWorkloadResource() throws IOException {
- //To test:
- //curl -v -X GET -H "Accept: application/json" http://<DcsMaster IP address>:8080/v1/workloads
- //
- return new WorkloadResource();
- }
-
- @Path("/v1/version")
- public VersionResource getVersionResource() throws IOException {
- //To test:
- //curl -v -X GET -H "Accept: application/json" http://<DcsMaster IP address>:8080/v1/version
- //
- return new VersionResource();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/ServerConnector.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/ServerConnector.java b/dcs/src/main/java/org/trafodion/dcs/rest/ServerConnector.java
deleted file mode 100644
index 35cafd9..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/ServerConnector.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-package org.trafodion.dcs.rest;
-
-import java.io.IOException;
-import java.net.InetSocketAddress;
-import java.util.StringTokenizer;
-import java.util.List;
-import java.util.Iterator;
-import java.util.HashMap;
-import java.util.Map;
-
-//import org.apache.avro.ipc.NettyTransceiver;
-//import org.apache.avro.ipc.Transceiver;
-//import org.apache.avro.ipc.specific.SpecificRequestor;
-//import org.apache.avro.AvroRemoteException;
-
-import org.trafodion.dcs.Constants;
-import org.trafodion.dcs.rest.RestConstants;
-import org.trafodion.dcs.zookeeper.ZkClient;
-
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.ZooDefs;
-
-import org.apache.hadoop.conf.Configuration;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-public class ServerConnector {
- private static final Log LOG = LogFactory.getLog(ServerConnector.class);
-// private Transceiver transceiver;
-// private Workload client;
-// private WorkloadListRequest request;
-/*
- public ServerConnector(String ipAddr,int port) throws IOException {
- try {
- transceiver = new NettyTransceiver(new InetSocketAddress(ipAddr,port));
- client = SpecificRequestor.getClient(Workload.class, transceiver);
-// request = WorkloadListRequest.newBuilder().build();
-
- } catch (AvroRemoteException e) {
- LOG.error(e);
- }
- }
-
- public WorkloadListResponse getWorkloadListResponse() {
- WorkloadListResponse response = null;
- try {
- response = client.list(request);
- } catch (AvroRemoteException e) {
- LOG.error(e);
- }
- return response;
- }
-*/
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/ServerResource.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/ServerResource.java b/dcs/src/main/java/org/trafodion/dcs/rest/ServerResource.java
deleted file mode 100644
index 5a39050..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/ServerResource.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/**********************************************************************
-* @@@ START COPYRIGHT @@@
-*
-* 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.
-*
-* @@@ END COPYRIGHT @@@
-**********************************************************************/
-
-package org.trafodion.dcs.rest;
-
-import java.io.*;
-import java.util.*;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.data.Stat;
-
-import org.trafodion.dcs.Constants;
-import org.trafodion.dcs.util.Bytes;
-import org.trafodion.dcs.zookeeper.ZkClient;
-import org.trafodion.dcs.rest.RestConstants;
-import org.trafodion.dcs.rest.model.ServerModel;
-
-public class ServerResource extends ResourceBase {
- private static final Log LOG =
- LogFactory.getLog(ServerResource.class);
-
- static CacheControl cacheControl;
- static {
- cacheControl = new CacheControl();
- cacheControl.setNoCache(true);
- cacheControl.setNoTransform(false);
- }
-
- /**
-* @@@ START COPYRIGHT @@@
-
- 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.
-
-* @@@ END COPYRIGHT @@@
- */
- public ServerResource() throws IOException {
- super();
- }
-
- @GET
- @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON})
- public Response get(final @Context UriInfo uriInfo) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("GET " + uriInfo.getAbsolutePath());
- }
-
- try {
- List<String> master = servlet.getMaster();
- List<String> running = servlet.getRunning();
- List<String> registered = servlet.getRegistered();
-
- ZkClient zkc = servlet.getZk();
- Stat stat = null;
-
- ServerModel model = new ServerModel();
-
- String data = null;
-
- if(master != null){
- for(String znode: master) {
- data = null;
- try {
- data = Bytes.toString(zkc.getData(servlet.getParentZnode() + Constants.DEFAULT_ZOOKEEPER_ZNODE_MASTER + "/" + znode, false, stat));
- } catch (Exception e) {
- LOG.error(e);
- }
-
- ServerModel.DcsMaster dcsMaster = model.addDcsMaster(znode,data);
-
- if(running != null){
- Collections.sort(running);
- data = null;
- for(String znodeRun: running) {
- try {
- data = Bytes.toString(zkc.getData(servlet.getParentZnode() + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_RUNNING + "/" + znodeRun, false, stat));
- } catch (Exception e) {
- LOG.error(e);
- }
-
- ServerModel.DcsServer dcsServer = dcsMaster.addDcsServer(znodeRun,data);
-
- if(registered != null){
- Collections.sort(registered);
- data = null;
- for(String znodeReg: registered) {
- try {
- data = Bytes.toString(zkc.getData(servlet.getParentZnode() + Constants.DEFAULT_ZOOKEEPER_ZNODE_SERVERS_REGISTERED + "/" + znodeReg, false, stat));
- } catch (Exception e) {
- LOG.error(e);
- }
-
- dcsServer.addTrafodionServer(znodeReg,data);
- }
- }
- }
- }
- }
- }
-
- ResponseBuilder response = Response.ok(model);
- response.cacheControl(cacheControl);
- return response.build();
- } catch (IOException e) {
- return Response.status(Response.Status.SERVICE_UNAVAILABLE)
- .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
- .build();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/VersionResource.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/VersionResource.java b/dcs/src/main/java/org/trafodion/dcs/rest/VersionResource.java
deleted file mode 100644
index caa7985..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/VersionResource.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/**********************************************************************
-* @@@ START COPYRIGHT @@@
-*
-* 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.
-*
-* @@@ END COPYRIGHT @@@
-**********************************************************************/
-
-package org.trafodion.dcs.rest;
-
-import java.io.IOException;
-
-import javax.servlet.ServletContext;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.trafodion.dcs.rest.model.VersionModel;
-
-/**
-* @@@ START COPYRIGHT @@@
-
-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.
-
-* @@@ END COPYRIGHT @@@
- */
-public class VersionResource extends ResourceBase {
-
- private static final Log LOG = LogFactory.getLog(VersionResource.class);
-
- static CacheControl cacheControl;
- static {
- cacheControl = new CacheControl();
- cacheControl.setNoCache(true);
- cacheControl.setNoTransform(false);
- }
-
- /**
- * Constructor
- * @throws IOException
- */
- public VersionResource() throws IOException {
- super();
- }
-
- /**
- * Build a response for a version request.
- * @param context servlet context
- * @param uriInfo (JAX-RS context variable) request URL
- * @return a response for a version request
- */
-
- @GET
- @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON})
- public Response get(final @Context ServletContext context,
- final @Context UriInfo uriInfo) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("GET " + uriInfo.getAbsolutePath());
- }
- //servlet.getMetrics().incrementRequests(1);
- ResponseBuilder response = Response.ok(new VersionModel(context));
- response.cacheControl(cacheControl);
- //servlet.getMetrics().incrementSucessfulGetRequests(1);
- return response.build();
- }
-
- /**
- * Dispatch to StorageClusterVersionResource
- */
-/*
- @Path("cluster")
- public StorageClusterVersionResource getClusterVersionResource()
- throws IOException {
- return new StorageClusterVersionResource();
- }
-*/
- /**
- * Dispatch <tt>/version/rest</tt> to self.
- */
- @Path("rest")
- public VersionResource getVersionResource() {
- return this;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/WorkloadResource.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/WorkloadResource.java b/dcs/src/main/java/org/trafodion/dcs/rest/WorkloadResource.java
deleted file mode 100644
index 6a17110..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/WorkloadResource.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/**********************************************************************
-* @@@ START COPYRIGHT @@@
-*
-* 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.
-*
-* @@@ END COPYRIGHT @@@
-**********************************************************************/
-package org.trafodion.dcs.rest;
-
-import java.io.*;
-import java.util.*;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.CacheControl;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.Response.ResponseBuilder;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.trafodion.dcs.Constants;
-import org.trafodion.dcs.util.Bytes;
-import org.trafodion.dcs.script.ScriptManager;
-import org.trafodion.dcs.script.ScriptContext;
-import org.trafodion.dcs.rest.model.WorkloadListModel;
-import org.trafodion.dcs.rest.model.WorkloadModel;
-
-import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONException;
-import org.codehaus.jettison.json.JSONObject;
-
-public class WorkloadResource extends ResourceBase {
- private static final Log LOG =
- LogFactory.getLog(WorkloadResource.class);
-
- static CacheControl cacheControl;
- static {
- cacheControl = new CacheControl();
- cacheControl.setNoCache(true);
- cacheControl.setNoTransform(false);
- }
-
- /**
-* @@@ START COPYRIGHT @@@
-
- 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.
-
-* @@@ END COPYRIGHT @@@
- */
- public WorkloadResource() throws IOException {
- super();
-
- }
-
- @GET
- @Produces({MIMETYPE_TEXT, MIMETYPE_XML, MIMETYPE_JSON})
- public Response get(final @Context UriInfo uriInfo) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("GET " + uriInfo.getAbsolutePath());
- }
-
- try {
-// ScriptContext scriptContext = new ScriptContext();
-// scriptContext.setScriptName(Constants.JDBCT2UTIL_SCRIPT_NAME);
-// scriptContext.setCommand(Constants.TRAFODION_REPOS_METRIC_SESSION_TABLE);
-
- try {
-// ScriptManager.getInstance().runScript(scriptContext);//This will block while script is running
- } catch (Exception e) {
- e.printStackTrace();
- throw new IOException(e);
- }
-
-// StringBuilder sb = new StringBuilder();
-// sb.append("exit code [" + scriptContext.getExitCode() + "]");
-// if(! scriptContext.getStdOut().toString().isEmpty())
-// sb.append(", stdout [" + scriptContext.getStdOut().toString() + "]");
-// if(! scriptContext.getStdErr().toString().isEmpty())
-// sb.append(", stderr [" + scriptContext.getStdErr().toString() + "]");
-// LOG.info(sb.toString());
-
- JSONArray workloadList = null;
-
-// try {
-// if(scriptContext.getExitCode() == 0 && (! scriptContext.getStdOut().toString().isEmpty())) {
-// workloadList = new JSONArray(scriptContext.getStdOut().toString());
-// }
-// } catch (Exception e) {
-// e.printStackTrace();
-// LOG.error(e.getMessage());
-// throw new IOException(e);
-// }
-
- ResponseBuilder response = Response.ok(workloadList);
- response.cacheControl(cacheControl);
- return response.build();
- } catch (IOException e) {
- return Response.status(Response.Status.SERVICE_UNAVAILABLE)
- .type(MIMETYPE_TEXT).entity("Unavailable" + CRLF)
- .build();
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/client/Client.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/client/Client.java b/dcs/src/main/java/org/trafodion/dcs/rest/client/Client.java
deleted file mode 100644
index d21eb3a..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/client/Client.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-*
-* 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.
-*
-* @@@ END COPYRIGHT @@@
- */
-
-package org.trafodion.dcs.rest.client;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpVersion;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.URI;
-import org.apache.commons.httpclient.methods.ByteArrayRequestEntity;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * A wrapper around HttpClient which provides some useful function and
- * semantics for interacting with the REST gateway.
- */
-public class Client {
- public static final Header[] EMPTY_HEADER_ARRAY = new Header[0];
-
- private static final Log LOG = LogFactory.getLog(Client.class);
-
- private HttpClient httpClient;
- private Cluster cluster;
-
- private Map<String, String> extraHeaders;
-
- /**
- * Default Constructor
- */
- public Client() {
- this(null);
- }
-
- /**
- * Constructor
- * @param cluster the cluster definition
- */
- public Client(Cluster cluster) {
- this.cluster = cluster;
- MultiThreadedHttpConnectionManager manager =
- new MultiThreadedHttpConnectionManager();
- HttpConnectionManagerParams managerParams = manager.getParams();
- managerParams.setConnectionTimeout(2000); // 2 s
- managerParams.setDefaultMaxConnectionsPerHost(10);
- managerParams.setMaxTotalConnections(100);
- extraHeaders = new ConcurrentHashMap<String, String>();
- this.httpClient = new HttpClient(manager);
- HttpClientParams clientParams = httpClient.getParams();
- clientParams.setVersion(HttpVersion.HTTP_1_1);
- }
-
- /**
- * Shut down the client. Close any open persistent connections.
- */
- public void shutdown() {
- MultiThreadedHttpConnectionManager manager =
- (MultiThreadedHttpConnectionManager) httpClient.getHttpConnectionManager();
- manager.shutdown();
- }
-
- /**
- * @return the wrapped HttpClient
- */
- public HttpClient getHttpClient() {
- return httpClient;
- }
-
- /**
- * Add extra headers. These extra headers will be applied to all http
- * methods before they are removed. If any header is not used any more,
- * client needs to remove it explicitly.
- */
- public void addExtraHeader(final String name, final String value) {
- extraHeaders.put(name, value);
- }
-
- /**
- * Get an extra header value.
- */
- public String getExtraHeader(final String name) {
- return extraHeaders.get(name);
- }
-
- /**
- * Get all extra headers (read-only).
- */
- public Map<String, String> getExtraHeaders() {
- return Collections.unmodifiableMap(extraHeaders);
- }
-
- /**
- * Remove an extra header.
- */
- public void removeExtraHeader(final String name) {
- extraHeaders.remove(name);
- }
-
- /**
- * Execute a transaction method given only the path. Will select at random
- * one of the members of the supplied cluster definition and iterate through
- * the list until a transaction can be successfully completed. The
- * definition of success here is a complete HTTP transaction, irrespective
- * of result code.
- * @param cluster the cluster definition
- * @param method the transaction method
- * @param headers HTTP header values to send
- * @param path the properly urlencoded path
- * @return the HTTP response code
- * @throws IOException
- */
- public int executePathOnly(Cluster cluster, HttpMethod method,
- Header[] headers, String path) throws IOException {
- IOException lastException;
- if (cluster.nodes.size() < 1) {
- throw new IOException("Cluster is empty");
- }
- int start = (int)Math.round((cluster.nodes.size() - 1) * Math.random());
- int i = start;
- do {
- cluster.lastHost = cluster.nodes.get(i);
- try {
- StringBuilder sb = new StringBuilder();
- sb.append("http://");
- sb.append(cluster.lastHost);
- sb.append(path);
- URI uri = new URI(sb.toString(), true);
- return executeURI(method, headers, uri.toString());
- } catch (IOException e) {
- lastException = e;
- }
- } while (++i != start && i < cluster.nodes.size());
- throw lastException;
- }
-
- /**
- * Execute a transaction method given a complete URI.
- * @param method the transaction method
- * @param headers HTTP header values to send
- * @param uri a properly urlencoded URI
- * @return the HTTP response code
- * @throws IOException
- */
- public int executeURI(HttpMethod method, Header[] headers, String uri)
- throws IOException {
- method.setURI(new URI(uri, true));
- for (Map.Entry<String, String> e: extraHeaders.entrySet()) {
- method.addRequestHeader(e.getKey(), e.getValue());
- }
- if (headers != null) {
- for (Header header: headers) {
- method.addRequestHeader(header);
- }
- }
- long startTime = System.currentTimeMillis();
- int code = httpClient.executeMethod(method);
- long endTime = System.currentTimeMillis();
- if (LOG.isDebugEnabled()) {
- LOG.debug(method.getName() + " " + uri + " " + code + " " +
- method.getStatusText() + " in " + (endTime - startTime) + " ms");
- }
- return code;
- }
-
- /**
- * Execute a transaction method. Will call either <tt>executePathOnly</tt>
- * or <tt>executeURI</tt> depending on whether a path only is supplied in
- * 'path', or if a complete URI is passed instead, respectively.
- * @param cluster the cluster definition
- * @param method the HTTP method
- * @param headers HTTP header values to send
- * @param path the properly urlencoded path or URI
- * @return the HTTP response code
- * @throws IOException
- */
- public int execute(Cluster cluster, HttpMethod method, Header[] headers,
- String path) throws IOException {
- if (path.startsWith("/")) {
- return executePathOnly(cluster, method, headers, path);
- }
- return executeURI(method, headers, path);
- }
-
- /**
- * @return the cluster definition
- */
- public Cluster getCluster() {
- return cluster;
- }
-
- /**
- * @param cluster the cluster definition
- */
- public void setCluster(Cluster cluster) {
- this.cluster = cluster;
- }
-
- /**
- * Send a HEAD request
- * @param path the path or URI
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response head(String path) throws IOException {
- return head(cluster, path, null);
- }
-
- /**
- * Send a HEAD request
- * @param cluster the cluster definition
- * @param path the path or URI
- * @param headers the HTTP headers to include in the request
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response head(Cluster cluster, String path, Header[] headers)
- throws IOException {
- HeadMethod method = new HeadMethod();
- try {
- int code = execute(cluster, method, null, path);
- headers = method.getResponseHeaders();
- return new Response(code, headers, null);
- } finally {
- method.releaseConnection();
- }
- }
-
- /**
- * Send a GET request
- * @param path the path or URI
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response get(String path) throws IOException {
- return get(cluster, path);
- }
-
- /**
- * Send a GET request
- * @param cluster the cluster definition
- * @param path the path or URI
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response get(Cluster cluster, String path) throws IOException {
- return get(cluster, path, EMPTY_HEADER_ARRAY);
- }
-
- /**
- * Send a GET request
- * @param path the path or URI
- * @param accept Accept header value
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response get(String path, String accept) throws IOException {
- return get(cluster, path, accept);
- }
-
- /**
- * Send a GET request
- * @param cluster the cluster definition
- * @param path the path or URI
- * @param accept Accept header value
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response get(Cluster cluster, String path, String accept)
- throws IOException {
- Header[] headers = new Header[1];
- headers[0] = new Header("Accept", accept);
- return get(cluster, path, headers);
- }
-
- /**
- * Send a GET request
- * @param path the path or URI
- * @param headers the HTTP headers to include in the request,
- * <tt>Accept</tt> must be supplied
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response get(String path, Header[] headers) throws IOException {
- return get(cluster, path, headers);
- }
-
- /**
- * Send a GET request
- * @param c the cluster definition
- * @param path the path or URI
- * @param headers the HTTP headers to include in the request
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response get(Cluster c, String path, Header[] headers)
- throws IOException {
- GetMethod method = new GetMethod();
- try {
- int code = execute(c, method, headers, path);
- headers = method.getResponseHeaders();
- byte[] body = method.getResponseBody();
- return new Response(code, headers, body);
- } finally {
- method.releaseConnection();
- }
- }
-
- /**
- * Send a PUT request
- * @param path the path or URI
- * @param contentType the content MIME type
- * @param content the content bytes
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response put(String path, String contentType, byte[] content)
- throws IOException {
- return put(cluster, path, contentType, content);
- }
-
- /**
- * Send a PUT request
- * @param cluster the cluster definition
- * @param path the path or URI
- * @param contentType the content MIME type
- * @param content the content bytes
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response put(Cluster cluster, String path, String contentType,
- byte[] content) throws IOException {
- Header[] headers = new Header[1];
- headers[0] = new Header("Content-Type", contentType);
- return put(cluster, path, headers, content);
- }
-
- /**
- * Send a PUT request
- * @param path the path or URI
- * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be
- * supplied
- * @param content the content bytes
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response put(String path, Header[] headers, byte[] content)
- throws IOException {
- return put(cluster, path, headers, content);
- }
-
- /**
- * Send a PUT request
- * @param cluster the cluster definition
- * @param path the path or URI
- * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be
- * supplied
- * @param content the content bytes
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response put(Cluster cluster, String path, Header[] headers,
- byte[] content) throws IOException {
- PutMethod method = new PutMethod();
- try {
- method.setRequestEntity(new ByteArrayRequestEntity(content));
- int code = execute(cluster, method, headers, path);
- headers = method.getResponseHeaders();
- content = method.getResponseBody();
- return new Response(code, headers, content);
- } finally {
- method.releaseConnection();
- }
- }
-
- /**
- * Send a POST request
- * @param path the path or URI
- * @param contentType the content MIME type
- * @param content the content bytes
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response post(String path, String contentType, byte[] content)
- throws IOException {
- return post(cluster, path, contentType, content);
- }
-
- /**
- * Send a POST request
- * @param cluster the cluster definition
- * @param path the path or URI
- * @param contentType the content MIME type
- * @param content the content bytes
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response post(Cluster cluster, String path, String contentType,
- byte[] content) throws IOException {
- Header[] headers = new Header[1];
- headers[0] = new Header("Content-Type", contentType);
- return post(cluster, path, headers, content);
- }
-
- /**
- * Send a POST request
- * @param path the path or URI
- * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be
- * supplied
- * @param content the content bytes
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response post(String path, Header[] headers, byte[] content)
- throws IOException {
- return post(cluster, path, headers, content);
- }
-
- /**
- * Send a POST request
- * @param cluster the cluster definition
- * @param path the path or URI
- * @param headers the HTTP headers to include, <tt>Content-Type</tt> must be
- * supplied
- * @param content the content bytes
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response post(Cluster cluster, String path, Header[] headers,
- byte[] content) throws IOException {
- PostMethod method = new PostMethod();
- try {
- method.setRequestEntity(new ByteArrayRequestEntity(content));
- int code = execute(cluster, method, headers, path);
- headers = method.getResponseHeaders();
- content = method.getResponseBody();
- return new Response(code, headers, content);
- } finally {
- method.releaseConnection();
- }
- }
-
- /**
- * Send a DELETE request
- * @param path the path or URI
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response delete(String path) throws IOException {
- return delete(cluster, path);
- }
-
- /**
- * Send a DELETE request
- * @param cluster the cluster definition
- * @param path the path or URI
- * @return a Response object with response detail
- * @throws IOException
- */
- public Response delete(Cluster cluster, String path) throws IOException {
- DeleteMethod method = new DeleteMethod();
- try {
- int code = execute(cluster, method, null, path);
- Header[] headers = method.getResponseHeaders();
- byte[] content = method.getResponseBody();
- return new Response(code, headers, content);
- } finally {
- method.releaseConnection();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/client/Cluster.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/client/Cluster.java b/dcs/src/main/java/org/trafodion/dcs/rest/client/Cluster.java
deleted file mode 100644
index 51721d6..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/client/Cluster.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-*
-* 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.
-*
-* @@@ END COPYRIGHT @@@
- */
-
-package org.trafodion.dcs.rest.client;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * A list of 'host:port' addresses of HTTP servers operating as a single
- * entity, for example multiple redundant web service gateways.
- */
-public class Cluster {
- protected List<String> nodes =
- Collections.synchronizedList(new ArrayList<String>());
- protected String lastHost;
-
- /**
- * Constructor
- */
- public Cluster() {}
-
- /**
- * Constructor
- * @param nodes a list of service locations, in 'host:port' format
- */
- public Cluster(List<String> nodes) {
- nodes.addAll(nodes);
- }
-
- /**
- * @return true if no locations have been added, false otherwise
- */
- public boolean isEmpty() {
- return nodes.isEmpty();
- }
-
- /**
- * Add a node to the cluster
- * @param node the service location in 'host:port' format
- */
- public Cluster add(String node) {
- nodes.add(node);
- return this;
- }
-
- /**
- * Add a node to the cluster
- * @param name host name
- * @param port service port
- */
- public Cluster add(String name, int port) {
- StringBuilder sb = new StringBuilder();
- sb.append(name);
- sb.append(':');
- sb.append(port);
- return add(sb.toString());
- }
-
- /**
- * Remove a node from the cluster
- * @param node the service location in 'host:port' format
- */
- public Cluster remove(String node) {
- nodes.remove(node);
- return this;
- }
-
- /**
- * Remove a node from the cluster
- * @param name host name
- * @param port service port
- */
- public Cluster remove(String name, int port) {
- StringBuilder sb = new StringBuilder();
- sb.append(name);
- sb.append(':');
- sb.append(port);
- return remove(sb.toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/7fe6dd13/dcs/src/main/java/org/trafodion/dcs/rest/client/Response.java
----------------------------------------------------------------------
diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/client/Response.java b/dcs/src/main/java/org/trafodion/dcs/rest/client/Response.java
deleted file mode 100644
index 025eb2f..0000000
--- a/dcs/src/main/java/org/trafodion/dcs/rest/client/Response.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/**
-* @@@ START COPYRIGHT @@@
-*
-* 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.
-*
-* @@@ END COPYRIGHT @@@
- */
-
-package org.trafodion.dcs.rest.client;
-
-import org.apache.commons.httpclient.Header;
-
-/**
- * The HTTP result code, response headers, and body of a HTTP response.
- */
-public class Response {
- private int code;
- private Header[] headers;
- private byte[] body;
-
- /**
- * Constructor
- * @param code the HTTP response code
- */
- public Response(int code) {
- this(code, null, null);
- }
-
- /**
- * Constructor
- * @param code the HTTP response code
- * @param headers the HTTP response headers
- */
- public Response(int code, Header[] headers) {
- this(code, headers, null);
- }
-
- /**
- * Constructor
- * @param code the HTTP response code
- * @param headers the HTTP response headers
- * @param body the response body, can be null
- */
- public Response(int code, Header[] headers, byte[] body) {
- this.code = code;
- this.headers = headers;
- this.body = body;
- }
-
- /**
- * @return the HTTP response code
- */
- public int getCode() {
- return code;
- }
-
- /**
- * @return the HTTP response headers
- */
- public Header[] getHeaders() {
- return headers;
- }
-
- public String getHeader(String key) {
- for (Header header: headers) {
- if (header.getName().equalsIgnoreCase(key)) {
- return header.getValue();
- }
- }
- return null;
- }
-
- /**
- * @return the value of the Location header
- */
- public String getLocation() {
- return getHeader("Location");
- }
-
- /**
- * @return true if a response body was sent
- */
- public boolean hasBody() {
- return body != null;
- }
-
- /**
- * @return the HTTP response body
- */
- public byte[] getBody() {
- return body;
- }
-
- /**
- * @param code the HTTP response code
- */
- public void setCode(int code) {
- this.code = code;
- }
-
- /**
- * @param headers the HTTP response headers
- */
- public void setHeaders(Header[] headers) {
- this.headers = headers;
- }
-
- /**
- * @param body the response body
- */
- public void setBody(byte[] body) {
- this.body = body;
- }
-}