http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/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/681cad66/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/681cad66/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; - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/model/ServerModel.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/model/ServerModel.java b/dcs/src/main/java/org/trafodion/dcs/rest/model/ServerModel.java deleted file mode 100644 index e254eca..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/model/ServerModel.java +++ /dev/null @@ -1,530 +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.model; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.Scanner; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlElementWrapper; -import javax.xml.bind.annotation.XmlRootElement; - -/** - * Simple representation of an DCS instance. - */ -@XmlRootElement(name = "DcsStatus") -public class ServerModel implements Serializable { - private static final long serialVersionUID = 1L; - - /** - * Represents a DcsMaster server. - */ - public static class DcsMaster { - private String hostName; - private String listenerPort; - private String listenerPortRange; - private String startTimestamp; - private List<DcsServer> dcsServerList = new ArrayList<DcsServer>(); - - /** - * Default constructor - */ - public DcsMaster() { - } - - /** - * Constructor - * - * @param hostName - * the host name - * @param listenerPort - * the port its listening on - * @param listenerPortRange - * the listener port range - * @param startTimestamp - * the start timestamp - */ - public DcsMaster(String hostName, String listenerPort, - String listenerPortRange, String startTimestamp) { - this.hostName = hostName; - this.listenerPort = listenerPort; - this.listenerPortRange = listenerPortRange; - this.startTimestamp = startTimestamp; - } - - /** - * @return the host name - */ - @XmlAttribute - public String getHostName() { - return hostName; - } - - /** - * @return the listener port number - */ - @XmlAttribute - public String getListenerPort() { - return listenerPort; - } - - /** - * @return the listener port range - */ - @XmlAttribute - public String getListenerPortRange() { - return listenerPortRange; - } - - /** - * @return the start time - */ - @XmlAttribute - public String getStartTimestamp() { - return startTimestamp; - } - - /** - * Add a DcsServer to the list - * - * @param znode - * the znode name - */ - public DcsServer addDcsServer(String znode, String data) { - Scanner scn = new Scanner(znode); - scn.useDelimiter(":"); - String hostName = scn.next();// host name - String instance = scn.next();// instance - String infoPort = scn.next();// info port - String startTimestamp = scn.next(); - scn.close(); - ServerModel.DcsServer dcsServer = new ServerModel.DcsServer( - hostName, instance, infoPort, startTimestamp); - dcsServerList.add(dcsServer); - return dcsServer; - } - - /** - * @param index - * the index - * @return the DcsServer name - */ - public DcsServer getDcsServer(int index) { - return dcsServerList.get(index); - } - - /** - * @return the list of DcsServer - */ - @XmlElement(name = "DcsServer") - public List<DcsServer> getDcsServer() { - return dcsServerList; - } - } - - /** - * Represents a DcsServer server. - */ - public static class DcsServer { - // from znode, no data - private String hostName; - private String instance; - private String infoPort; - private String startTimestamp; - private List<TrafodionServer> trafServerList = new ArrayList<TrafodionServer>(); - - /** - * Default constructor - */ - public DcsServer() { - } - - /** - * Constructor - * - * @param hostName - * the host name - * @param instance - * the instance number - * @param infoPort - * the port - * @param startTimestamp - * the start timestamp - */ - public DcsServer(String hostName, String instance, String infoPort, - String startTimestamp) { - this.hostName = hostName; - this.instance = instance; - this.infoPort = infoPort; - this.startTimestamp = startTimestamp; - } - - /** - * @return the host name - */ - @XmlAttribute - public String getHostName() { - return hostName; - } - - /** - * @return the instance number - */ - @XmlAttribute - public String getInstance() { - return instance; - } - - /** - * @return the listener port range - */ - @XmlAttribute - public String getInfoPort() { - return infoPort; - } - - /** - * @return the start timestamp - */ - @XmlAttribute - public String getStartTimestamp() { - return startTimestamp; - } - - /** - * Add a TrafodionServer to the list - * - * @param znode - * the znode name - * @param data - * the data - */ - public void addTrafodionServer(String znode, String data) { - Scanner scn = new Scanner(znode); - scn.useDelimiter(":"); - String hostName = scn.next();// host name - String instance = scn.next();// DcsServer's instance ID - String trafInstance = scn.next();// Traf server's instance ID - scn.close(); - scn = new Scanner(data); - scn.useDelimiter(":"); - String state = scn.next();// state - String timestamp = scn.next();// last updated timestamp - String dialogueId = scn.next();// dialogue id - String nid = scn.next();// node id - String pid = scn.next();// process id - String processName = scn.next();// process name - String ipAddress = scn.next();// server ip address - String port = scn.next();// server port - String clientHostName = scn.next();// client host name - String clientIpAddress = scn.next();// client ip address - String clientPort = scn.next();// client port - String clientAppl = scn.next();// client application name - scn.close(); - - if (this.hostName.equalsIgnoreCase(hostName) - && this.instance.equalsIgnoreCase(instance)) - trafServerList.add(new ServerModel.TrafodionServer(hostName, - instance, trafInstance, state, timestamp, dialogueId, - nid, pid, processName, ipAddress, port, clientHostName, - clientIpAddress, clientPort, clientAppl)); - } - - /** - * @param index - * the index - * @return the TrafodionServer - */ - public TrafodionServer getTrafodionServer(int index) { - return trafServerList.get(index); - } - - /** - * @return the list of Trafodion servers - */ - @XmlElement(name = "TrafodionServer") - public List<TrafodionServer> getTrafodionServer() { - return trafServerList; - } - } - - /** - * Represents a TrafodionServer server. - */ - public static class TrafodionServer { - // from znode - private String hostName; - private String dcsInstance; - private String instance; - // from data - private String state; - private String timestamp; - private String dialogueId; - private String nid; - private String pid; - private String processName; - private String ipAddress; - private String port; - private String clientHostName; - private String clientIpAddress; - private String clientPort; - private String clientAppl; - - /** - * Default constructor - */ - public TrafodionServer() { - } - - /** - * Constructor - * - * @param hostName - * the host name - */ - public TrafodionServer(String hostName, String dcsInstance, - String instance, String state, String timestamp, - String dialogueId, String nid, String pid, String processName, - String ipAddress, String port, String clientHostName, - String clientIpAddress, String clientPort, String clientAppl) { - this.hostName = hostName; - this.dcsInstance = dcsInstance; - this.instance = instance; - this.state = state; - this.timestamp = timestamp; - this.dialogueId = dialogueId; - this.nid = nid; - this.pid = pid; - this.processName = processName; - this.ipAddress = ipAddress; - this.port = port; - this.clientHostName = clientHostName; - this.clientIpAddress = clientIpAddress; - this.clientPort = clientPort; - this.clientAppl = clientAppl; - } - - /** - * @return the server's host name - */ - @XmlAttribute - public String getHostName() { - return hostName; - } - - /** - * @return the DCS server's instance ID - */ - @XmlAttribute - public String getDcsInstance() { - return dcsInstance; - } - - /** - * @return the Trafodion server's instance number - */ - @XmlAttribute - public String getInstance() { - return instance; - } - - /** - * @return the server state - */ - @XmlAttribute - public String getState() { - return state; - } - - /** - * @return the server timestamp - */ - @XmlAttribute - public String getTimestamp() { - return timestamp; - } - - /** - * @return the dialogueId - */ - @XmlAttribute - public String getDialogueId() { - return dialogueId; - } - - /** - * @return the node Id - */ - @XmlAttribute - public String getNid() { - return nid; - } - - /** - * @return the process Id - */ - @XmlAttribute - public String getPid() { - return pid; - } - - /** - * @return the process name - */ - @XmlAttribute - public String getProcessName() { - return processName; - } - - /** - * @return the server's IP address - */ - @XmlAttribute - public String getIpAddress() { - return ipAddress; - } - - /** - * @return the server's port number - */ - @XmlAttribute - public String getPort() { - return port; - } - - /** - * @return the connected client's host name - */ - @XmlAttribute - public String getClientHostName() { - return clientHostName; - } - - /** - * @return the the connected client's IP address - */ - @XmlAttribute - public String getClientIpAddress() { - return clientIpAddress; - } - - /** - * @return the connected client's port number - */ - @XmlAttribute - public String getClientPort() { - return clientPort; - } - - /** - * @return the connected client's application name - */ - @XmlAttribute - public String getClientAppl() { - return clientAppl; - } - } - - /** - * Default constructor - */ - public ServerModel() { - } - - private DcsMaster dcsMaster = null; - - /** - * Add a DcsMaster - * - * @param znode - * the znode - */ - public DcsMaster addDcsMaster(String znode, String data) { - Scanner scn = new Scanner(znode); - scn.useDelimiter(":"); - String hostName = scn.next();// host name - String listenerPort = scn.next();// listener port - String listenerPortRange = scn.next(); - String startTimestamp = scn.next(); - scn.close(); - dcsMaster = new ServerModel.DcsMaster(hostName, listenerPort, - listenerPortRange, startTimestamp); - return dcsMaster; - } - - /** - * @return the DCS Master server - */ - @XmlElement(name = "DcsMaster") - public DcsMaster getDcsMaster() { - return dcsMaster; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - /* - * if (!dcsMaster.isEmpty()) { //sb.append(String.format( - * "%d DcsMaster server(s), %d DcsServer server(s)\n\n" - * ,dcsMaster.size(), dcsMaster.getDcsServer().size()); - * //sb.append(liveNodes.size()); //sb.append(" live servers\n"); for - * (DcsMaster aServer: dcsMaster) { sb.append(" "); - * sb.append(node.name); sb.append(' '); sb.append(node.startCode); - * sb.append("\n requests="); sb.append(node.requests); - * sb.append(", regions="); sb.append(node.regions.size()); - * sb.append("\n heapSizeMB="); sb.append(node.heapSizeMB); - * sb.append("\n maxHeapSizeMB="); sb.append(node.maxHeapSizeMB); - * sb.append("\n\n"); for (Node.Region region: node.regions) { - * sb.append(" "); sb.append(Bytes.toString(region.name)); - * sb.append("\n stores="); sb.append(region.stores); - * sb.append("\n storefiless="); - * sb.append(region.storefiles); - * sb.append("\n storefileSizeMB="); - * sb.append(region.storefileSizeMB); - * sb.append("\n memstoreSizeMB="); - * sb.append(region.memstoreSizeMB); - * sb.append("\n storefileIndexSizeMB="); - * sb.append(region.storefileIndexSizeMB); - * sb.append("\n readRequestsCount="); - * sb.append(region.readRequestsCount); - * sb.append("\n writeRequestsCount="); - * sb.append(region.writeRequestsCount); - * sb.append("\n rootIndexSizeKB="); - * sb.append(region.rootIndexSizeKB); - * sb.append("\n totalStaticIndexSizeKB="); - * sb.append(region.totalStaticIndexSizeKB); - * sb.append("\n totalStaticBloomSizeKB="); - * sb.append(region.totalStaticBloomSizeKB); - * sb.append("\n totalCompactingKVs="); - * sb.append(region.totalCompactingKVs); - * sb.append("\n currentCompactedKVs="); - * sb.append(region.currentCompactedKVs); sb.append('\n'); } - * sb.append('\n'); } } - */ - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/model/VersionModel.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/model/VersionModel.java b/dcs/src/main/java/org/trafodion/dcs/rest/model/VersionModel.java deleted file mode 100644 index 3d3bebe..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/model/VersionModel.java +++ /dev/null @@ -1,193 +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.model; - -import java.io.IOException; -import java.io.Serializable; - -import javax.servlet.ServletContext; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -import org.trafodion.dcs.rest.RESTServlet; - -import com.sun.jersey.spi.container.servlet.ServletContainer; - -/** - * A representation of the collection of versions of the REST gateway software - * components. - * <ul> - * <li>restVersion: REST gateway revision</li> - * <li>jvmVersion: the JVM vendor and version information</li> - * <li>osVersion: the OS type, version, and hardware architecture</li> - * <li>serverVersion: the name and version of the servlet container</li> - * <li>jerseyVersion: the version of the embedded Jersey framework</li> - * </ul> - */ -@XmlRootElement(name="Version") -public class VersionModel implements Serializable { - - private static final long serialVersionUID = 1L; - - private String restVersion; - private String jvmVersion; - private String osVersion; - private String serverVersion; - private String jerseyVersion; - - /** - * Default constructor. Do not use. - */ - public VersionModel() {} - - /** - * Constructor - * @param context the servlet context - */ - public VersionModel(ServletContext context) { - restVersion = RESTServlet.VERSION_STRING; - jvmVersion = System.getProperty("java.vm.vendor") + ' ' + - System.getProperty("java.version") + '-' + - System.getProperty("java.vm.version"); - osVersion = System.getProperty("os.name") + ' ' + - System.getProperty("os.version") + ' ' + - System.getProperty("os.arch"); - serverVersion = context.getServerInfo(); - jerseyVersion = ServletContainer.class.getPackage() - .getImplementationVersion(); - } - - /** - * @return the REST gateway version - */ - @XmlAttribute(name="REST") - public String getRESTVersion() { - return restVersion; - } - - /** - * @return the JVM vendor and version - */ - @XmlAttribute(name="JVM") - public String getJVMVersion() { - return jvmVersion; - } - - /** - * @return the OS name, version, and hardware architecture - */ - @XmlAttribute(name="OS") - public String getOSVersion() { - return osVersion; - } - - /** - * @return the servlet container version - */ - @XmlAttribute(name="Server") - public String getServerVersion() { - return serverVersion; - } - - /** - * @return the version of the embedded Jersey framework - */ - @XmlAttribute(name="Jersey") - public String getJerseyVersion() { - return jerseyVersion; - } - - /** - * @param version the REST gateway version string - */ - public void setRESTVersion(String version) { - this.restVersion = version; - } - - /** - * @param version the OS version string - */ - public void setOSVersion(String version) { - this.osVersion = version; - } - - /** - * @param version the JVM version string - */ - public void setJVMVersion(String version) { - this.jvmVersion = version; - } - - /** - * @param version the servlet container version string - */ - public void setServerVersion(String version) { - this.serverVersion = version; - } - - /** - * @param version the Jersey framework version string - */ - public void setJerseyVersion(String version) { - this.jerseyVersion = version; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("rest "); - sb.append(restVersion); - sb.append(" [JVM: "); - sb.append(jvmVersion); - sb.append("] [OS: "); - sb.append(osVersion); - sb.append("] [Server: "); - sb.append(serverVersion); - sb.append("] [Jersey: "); - sb.append(jerseyVersion); - sb.append("]\n"); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/model/WorkloadListModel.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/model/WorkloadListModel.java b/dcs/src/main/java/org/trafodion/dcs/rest/model/WorkloadListModel.java deleted file mode 100644 index 9aecf14..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/model/WorkloadListModel.java +++ /dev/null @@ -1,225 +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.model; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.apache.hadoop.conf.Configuration; -import org.trafodion.dcs.util.DcsConfiguration; -import org.trafodion.dcs.Constants; - -import javax.xml.bind.annotation.XmlElementRef; -import javax.xml.bind.annotation.XmlRootElement; - -/** -* @@@ 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 @@@ - */ -@XmlRootElement(name="Workloads") -public class WorkloadListModel { - private static final long serialVersionUID = 1L; - private List<WorkloadModel> workloads = new ArrayList<WorkloadModel>(); - private static int refreshSeconds; - /** - * Default constructor - */ - public WorkloadListModel() { - Configuration conf = DcsConfiguration.create(); - refreshSeconds = conf.getInt("dcs.rest.refresh.seconds",5); - } - - /** - * Add the workload to the list - * @param workload the workload model - */ - public void add(WorkloadModel workload) { - workloads.add(workload); - } - - /** - * @param index the index - * @return the workload model - */ - public WorkloadModel get(int index) { - return workloads.get(index); - } - - /** - * @return the workloads - */ - public List<WorkloadModel> getWorkloads() { - return workloads; - } - - /** - * @param workloads the list of workloads - */ - public void setWorkloads(List<WorkloadModel> workloads) { - this.workloads = workloads; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - /* - sb.append("<html>\n"); - sb.append("<head>\n"); - sb.append("<title>DCS (Data Connectivity Services)</title>\n"); - if(refreshSeconds > 0) - sb.append("<meta http-equiv=\"refresh\" content=\"5\">\n"); - sb.append("</head>\n"); - sb.append("<body>\n"); - // - sb.append("<table border=\"1\">\n"); - sb.append("<tr>\n"); - sb.append("<th>Type</th>\n"); - sb.append("<th>Znode</th>\n"); - sb.append("<th>Data</th>\n"); - sb.append("</tr>\n"); - - for(WorkloadModel aWorkload : workloads) { - sb.append(aWorkload.toString()); - sb.append('\n'); - } - - sb.append("</table>\n"); - sb.append("</body>\n"); - sb.append("</html>\n"); - */ - - - sb.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"); - sb.append("<html>\n"); - sb.append("<head>\n"); - sb.append("<meta http-equiv=\"Content-Type\" content=\"text/html\"; charset=ISO-8859-1\">\n"); - sb.append("<title>(DCS) Data Connectivity Services</title>\n"); - sb.append("<style type=\"text/css\">\n"); - sb.append(" * { padding: 0; margin: 0; }\n"); - sb.append(" table.dcs {\n"); - sb.append(" font-family: verdana, arial, helvetica, sans-serif;\n"); - sb.append(" font-size: 11px;\n"); - sb.append(" cellspacing: 0;\n"); - sb.append(" border-collapse: collapse;\n"); - sb.append(" width: 535px;\n"); - sb.append(" }\n"); - sb.append(" table.dcs td {\n"); - sb.append(" border-left: 1px solid #999;\n"); - sb.append(" border-top: 1px solid #999;\n"); - sb.append(" padding: 2px 4px;\n"); - sb.append(" }\n"); - sb.append(" table.dcs tr:first-child td {\n"); - sb.append(" border-top: none;\n"); - sb.append(" }\n"); - sb.append(" table.dcs th { \n"); - sb.append(" border-left: 1px solid #999;\n"); - sb.append(" padding: 2px 4px;\n"); - sb.append(" background: #6b6164;\n"); - sb.append(" color: white;\n"); - sb.append(" font-variant: small-caps;\n"); - sb.append(" }\n"); - sb.append(" table.dcs td { background: #eee; overflow: hidden; }\n"); - - sb.append(" div.scrollableContainer {\n"); - sb.append(" position: relative;\n"); - sb.append(" width: 750px;\n"); - sb.append(" padding-top: 2em;\n"); - sb.append(" margin: 40px;\n"); - sb.append(" border: 1px solid #999;\n"); - sb.append(" background: #6b6164;\n"); - sb.append(" }\n"); - sb.append(" div.scrollingArea {\n"); - sb.append(" height: 240px;\n"); - sb.append(" overflow: auto;\n"); - sb.append(" }\n"); - - sb.append(" table.scrollable thead tr {\n"); - sb.append(" left: -1px; top: 0;\n"); - sb.append(" position: absolute;\n"); - sb.append(" }\n"); - - sb.append(" table.dcs .type div { width: 100px; }\n"); - sb.append(" table.dcs .znode div { width: 100px; }\n"); - sb.append(" table.dcs .data div { width: 100px; }\n"); - - sb.append("</style>\n"); - sb.append("</head>\n"); - sb.append("<body>\n"); - - sb.append("<div class=\"scrollableContainer\">\n"); - sb.append("<div class=\"scrollingArea\">\n"); - sb.append("<table class=\"dcs scrollable\">\n"); - sb.append("<thead>\n"); - sb.append("<tr>\n"); - sb.append("<th><div class=\"type\">Type</div></th>\n"); - sb.append("<th><div class=\"znode\">Znode</div></th>\n"); - sb.append("<th><div class=\"data\">Data</div></th>\n"); - sb.append("</tr>\n"); - sb.append("</thead>\n"); - sb.append("<tbody>\n"); - - for(WorkloadModel aWorkload : workloads) { - sb.append("<tr>\n"); - sb.append(aWorkload.toString()); - sb.append("</tr>\n"); - } - - sb.append("</tbody>\n"); - sb.append("</table>\n"); - sb.append("</div>\n"); - sb.append("</div>\n"); - sb.append("<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js\"></script>\n"); - sb.append("<script type=\"text/javascript\">\n"); - sb.append("$(document).ready(function() {\n"); - sb.append("$(\".scrollingArea\").height( $(window).height()-100 );\n"); - sb.append("$(window).resize(function() { $(\".scrollingArea\").height( $(window).height()-100 ); } );\n"); - sb.append("});\n"); - sb.append("</script>\n"); - sb.append("</body>\n"); - sb.append("</html>\n"); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/model/WorkloadModel.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/model/WorkloadModel.java b/dcs/src/main/java/org/trafodion/dcs/rest/model/WorkloadModel.java deleted file mode 100644 index 1f67edc..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/model/WorkloadModel.java +++ /dev/null @@ -1,139 +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.model; - -import java.io.Serializable; -import java.util.Date; -import java.text.DateFormat; - -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; - -/** -* @@@ 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 @@@ - */ -@XmlRootElement(name="workload") -public class WorkloadModel implements Serializable { - private static final long serialVersionUID = 1L; - - private String type; - private String znode; - private String data; - - /** - * Default constructor - */ - public WorkloadModel() {} - - /** - * Constructor - * @param type - * @param znode - * @param data - */ - public WorkloadModel(String type,String znode,String data) { - super(); - this.type = type; - this.znode = znode; - this.data = data; - } - - /** - * @return the type - */ - @XmlAttribute - public String getType() { - return type; - } - - /** - * @param value the type to set - */ - public void setType(String value) { - this.type = value; - } - - /** - * @return the znode - */ - @XmlAttribute - public String getZnode() { - return znode; - } - - /** - * @param value the znode to set - */ - public void setZnode(String value) { - this.znode = value; - } - - /** - * @return the data - */ - @XmlAttribute - public String getData() { - return data; - } - - /** - * @param value the value to set - */ - public void setData(String value) { - this.data = value; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - /* - sb.append("<td>" + type + "</td>\n"); - sb.append("<td>" + znode + "</td>\n"); - sb.append("<td>" + data + "</td>\n"); - sb.append("</tr>\n"); - */ - sb.append("<td><div class=\"type\">" + type + "</div></td>\n"); - sb.append("<td><div class=\"znode\">" + znode + "</div></td>\n"); - sb.append("<td><div class=\"data\">" + data + "</div></td>\n"); - return sb.toString(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/provider/JAXBContextResolver.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/provider/JAXBContextResolver.java b/dcs/src/main/java/org/trafodion/dcs/rest/provider/JAXBContextResolver.java deleted file mode 100644 index aa3b965..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/provider/JAXBContextResolver.java +++ /dev/null @@ -1,84 +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.provider; - -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import javax.ws.rs.ext.ContextResolver; -import javax.ws.rs.ext.Provider; -import javax.xml.bind.JAXBContext; - -import org.trafodion.dcs.rest.model.ServerModel; -import org.trafodion.dcs.rest.model.VersionModel; - -import com.sun.jersey.api.json.JSONConfiguration; -import com.sun.jersey.api.json.JSONJAXBContext; - -/** -* @@@ 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 @@@ - */ -@Provider -public class JAXBContextResolver implements ContextResolver<JAXBContext> { - - private final JAXBContext context; - - private final Set<Class<?>> types; - - private final Class<?>[] cTypes = { - ServerModel.class, - VersionModel.class - }; - - @SuppressWarnings("unchecked") - public JAXBContextResolver() throws Exception { - this.types = new HashSet<Class<?>>(Arrays.asList(cTypes)); - this.context = new JSONJAXBContext(JSONConfiguration.natural().build(), - cTypes); - } - - @Override - public JAXBContext getContext(Class<?> objectType) { - return (types.contains(objectType)) ? context : null; - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/java/org/trafodion/dcs/rest/provider/producer/PlainTextMessageBodyProducer.java ---------------------------------------------------------------------- diff --git a/dcs/src/main/java/org/trafodion/dcs/rest/provider/producer/PlainTextMessageBodyProducer.java b/dcs/src/main/java/org/trafodion/dcs/rest/provider/producer/PlainTextMessageBodyProducer.java deleted file mode 100644 index 5cf1431..0000000 --- a/dcs/src/main/java/org/trafodion/dcs/rest/provider/producer/PlainTextMessageBodyProducer.java +++ /dev/null @@ -1,92 +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.provider.producer; - -import java.io.IOException; -import java.io.OutputStream; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - -import javax.ws.rs.Produces; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.ext.MessageBodyWriter; -import javax.ws.rs.ext.Provider; - -import org.trafodion.dcs.rest.RestConstants; - -/** -* @@@ 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 @@@ - */ -@Provider -@Produces(RestConstants.MIMETYPE_TEXT) -public class PlainTextMessageBodyProducer - implements MessageBodyWriter<Object> { - - private ThreadLocal<byte[]> buffer = new ThreadLocal<byte[]>(); - - @Override - public boolean isWriteable(Class<?> arg0, Type arg1, Annotation[] arg2, - MediaType arg3) { - return true; - } - - @Override - public long getSize(Object object, Class<?> type, Type genericType, - Annotation[] annotations, MediaType mediaType) { - byte[] bytes = object.toString().getBytes(); - buffer.set(bytes); - return bytes.length; - } - - @Override - public void writeTo(Object object, Class<?> type, Type genericType, - Annotation[] annotations, MediaType mediaType, - MultivaluedMap<String, Object> httpHeaders, OutputStream outStream) - throws IOException, WebApplicationException { - byte[] bytes = buffer.get(); - outStream.write(bytes); - buffer.remove(); - } -} http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/resources/dcs-webapps/master/aggr_querystats.html ---------------------------------------------------------------------- diff --git a/dcs/src/main/resources/dcs-webapps/master/aggr_querystats.html b/dcs/src/main/resources/dcs-webapps/master/aggr_querystats.html deleted file mode 100644 index 76545ae..0000000 --- a/dcs/src/main/resources/dcs-webapps/master/aggr_querystats.html +++ /dev/null @@ -1,88 +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 @@@ --> -<head> - <link type="text/css" href="datatables/css/jquery.dataTables_themeroller.css" rel="stylesheet" /> - <link type="text/css" href="datatables/css/demo_page.css" rel="stylesheet" /> - <link type="text/css" href="datatables/css/demo_table_jui.css" rel="stylesheet" /> - <link type="text/css" href="jquery-ui/jquery-ui.css" rel="stylesheet" /> - <script type="text/javascript" src="js/lib/jquery-1.11.0.js"></script> - <script type="text/javascript" src="datatables/js/jquery.dataTables.js"></script> - -</head> - - <div id="progress"> - <p><span style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 18px;">Fetching repository data ...</p> - <img src="img/ajax-loader.gif"/> - </div> - <div id="aggr-query-stats"></div> - -<script type="text/javascript"> -$(document).ready(function(){ - document.body.style.cursor = 'wait'; - $('#aggr-query-stats').html('').css('color','black'); - var jqxhr = $.getJSON('aggr_querystats.jsp',function(result){ - - var keys; - $.each(result, function(i, data){ - keys = Object.keys(data); - }); - - var sb = '<table class="display1" id="aggr-query-stats-table" style="font-size:small"><thead><tr>'; - for (var r=0,len=keys.length; r<len; r++) { - sb += '<th><b></b>' + keys[r] + '</th>'; - } - sb += '</tr></thead><tbody> </tbody></table>'; - $('#aggr-query-stats').html( sb ); - - var aoColumns = []; - var aaData = []; - - $.each(result, function(i, data){ - var rowData = []; - $.each(keys, function(k, v) { - rowData.push(data[v]); - }); - aaData.push(rowData); - }); - - // add needed columns - $.each(keys, function(k, v) { - obj = new Object(); - obj.sTitle = v; - aoColumns.push(obj); - }); - - $('#aggr-query-stats-table').dataTable({"bProcessing": true,"bJQueryUI": true,"sPaginationType": "full_numbers","aaData": aaData, "aoColumns" : aoColumns }); - - var elem = document.getElementById('progress'); - elem.parentNode.removeChild(elem); - document.body.style.cursor = 'default'; - - }); - - jqxhr.fail(function(){ - $('#aggr-query-stats').html( jqxhr.responseText ).css('color','red'); - var elem = document.getElementById('progress'); - elem.parentNode.removeChild(elem); - document.body.style.cursor = 'default'; - }); - }); -</script> http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/resources/dcs-webapps/master/aggr_querystats.jsp ---------------------------------------------------------------------- diff --git a/dcs/src/main/resources/dcs-webapps/master/aggr_querystats.jsp b/dcs/src/main/resources/dcs-webapps/master/aggr_querystats.jsp deleted file mode 100644 index ff80698..0000000 --- a/dcs/src/main/resources/dcs-webapps/master/aggr_querystats.jsp +++ /dev/null @@ -1,85 +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 @@@ - */ ---%> -<%@ taglib uri="http://displaytag.sf.net" prefix="display" %> -<%@ page contentType="text/html;charset=UTF-8" - import="java.io.*" - import="java.util.*" - import="java.sql.*" - import="org.apache.hadoop.conf.Configuration" - import="org.trafodion.dcs.master.DcsMaster" - import="org.trafodion.dcs.util.DcsConfiguration" - import="org.trafodion.dcs.Constants" - import="org.trafodion.dcs.util.Bytes" - import="org.trafodion.dcs.util.JdbcT4Util" - import="org.codehaus.jettison.json.JSONArray" - import="org.codehaus.jettison.json.JSONException" - import="org.codehaus.jettison.json.JSONObject" - %> -<% - java.sql.Connection connection = null; - java.sql.Statement stmt = null; - java.sql.ResultSet rs = null; - - try { - DcsMaster master = (DcsMaster)getServletContext().getAttribute(DcsMaster.MASTER); - Configuration conf = master.getConfiguration(); - boolean readOnly = conf.getBoolean("dcs.master.ui.readonly", false); - String masterServerName = master.getServerName(); - int masterInfoPort = master.getInfoPort(); - String trafodionHome = master.getTrafodionHome(); - boolean trafodionLogs = conf.getBoolean(Constants.DCS_MASTER_TRAFODION_LOGS, Constants.DEFAULT_DCS_MASTER_TRAFODION_LOGS); - String queryText = conf.get(Constants.TRAFODION_REPOS_METRIC_QUERY_AGGR_TABLE_QUERY,Constants.DEFAULT_TRAFODION_REPOS_METRIC_QUERY_AGGR_TABLE_QUERY); - JSONArray metricQueryAggrJson = null; - JdbcT4Util jdbcT4Util = master.getServerManager().getJdbcT4Util(); - connection = jdbcT4Util.getConnection(); - stmt = connection.createStatement(); - rs = stmt.executeQuery(queryText); - metricQueryAggrJson = jdbcT4Util.convertResultSetToJSON(rs); - response.setContentType("application/json"); - response.getWriter().print(metricQueryAggrJson); - } catch (SQLException e) { - SQLException nextException = e; - StringBuilder sb = new StringBuilder(); - do { - sb.append(nextException.getMessage()); - sb.append("\nSQLState " + nextException.getSQLState()); - sb.append("\nError Code " + nextException.getErrorCode()); - } while ((nextException = nextException.getNextException()) != null); - response.setContentType("text/plain"); - response.setStatus(response.SC_INTERNAL_SERVER_ERROR); - response.getWriter().print(sb.toString()); - } catch (Exception e) { - response.setContentType("text/plain"); - response.setStatus(response.SC_INTERNAL_SERVER_ERROR); - response.getWriter().print(e.getMessage()); - } finally { - if (rs != null) - rs.close(); - if (stmt != null) - stmt.close(); - if (connection != null) - connection.close(); - } -%> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/resources/dcs-webapps/master/explain.html ---------------------------------------------------------------------- diff --git a/dcs/src/main/resources/dcs-webapps/master/explain.html b/dcs/src/main/resources/dcs-webapps/master/explain.html deleted file mode 100644 index d8ddd12..0000000 --- a/dcs/src/main/resources/dcs-webapps/master/explain.html +++ /dev/null @@ -1,62 +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 @@@ --> - -<head> - <link type="text/css" href="css/base.css" rel="stylesheet" /> - <link type="text/css" href="css/Spacetree.css" rel="stylesheet" /> - <link type="text/css" href="datatables/css/jquery.dataTables_themeroller.css" rel="stylesheet" /> - <link type="text/css" href="datatables/css/demo_page.css" rel="stylesheet" /> - <link type="text/css" href="datatables/css/demo_table_jui.css" rel="stylesheet" /> - <link type="text/css" href="jquery-ui/jquery-ui.css" rel="stylesheet" /> - <script type="text/javascript" src="js/lib/jquery-1.11.0.js"></script> - <script type="text/javascript" src="jquery-ui/jquery-ui.js"></script> - <script type="text/javascript" src="datatables/js/jquery.dataTables.js"></script> - <script type="text/javascript" src="js/lib/jit.js"></script> - <script type="text/javascript" src="js/ExplainPlanView.js"></script> -</head> -<div id="hpdsm-workload-summary-page" class="hp-page"> - <h1>Query</h1> - <div id="hpdsm-whiteboard-query" class="hp-panel-contents"> - <textarea id="query-text" class="hpdsm-whiteboard-query-area" name="TextMessage" spellcheck="false" placeholder="Enter a SQL query..." rows="5" style="width: 95%;color:black;font-size:14px;"></textarea> - <br> - <button id="explainQuery" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"><span class="ui-button-text">Explain</span></button> - <button id="executeQuery" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"><span class="ui-button-text">Execute</span></button> - <button id="setControlStmts" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"><span class="ui-button-text">Options</span></button> - </div> - <br/> - <h1>Result</h1> - <img id="loadingImg" src="img/ajax-loader.gif"/> - <div id="hpdsm-1"> - <div id="query-result-container" dtName=''></div> - <div id="infovis"></div> - <label id="errorText" style="color:red"></label> - </div> - -</div> -<div id="dialog-form" title="Control Options" style="display:none; height:500px;width:100%"> - <form onsubmit="return false"> - <label for="controlStmts">Control Statements : </label> - <textarea id="controlStmts" rows="9" cols="450" placeholder="control statements separated by semi-colon" style="width:450px"/> - - <!-- Allow form submission with keyboard without duplicating the dialog button --> - <input type="submit" tabindex="-1" style="position:absolute; top:-1000px"> - </form> -</div> http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/resources/dcs-webapps/master/queryPlan.jsp ---------------------------------------------------------------------- diff --git a/dcs/src/main/resources/dcs-webapps/master/queryPlan.jsp b/dcs/src/main/resources/dcs-webapps/master/queryPlan.jsp deleted file mode 100644 index 51f74ce..0000000 --- a/dcs/src/main/resources/dcs-webapps/master/queryPlan.jsp +++ /dev/null @@ -1,77 +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 @@@ - */ ---%> -<%@ page contentType="text/html;charset=UTF-8" - import="java.io.*" - import="java.util.*" - import="org.apache.hadoop.conf.Configuration" - import="org.trafodion.dcs.master.DcsMaster" - import="org.trafodion.dcs.util.DcsConfiguration" - import="org.trafodion.dcs.Constants" - import="org.trafodion.dcs.util.Bytes" - import="org.codehaus.jettison.json.JSONArray" - import="org.codehaus.jettison.json.JSONException" - import="org.codehaus.jettison.json.JSONObject" - import="org.trafodion.dcs.master.QueryPlanModel" - import="org.trafodion.dcs.master.QueryPlanResponse" - import="org.codehaus.jackson.JsonGenerationException" - import="org.codehaus.jackson.map.JsonMappingException" - import="org.codehaus.jackson.map.ObjectMapper" - %> -<% - try { - DcsMaster master = (DcsMaster)getServletContext().getAttribute(DcsMaster.MASTER); - Configuration conf = master.getConfiguration(); - - BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream())); - String json = ""; - if(br != null) { - json = br.readLine(); - } - - JSONObject jsonObject = new JSONObject(json); - String sQuery = jsonObject.getString("sQuery"); - String sControlStmts = jsonObject.getString("sControlStmts"); - - if(sQuery == null || sQuery.trim().length() < 1) { - response.setContentType("text/plain"); - response.setStatus(response.SC_INTERNAL_SERVER_ERROR); - response.getWriter().print("The query text cannot be empty"); - return; - } - - QueryPlanModel qpm = new QueryPlanModel(); - qpm.GeneratePlan(master.getServerManager().getJdbcT4Util(),sQuery, sControlStmts); - QueryPlanResponse qpr = qpm.getQueryPlanResponse(); - ObjectMapper mapper = new ObjectMapper(); - JSONObject queryPlanJson = null; - queryPlanJson = new JSONObject(mapper.writeValueAsString(qpr)); - response.setContentType("application/json"); - response.getWriter().print(queryPlanJson); - } catch (Exception e) { - response.setContentType("text/plain"); - response.setStatus(response.SC_INTERNAL_SERVER_ERROR); - response.getWriter().print(e.getMessage()); - } - %> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/681cad66/dcs/src/main/resources/dcs-webapps/master/querystats.html ---------------------------------------------------------------------- diff --git a/dcs/src/main/resources/dcs-webapps/master/querystats.html b/dcs/src/main/resources/dcs-webapps/master/querystats.html deleted file mode 100644 index d7f2fdb..0000000 --- a/dcs/src/main/resources/dcs-webapps/master/querystats.html +++ /dev/null @@ -1,89 +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 @@@ --> -<head> - <link type="text/css" href="datatables/css/jquery.dataTables_themeroller.css" rel="stylesheet" /> - <link type="text/css" href="datatables/css/demo_page.css" rel="stylesheet" /> - <link type="text/css" href="datatables/css/demo_table_jui.css" rel="stylesheet" /> - <link type="text/css" href="jquery-ui/jquery-ui.css" rel="stylesheet" /> - <script type="text/javascript" src="js/lib/jquery-1.11.0.js"></script> - <script type="text/javascript" src="datatables/js/jquery.dataTables.js"></script> - -</head> - - <div id="progress"> - <p><span style="font-family: Georgia, 'Times New Roman', Times, serif; font-size: 18px;">Fetching repository data ...</p> - <img src="img/ajax-loader.gif"/> - </div> - <div id="query-stats"></div> - -<script type="text/javascript"> -$(document).ready(function(){ - document.body.style.cursor = 'wait'; - $('#query-stats').html('').css('color','black'); - var jqxhr = $.getJSON('querystats.jsp',function(result){ - - var keys; - $.each(result, function(i, data){ - keys = Object.keys(data); - }); - - var sb = '<table class="display1" id="query-stats-table" style="font-size:small"><thead><tr>'; - for (var r=0,len=keys.length; r<len; r++) { - sb += '<th><b></b>' + keys[r] + '</th>'; - } - sb += '</tr></thead><tbody> </tbody></table>'; - $('#query-stats').html( sb ); - - var aoColumns = []; - var aaData = []; - - $.each(result, function(i, data){ - var rowData = []; - $.each(keys, function(k, v) { - rowData.push(data[v]); - }); - aaData.push(rowData); - }); - - // add needed columns - $.each(keys, function(k, v) { - obj = new Object(); - obj.sTitle = v; - aoColumns.push(obj); - }); - - $('#query-stats-table').dataTable({"bProcessing": true,"bJQueryUI": true,"sPaginationType": "full_numbers","aaData": aaData, "aoColumns" : aoColumns }); - - var elem = document.getElementById('progress'); - elem.parentNode.removeChild(elem); - document.body.style.cursor = 'default'; - - }); - - jqxhr.fail(function(){ - $('#query-stats').html( jqxhr.responseText ).css('color','red'); - var elem = document.getElementById('progress'); - elem.parentNode.removeChild(elem); - document.body.style.cursor = 'default'; - }); - - }); -</script>
