Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 92D8A200CD6 for ; Mon, 31 Jul 2017 21:53:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 914B7165D18; Mon, 31 Jul 2017 19:53:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 17942165D16 for ; Mon, 31 Jul 2017 21:53:51 +0200 (CEST) Received: (qmail 27105 invoked by uid 500); 31 Jul 2017 19:53:51 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 27039 invoked by uid 99); 31 Jul 2017 19:53:51 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 31 Jul 2017 19:53:51 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 21598E96B2; Mon, 31 Jul 2017 19:53:51 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tdsilva@apache.org To: commits@phoenix.apache.org Date: Mon, 31 Jul 2017 19:53:52 -0000 Message-Id: In-Reply-To: <21c117ce28eb432aac9340c12396a6e4@git.apache.org> References: <21c117ce28eb432aac9340c12396a6e4@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/2] phoenix git commit: PHOENIX-4022 Add PhoenixMetricsLog interface that can be used to log metrics for queries and mutations archived-at: Mon, 31 Jul 2017 19:53:54 -0000 PHOENIX-4022 Add PhoenixMetricsLog interface that can be used to log metrics for queries and mutations Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/bd35b0e8 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/bd35b0e8 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/bd35b0e8 Branch: refs/heads/4.x-HBase-0.98 Commit: bd35b0e868d0b9b6cda13c299258dd8b27688967 Parents: 38d5363 Author: Thomas Authored: Thu Jul 13 15:08:23 2017 -0700 Committer: Thomas Committed: Mon Jul 31 12:46:28 2017 -0700 ---------------------------------------------------------------------- .../phoenix/monitoring/PhoenixMetricsIT.java | 75 +- .../apache/phoenix/trace/BaseTracingTestIT.java | 1 + .../phoenix/trace/DelegateConnection.java | 324 ------ .../apache/phoenix/jdbc/DelegateConnection.java | 321 ++++++ .../phoenix/jdbc/DelegatePreparedStatement.java | 553 ++++++++++ .../apache/phoenix/jdbc/DelegateResultSet.java | 1008 ++++++++++++++++++ .../apache/phoenix/jdbc/DelegateStatement.java | 254 +++++ .../phoenix/jdbc/LoggingPhoenixConnection.java | 109 ++ .../jdbc/LoggingPhoenixPreparedStatement.java | 53 + .../phoenix/jdbc/LoggingPhoenixResultSet.java | 45 + .../phoenix/jdbc/LoggingPhoenixStatement.java | 48 + .../apache/phoenix/jdbc/PhoenixMetricsLog.java | 35 + 12 files changed, 2501 insertions(+), 325 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java index 2c619c9..81428e6 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java @@ -62,13 +62,16 @@ import org.apache.phoenix.end2end.BaseUniqueNamesOwnClusterIT; import org.apache.phoenix.exception.SQLExceptionCode; import org.apache.phoenix.jdbc.PhoenixConnection; import org.apache.phoenix.jdbc.PhoenixDriver; +import org.apache.phoenix.jdbc.PhoenixMetricsLog; import org.apache.phoenix.jdbc.PhoenixResultSet; +import org.apache.phoenix.jdbc.LoggingPhoenixConnection; import org.apache.phoenix.query.QueryServices; import org.apache.phoenix.util.PhoenixRuntime; import org.apache.phoenix.util.ReadOnlyProps; import org.junit.BeforeClass; import org.junit.Test; import org.mockito.internal.util.reflection.Whitebox; +import org.slf4j.Logger; import com.google.common.base.Joiner; import com.google.common.collect.Lists; @@ -277,7 +280,7 @@ public class PhoenixMetricsIT extends BaseUniqueNamesOwnClusterIT { assertTrue(mutationBatchSizePresent); assertTrue(mutationCommitTimePresent); assertTrue(mutationBytesPresent); - assertTrue(mutationBytesPresent); + assertTrue(mutationBatchFailedPresent); } Map> readMetrics = PhoenixRuntime.getReadMetricInfoForMutationsSinceLastReset(pConn); assertEquals("Read metrics should be empty", 0, readMetrics.size()); @@ -1007,5 +1010,75 @@ public class PhoenixMetricsIT extends BaseUniqueNamesOwnClusterIT { return c; } } + + @Test + public void testPhoenixMetricsLogged() throws Exception { + final Map overAllQueryMetricsMap = Maps.newHashMap(); + final Map> requestReadMetricsMap = Maps.newHashMap(); + final Map> mutationWriteMetricsMap = Maps.newHashMap(); + final Map> mutationReadMetricsMap = Maps.newHashMap(); + + String tableName1 = generateUniqueName(); + String ddl = "CREATE TABLE " + tableName1 + " (K VARCHAR NOT NULL PRIMARY KEY, V VARCHAR)"; + Connection ddlConn = DriverManager.getConnection(getUrl()); + ddlConn.createStatement().execute(ddl); + ddlConn.close(); + insertRowsInTable(tableName1, 10); + + String tableName2 = generateUniqueName(); + ddl = "CREATE TABLE " + tableName2 + " (K VARCHAR NOT NULL PRIMARY KEY, V VARCHAR)"; + ddlConn = DriverManager.getConnection(getUrl()); + ddlConn.createStatement().execute(ddl); + ddlConn.close(); + + Connection conn = DriverManager.getConnection(getUrl()); + LoggingPhoenixConnection protectedConn = + new LoggingPhoenixConnection(conn, new PhoenixMetricsLog() { + @Override + public void logOverAllReadRequestMetrics(Logger logger, + Map overAllQueryMetrics) { + overAllQueryMetricsMap.putAll(overAllQueryMetrics); + } + + @Override + public void logRequestReadMetrics(Logger logger, + Map> requestReadMetrics) { + requestReadMetricsMap.putAll(requestReadMetrics); + } + + @Override + public void logWriteMetricsfoForMutations(Logger logger, + Map> mutationWriteMetrics) { + mutationWriteMetricsMap.putAll(mutationWriteMetrics); + } + + @Override + public void logReadMetricInfoForMutationsSinceLastReset(Logger logger, + Map> mutationReadMetrics) { + mutationReadMetricsMap.putAll(mutationReadMetrics); + } + }); + + // run SELECT to verify read metrics are logged + String query = "SELECT * FROM " + tableName1; + Statement stmt = protectedConn.createStatement(); + ResultSet rs = stmt.executeQuery(query); + while (rs.next()) { + } + rs.close(); + assertTrue("Read metrics for not found for " + tableName1, + requestReadMetricsMap.get(tableName1).size() > 0); + assertTrue("Overall read metrics for not found ", overAllQueryMetricsMap.size() > 0); + + // run UPSERT SELECT to verify mutation metrics are logged + String upsertSelect = "UPSERT INTO " + tableName2 + " SELECT * FROM " + tableName1; + protectedConn.createStatement().executeUpdate(upsertSelect); + protectedConn.commit(); + assertTrue("Mutation write metrics for not found for " + tableName2, + mutationWriteMetricsMap.get(tableName2).size() > 0); + assertTrue("Mutation read metrics for not found for " + tableName1, + mutationReadMetricsMap.get(tableName1).size() > 0); + protectedConn.close(); + } } http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/it/java/org/apache/phoenix/trace/BaseTracingTestIT.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/trace/BaseTracingTestIT.java b/phoenix-core/src/it/java/org/apache/phoenix/trace/BaseTracingTestIT.java index eed5618..d17113d 100644 --- a/phoenix-core/src/it/java/org/apache/phoenix/trace/BaseTracingTestIT.java +++ b/phoenix-core/src/it/java/org/apache/phoenix/trace/BaseTracingTestIT.java @@ -38,6 +38,7 @@ import org.apache.hadoop.metrics2.impl.ExposedMetricsRecordImpl; import org.apache.hadoop.metrics2.lib.ExposedMetricsInfoImpl; import org.apache.phoenix.end2end.ParallelStatsDisabledIT; import org.apache.phoenix.metrics.MetricInfo; +import org.apache.phoenix.jdbc.DelegateConnection; import org.apache.phoenix.trace.util.Tracing; import org.apache.phoenix.trace.util.Tracing.Frequency; import org.apache.phoenix.util.PhoenixRuntime; http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/it/java/org/apache/phoenix/trace/DelegateConnection.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/it/java/org/apache/phoenix/trace/DelegateConnection.java b/phoenix-core/src/it/java/org/apache/phoenix/trace/DelegateConnection.java deleted file mode 100644 index 8fff469..0000000 --- a/phoenix-core/src/it/java/org/apache/phoenix/trace/DelegateConnection.java +++ /dev/null @@ -1,324 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.phoenix.trace; - -import java.sql.Array; -import java.sql.Blob; -import java.sql.CallableStatement; -import java.sql.Clob; -import java.sql.Connection; -import java.sql.DatabaseMetaData; -import java.sql.NClob; -import java.sql.PreparedStatement; -import java.sql.SQLClientInfoException; -import java.sql.SQLException; -import java.sql.SQLWarning; -import java.sql.SQLXML; -import java.sql.Savepoint; -import java.sql.Statement; -import java.sql.Struct; -import java.util.Map; -import java.util.Properties; -import java.util.concurrent.Executor; - -/** - * Simple {@link Connection} that just delegates to an underlying {@link Connection}. - */ -public class DelegateConnection implements Connection { - - @Override - public T unwrap(Class iface) throws SQLException { - return conn.unwrap(iface); - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return conn.isWrapperFor(iface); - } - - @Override - public Statement createStatement() throws SQLException { - return conn.createStatement(); - } - - @Override - public PreparedStatement prepareStatement(String sql) throws SQLException { - return conn.prepareStatement(sql); - } - - @Override - public CallableStatement prepareCall(String sql) throws SQLException { - return conn.prepareCall(sql); - } - - @Override - public String nativeSQL(String sql) throws SQLException { - return conn.nativeSQL(sql); - } - - @Override - public void setAutoCommit(boolean autoCommit) throws SQLException { - conn.setAutoCommit(autoCommit); - } - - @Override - public boolean getAutoCommit() throws SQLException { - return conn.getAutoCommit(); - } - - @Override - public void commit() throws SQLException { - conn.commit(); - } - - @Override - public void rollback() throws SQLException { - conn.rollback(); - } - - @Override - public void close() throws SQLException { - conn.close(); - } - - @Override - public boolean isClosed() throws SQLException { - return conn.isClosed(); - } - - @Override - public DatabaseMetaData getMetaData() throws SQLException { - return conn.getMetaData(); - } - - @Override - public void setReadOnly(boolean readOnly) throws SQLException { - conn.setReadOnly(readOnly); - } - - @Override - public boolean isReadOnly() throws SQLException { - return conn.isReadOnly(); - } - - @Override - public void setCatalog(String catalog) throws SQLException { - conn.setCatalog(catalog); - } - - @Override - public String getCatalog() throws SQLException { - return conn.getCatalog(); - } - - @Override - public void setTransactionIsolation(int level) throws SQLException { - conn.setTransactionIsolation(level); - } - - @Override - public int getTransactionIsolation() throws SQLException { - return conn.getTransactionIsolation(); - } - - @Override - public SQLWarning getWarnings() throws SQLException { - return conn.getWarnings(); - } - - @Override - public void clearWarnings() throws SQLException { - conn.clearWarnings(); - } - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { - return conn.createStatement(resultSetType, resultSetConcurrency); - } - - @Override - public PreparedStatement - prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { - return conn.prepareStatement(sql, resultSetType, resultSetConcurrency); - } - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) - throws SQLException { - return conn.prepareCall(sql, resultSetType, resultSetConcurrency); - } - - @Override - public Map> getTypeMap() throws SQLException { - return conn.getTypeMap(); - } - - @Override - public void setTypeMap(Map> map) throws SQLException { - conn.setTypeMap(map); - } - - @Override - public void setHoldability(int holdability) throws SQLException { - conn.setHoldability(holdability); - } - - @Override - public int getHoldability() throws SQLException { - return conn.getHoldability(); - } - - @Override - public Savepoint setSavepoint() throws SQLException { - return conn.setSavepoint(); - } - - @Override - public Savepoint setSavepoint(String name) throws SQLException { - return conn.setSavepoint(name); - } - - @Override - public void rollback(Savepoint savepoint) throws SQLException { - conn.rollback(savepoint); - } - - @Override - public void releaseSavepoint(Savepoint savepoint) throws SQLException { - conn.releaseSavepoint(savepoint); - } - - @Override - public Statement createStatement(int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public PreparedStatement prepareStatement(String sql, int resultSetType, - int resultSetConcurrency, int resultSetHoldability) throws SQLException { - return conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, - int resultSetHoldability) throws SQLException { - return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); - } - - @Override - public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { - return conn.prepareStatement(sql, autoGeneratedKeys); - } - - @Override - public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { - return conn.prepareStatement(sql, columnIndexes); - } - - @Override - public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { - return conn.prepareStatement(sql, columnNames); - } - - @Override - public Clob createClob() throws SQLException { - return conn.createClob(); - } - - @Override - public Blob createBlob() throws SQLException { - return conn.createBlob(); - } - - @Override - public NClob createNClob() throws SQLException { - return conn.createNClob(); - } - - @Override - public SQLXML createSQLXML() throws SQLException { - return conn.createSQLXML(); - } - - @Override - public boolean isValid(int timeout) throws SQLException { - return conn.isValid(timeout); - } - - @Override - public void setClientInfo(String name, String value) throws SQLClientInfoException { - conn.setClientInfo(name, value); - } - - @Override - public void setClientInfo(Properties properties) throws SQLClientInfoException { - conn.setClientInfo(properties); - } - - @Override - public String getClientInfo(String name) throws SQLException { - return conn.getClientInfo(name); - } - - @Override - public Properties getClientInfo() throws SQLException { - return conn.getClientInfo(); - } - - @Override - public Array createArrayOf(String typeName, Object[] elements) throws SQLException { - return conn.createArrayOf(typeName, elements); - } - - @Override - public Struct createStruct(String typeName, Object[] attributes) throws SQLException { - return conn.createStruct(typeName, attributes); - } - - private Connection conn; - - public DelegateConnection(Connection conn) { - this.conn = conn; - } - - @Override - public void setSchema(String schema) throws SQLException { - conn.setSchema(schema); - } - - @Override - public String getSchema() throws SQLException { - return conn.getSchema(); - } - - @Override - public void abort(Executor executor) throws SQLException { - conn.abort(executor); - } - - @Override - public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { - conn.setNetworkTimeout(executor, milliseconds); - } - - @Override - public int getNetworkTimeout() throws SQLException { - return conn.getNetworkTimeout(); - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateConnection.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateConnection.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateConnection.java new file mode 100644 index 0000000..40c02d2 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateConnection.java @@ -0,0 +1,321 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable + * law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License + * for the specific language governing permissions and limitations under the License. + */ +package org.apache.phoenix.jdbc; + +import java.sql.Array; +import java.sql.Blob; +import java.sql.CallableStatement; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.NClob; +import java.sql.PreparedStatement; +import java.sql.SQLClientInfoException; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Savepoint; +import java.sql.Statement; +import java.sql.Struct; +import java.util.Map; +import java.util.Properties; +import java.util.concurrent.Executor; + +/** + * Simple {@link Connection} that just delegates to an underlying {@link Connection}. + */ +public class DelegateConnection implements Connection { + + protected Connection conn; + + public DelegateConnection(Connection conn) { + this.conn = conn; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return conn.unwrap(iface); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return conn.isWrapperFor(iface); + } + + @Override + public Statement createStatement() throws SQLException { + return conn.createStatement(); + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + return conn.prepareStatement(sql); + } + + @Override + public CallableStatement prepareCall(String sql) throws SQLException { + return conn.prepareCall(sql); + } + + @Override + public String nativeSQL(String sql) throws SQLException { + return conn.nativeSQL(sql); + } + + @Override + public void setAutoCommit(boolean autoCommit) throws SQLException { + conn.setAutoCommit(autoCommit); + } + + @Override + public boolean getAutoCommit() throws SQLException { + return conn.getAutoCommit(); + } + + @Override + public void commit() throws SQLException { + conn.commit(); + } + + @Override + public void rollback() throws SQLException { + conn.rollback(); + } + + @Override + public void close() throws SQLException { + conn.close(); + } + + @Override + public boolean isClosed() throws SQLException { + return conn.isClosed(); + } + + @Override + public DatabaseMetaData getMetaData() throws SQLException { + return conn.getMetaData(); + } + + @Override + public void setReadOnly(boolean readOnly) throws SQLException { + conn.setReadOnly(readOnly); + } + + @Override + public boolean isReadOnly() throws SQLException { + return conn.isReadOnly(); + } + + @Override + public void setCatalog(String catalog) throws SQLException { + conn.setCatalog(catalog); + } + + @Override + public String getCatalog() throws SQLException { + return conn.getCatalog(); + } + + @Override + public void setTransactionIsolation(int level) throws SQLException { + conn.setTransactionIsolation(level); + } + + @Override + public int getTransactionIsolation() throws SQLException { + return conn.getTransactionIsolation(); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return conn.getWarnings(); + } + + @Override + public void clearWarnings() throws SQLException { + conn.clearWarnings(); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency) + throws SQLException { + return conn.createStatement(resultSetType, resultSetConcurrency); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, + int resultSetConcurrency) throws SQLException { + return conn.prepareStatement(sql, resultSetType, resultSetConcurrency); + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) + throws SQLException { + return conn.prepareCall(sql, resultSetType, resultSetConcurrency); + } + + @Override + public Map> getTypeMap() throws SQLException { + return conn.getTypeMap(); + } + + @Override + public void setTypeMap(Map> map) throws SQLException { + conn.setTypeMap(map); + } + + @Override + public void setHoldability(int holdability) throws SQLException { + conn.setHoldability(holdability); + } + + @Override + public int getHoldability() throws SQLException { + return conn.getHoldability(); + } + + @Override + public Savepoint setSavepoint() throws SQLException { + return conn.setSavepoint(); + } + + @Override + public Savepoint setSavepoint(String name) throws SQLException { + return conn.setSavepoint(name); + } + + @Override + public void rollback(Savepoint savepoint) throws SQLException { + conn.rollback(savepoint); + } + + @Override + public void releaseSavepoint(Savepoint savepoint) throws SQLException { + conn.releaseSavepoint(savepoint); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, + int resultSetConcurrency, int resultSetHoldability) throws SQLException { + return conn.prepareStatement(sql, resultSetType, resultSetConcurrency, + resultSetHoldability); + } + + @Override + public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) + throws SQLException { + return conn.prepareStatement(sql, autoGeneratedKeys); + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + return conn.prepareStatement(sql, columnIndexes); + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) + throws SQLException { + return conn.prepareStatement(sql, columnNames); + } + + @Override + public Clob createClob() throws SQLException { + return conn.createClob(); + } + + @Override + public Blob createBlob() throws SQLException { + return conn.createBlob(); + } + + @Override + public NClob createNClob() throws SQLException { + return conn.createNClob(); + } + + @Override + public SQLXML createSQLXML() throws SQLException { + return conn.createSQLXML(); + } + + @Override + public boolean isValid(int timeout) throws SQLException { + return conn.isValid(timeout); + } + + @Override + public void setClientInfo(String name, String value) throws SQLClientInfoException { + conn.setClientInfo(name, value); + } + + @Override + public void setClientInfo(Properties properties) throws SQLClientInfoException { + conn.setClientInfo(properties); + } + + @Override + public String getClientInfo(String name) throws SQLException { + return conn.getClientInfo(name); + } + + @Override + public Properties getClientInfo() throws SQLException { + return conn.getClientInfo(); + } + + @Override + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { + return conn.createArrayOf(typeName, elements); + } + + @Override + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { + return conn.createStruct(typeName, attributes); + } + + @Override + public void setSchema(String schema) throws SQLException { + conn.setSchema(schema); + } + + @Override + public String getSchema() throws SQLException { + return conn.getSchema(); + } + + @Override + public void abort(Executor executor) throws SQLException { + conn.abort(executor); + } + + @Override + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { + conn.setNetworkTimeout(executor, milliseconds); + } + + @Override + public int getNetworkTimeout() throws SQLException { + return conn.getNetworkTimeout(); + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegatePreparedStatement.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegatePreparedStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegatePreparedStatement.java new file mode 100644 index 0000000..85301c9 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegatePreparedStatement.java @@ -0,0 +1,553 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Connection; +import java.sql.Date; +import java.sql.NClob; +import java.sql.ParameterMetaData; +import java.sql.PreparedStatement; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; + +public class DelegatePreparedStatement implements PreparedStatement { + + protected PreparedStatement ps; + + public DelegatePreparedStatement(PreparedStatement ps) { + this.ps = ps; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return ps.unwrap(iface); + } + + @Override + public ResultSet executeQuery(String sql) throws SQLException { + return ps.executeQuery(sql); + } + + @Override + public ResultSet executeQuery() throws SQLException { + return ps.executeQuery(); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return ps.isWrapperFor(iface); + } + + @Override + public int executeUpdate(String sql) throws SQLException { + return ps.executeUpdate(sql); + } + + @Override + public int executeUpdate() throws SQLException { + return ps.executeUpdate(); + } + + @Override + public void setNull(int parameterIndex, int sqlType) throws SQLException { + ps.setNull(parameterIndex, sqlType); + } + + @Override + public void close() throws SQLException { + ps.close(); + } + + @Override + public int getMaxFieldSize() throws SQLException { + return ps.getMaxFieldSize(); + } + + @Override + public void setBoolean(int parameterIndex, boolean x) throws SQLException { + ps.setBoolean(parameterIndex, x); + } + + @Override + public void setByte(int parameterIndex, byte x) throws SQLException { + ps.setByte(parameterIndex, x); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + ps.setMaxFieldSize(max); + } + + @Override + public void setShort(int parameterIndex, short x) throws SQLException { + ps.setShort(parameterIndex, x); + } + + @Override + public int getMaxRows() throws SQLException { + return ps.getMaxRows(); + } + + @Override + public void setInt(int parameterIndex, int x) throws SQLException { + ps.setInt(parameterIndex, x); + } + + @Override + public void setMaxRows(int max) throws SQLException { + ps.setMaxRows(max); + } + + @Override + public void setLong(int parameterIndex, long x) throws SQLException { + ps.setLong(parameterIndex, x); + } + + @Override + public void setFloat(int parameterIndex, float x) throws SQLException { + ps.setFloat(parameterIndex, x); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + ps.setEscapeProcessing(enable); + } + + @Override + public void setDouble(int parameterIndex, double x) throws SQLException { + ps.setDouble(parameterIndex, x); + } + + @Override + public int getQueryTimeout() throws SQLException { + return ps.getQueryTimeout(); + } + + @Override + public void setBigDecimal(int parameterIndex, BigDecimal x) throws SQLException { + ps.setBigDecimal(parameterIndex, x); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + ps.setQueryTimeout(seconds); + } + + @Override + public void setString(int parameterIndex, String x) throws SQLException { + ps.setString(parameterIndex, x); + } + + @Override + public void setBytes(int parameterIndex, byte[] x) throws SQLException { + ps.setBytes(parameterIndex, x); + } + + @Override + public void cancel() throws SQLException { + ps.cancel(); + } + + @Override + public void setDate(int parameterIndex, Date x) throws SQLException { + ps.setDate(parameterIndex, x); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return ps.getWarnings(); + } + + @Override + public void setTime(int parameterIndex, Time x) throws SQLException { + ps.setTime(parameterIndex, x); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x) throws SQLException { + ps.setTimestamp(parameterIndex, x); + } + + @Override + public void clearWarnings() throws SQLException { + ps.clearWarnings(); + } + + @Override + public void setCursorName(String name) throws SQLException { + ps.setCursorName(name); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, int length) throws SQLException { + ps.setAsciiStream(parameterIndex, x, length); + } + + @Override + public void setUnicodeStream(int parameterIndex, InputStream x, int length) + throws SQLException { + ps.setUnicodeStream(parameterIndex, x, length); + } + + @Override + public boolean execute(String sql) throws SQLException { + return ps.execute(sql); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, int length) throws SQLException { + ps.setBinaryStream(parameterIndex, x, length); + } + + @Override + public ResultSet getResultSet() throws SQLException { + return ps.getResultSet(); + } + + @Override + public int getUpdateCount() throws SQLException { + return ps.getUpdateCount(); + } + + @Override + public void clearParameters() throws SQLException { + ps.clearParameters(); + } + + @Override + public boolean getMoreResults() throws SQLException { + return ps.getMoreResults(); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType) throws SQLException { + ps.setObject(parameterIndex, x, targetSqlType); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + ps.setFetchDirection(direction); + } + + @Override + public void setObject(int parameterIndex, Object x) throws SQLException { + ps.setObject(parameterIndex, x); + } + + @Override + public int getFetchDirection() throws SQLException { + return ps.getFetchDirection(); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + ps.setFetchSize(rows); + } + + @Override + public int getFetchSize() throws SQLException { + return ps.getFetchSize(); + } + + @Override + public boolean execute() throws SQLException { + return ps.execute(); + } + + @Override + public int getResultSetConcurrency() throws SQLException { + return ps.getResultSetConcurrency(); + } + + @Override + public int getResultSetType() throws SQLException { + return ps.getResultSetType(); + } + + @Override + public void addBatch(String sql) throws SQLException { + ps.addBatch(sql); + } + + @Override + public void addBatch() throws SQLException { + ps.addBatch(); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, int length) + throws SQLException { + ps.setCharacterStream(parameterIndex, reader, length); + } + + @Override + public void clearBatch() throws SQLException { + ps.clearBatch(); + } + + @Override + public int[] executeBatch() throws SQLException { + return ps.executeBatch(); + } + + @Override + public void setRef(int parameterIndex, Ref x) throws SQLException { + ps.setRef(parameterIndex, x); + } + + @Override + public void setBlob(int parameterIndex, Blob x) throws SQLException { + ps.setBlob(parameterIndex, x); + } + + @Override + public void setClob(int parameterIndex, Clob x) throws SQLException { + ps.setClob(parameterIndex, x); + } + + @Override + public void setArray(int parameterIndex, Array x) throws SQLException { + ps.setArray(parameterIndex, x); + } + + @Override + public Connection getConnection() throws SQLException { + return ps.getConnection(); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + return ps.getMetaData(); + } + + @Override + public void setDate(int parameterIndex, Date x, Calendar cal) throws SQLException { + ps.setDate(parameterIndex, x, cal); + } + + @Override + public boolean getMoreResults(int current) throws SQLException { + return ps.getMoreResults(current); + } + + @Override + public void setTime(int parameterIndex, Time x, Calendar cal) throws SQLException { + ps.setTime(parameterIndex, x, cal); + } + + @Override + public ResultSet getGeneratedKeys() throws SQLException { + return ps.getGeneratedKeys(); + } + + @Override + public void setTimestamp(int parameterIndex, Timestamp x, Calendar cal) throws SQLException { + ps.setTimestamp(parameterIndex, x, cal); + } + + @Override + public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + return ps.executeUpdate(sql, autoGeneratedKeys); + } + + @Override + public void setNull(int parameterIndex, int sqlType, String typeName) throws SQLException { + ps.setNull(parameterIndex, sqlType, typeName); + } + + @Override + public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { + return ps.executeUpdate(sql, columnIndexes); + } + + @Override + public void setURL(int parameterIndex, URL x) throws SQLException { + ps.setURL(parameterIndex, x); + } + + @Override + public ParameterMetaData getParameterMetaData() throws SQLException { + return ps.getParameterMetaData(); + } + + @Override + public void setRowId(int parameterIndex, RowId x) throws SQLException { + ps.setRowId(parameterIndex, x); + } + + @Override + public int executeUpdate(String sql, String[] columnNames) throws SQLException { + return ps.executeUpdate(sql, columnNames); + } + + @Override + public void setNString(int parameterIndex, String value) throws SQLException { + ps.setNString(parameterIndex, value); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value, long length) + throws SQLException { + ps.setNCharacterStream(parameterIndex, value, length); + } + + @Override + public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { + return ps.execute(sql, autoGeneratedKeys); + } + + @Override + public void setNClob(int parameterIndex, NClob value) throws SQLException { + ps.setNClob(parameterIndex, value); + } + + @Override + public void setClob(int parameterIndex, Reader reader, long length) throws SQLException { + ps.setClob(parameterIndex, reader, length); + } + + @Override + public boolean execute(String sql, int[] columnIndexes) throws SQLException { + return ps.execute(sql, columnIndexes); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream, long length) + throws SQLException { + ps.setBlob(parameterIndex, inputStream, length); + } + + @Override + public void setNClob(int parameterIndex, Reader reader, long length) throws SQLException { + ps.setNClob(parameterIndex, reader, length); + } + + @Override + public boolean execute(String sql, String[] columnNames) throws SQLException { + return ps.execute(sql, columnNames); + } + + @Override + public void setSQLXML(int parameterIndex, SQLXML xmlObject) throws SQLException { + ps.setSQLXML(parameterIndex, xmlObject); + } + + @Override + public void setObject(int parameterIndex, Object x, int targetSqlType, int scaleOrLength) + throws SQLException { + ps.setObject(parameterIndex, x, targetSqlType, scaleOrLength); + } + + @Override + public int getResultSetHoldability() throws SQLException { + return ps.getResultSetHoldability(); + } + + @Override + public boolean isClosed() throws SQLException { + return ps.isClosed(); + } + + @Override + public void setPoolable(boolean poolable) throws SQLException { + ps.setPoolable(poolable); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x, long length) throws SQLException { + ps.setAsciiStream(parameterIndex, x, length); + } + + @Override + public boolean isPoolable() throws SQLException { + return ps.isPoolable(); + } + + @Override + public void closeOnCompletion() throws SQLException { + ps.closeOnCompletion(); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x, long length) + throws SQLException { + ps.setBinaryStream(parameterIndex, x, length); + } + + @Override + public boolean isCloseOnCompletion() throws SQLException { + return ps.isCloseOnCompletion(); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader, long length) + throws SQLException { + ps.setCharacterStream(parameterIndex, reader, length); + } + + @Override + public void setAsciiStream(int parameterIndex, InputStream x) throws SQLException { + ps.setAsciiStream(parameterIndex, x); + } + + @Override + public void setBinaryStream(int parameterIndex, InputStream x) throws SQLException { + ps.setBinaryStream(parameterIndex, x); + } + + @Override + public void setCharacterStream(int parameterIndex, Reader reader) throws SQLException { + ps.setCharacterStream(parameterIndex, reader); + } + + @Override + public void setNCharacterStream(int parameterIndex, Reader value) throws SQLException { + ps.setNCharacterStream(parameterIndex, value); + } + + @Override + public void setClob(int parameterIndex, Reader reader) throws SQLException { + ps.setClob(parameterIndex, reader); + } + + @Override + public void setBlob(int parameterIndex, InputStream inputStream) throws SQLException { + ps.setBlob(parameterIndex, inputStream); + } + + @Override + public void setNClob(int parameterIndex, Reader reader) throws SQLException { + ps.setNClob(parameterIndex, reader); + } + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateResultSet.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateResultSet.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateResultSet.java new file mode 100644 index 0000000..617943c --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateResultSet.java @@ -0,0 +1,1008 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more contributor license + * agreements. See the NOTICE file distributed with this work for additional information regarding + * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. You may obtain a + * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable + * law or agreed to in writing, software distributed under the License is distributed on an "AS IS" + * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License + * for the specific language governing permissions and limitations under the License. + */ +package org.apache.phoenix.jdbc; + +import java.io.InputStream; +import java.io.Reader; +import java.math.BigDecimal; +import java.net.URL; +import java.sql.Array; +import java.sql.Blob; +import java.sql.Clob; +import java.sql.Date; +import java.sql.NClob; +import java.sql.Ref; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.RowId; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.SQLXML; +import java.sql.Statement; +import java.sql.Time; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Map; + +public class DelegateResultSet implements ResultSet { + + protected ResultSet rs; + + public DelegateResultSet(ResultSet rs) { + this.rs = rs; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return rs.unwrap(iface); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return rs.isWrapperFor(iface); + } + + @Override + public boolean next() throws SQLException { + return rs.next(); + } + + @Override + public void close() throws SQLException { + rs.close(); + } + + @Override + public boolean wasNull() throws SQLException { + return rs.wasNull(); + } + + @Override + public String getString(int columnIndex) throws SQLException { + return rs.getString(columnIndex); + } + + @Override + public boolean getBoolean(int columnIndex) throws SQLException { + return rs.getBoolean(columnIndex); + } + + @Override + public byte getByte(int columnIndex) throws SQLException { + return rs.getByte(columnIndex); + } + + @Override + public short getShort(int columnIndex) throws SQLException { + return rs.getShort(columnIndex); + } + + @Override + public int getInt(int columnIndex) throws SQLException { + return rs.getInt(columnIndex); + } + + @Override + public long getLong(int columnIndex) throws SQLException { + return rs.getLong(columnIndex); + } + + @Override + public float getFloat(int columnIndex) throws SQLException { + return rs.getFloat(columnIndex); + } + + @Override + public double getDouble(int columnIndex) throws SQLException { + return rs.getDouble(columnIndex); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException { + return rs.getBigDecimal(columnIndex, scale); + } + + @Override + public byte[] getBytes(int columnIndex) throws SQLException { + return rs.getBytes(columnIndex); + } + + @Override + public Date getDate(int columnIndex) throws SQLException { + return rs.getDate(columnIndex); + } + + @Override + public Time getTime(int columnIndex) throws SQLException { + return rs.getTime(columnIndex); + } + + @Override + public Timestamp getTimestamp(int columnIndex) throws SQLException { + return rs.getTimestamp(columnIndex); + } + + @Override + public InputStream getAsciiStream(int columnIndex) throws SQLException { + return rs.getAsciiStream(columnIndex); + } + + @Override + public InputStream getUnicodeStream(int columnIndex) throws SQLException { + return rs.getUnicodeStream(columnIndex); + } + + @Override + public InputStream getBinaryStream(int columnIndex) throws SQLException { + return rs.getBinaryStream(columnIndex); + } + + @Override + public String getString(String columnLabel) throws SQLException { + return rs.getString(columnLabel); + } + + @Override + public boolean getBoolean(String columnLabel) throws SQLException { + return rs.getBoolean(columnLabel); + } + + @Override + public byte getByte(String columnLabel) throws SQLException { + return rs.getByte(columnLabel); + } + + @Override + public short getShort(String columnLabel) throws SQLException { + return rs.getShort(columnLabel); + } + + @Override + public int getInt(String columnLabel) throws SQLException { + return rs.getInt(columnLabel); + } + + @Override + public long getLong(String columnLabel) throws SQLException { + return rs.getLong(columnLabel); + } + + @Override + public float getFloat(String columnLabel) throws SQLException { + return rs.getFloat(columnLabel); + } + + @Override + public double getDouble(String columnLabel) throws SQLException { + return rs.getDouble(columnLabel); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException { + return rs.getBigDecimal(columnLabel, scale); + } + + @Override + public byte[] getBytes(String columnLabel) throws SQLException { + return rs.getBytes(columnLabel); + } + + @Override + public Date getDate(String columnLabel) throws SQLException { + return rs.getDate(columnLabel); + } + + @Override + public Time getTime(String columnLabel) throws SQLException { + return rs.getTime(columnLabel); + } + + @Override + public Timestamp getTimestamp(String columnLabel) throws SQLException { + return rs.getTimestamp(columnLabel); + } + + @Override + public InputStream getAsciiStream(String columnLabel) throws SQLException { + return rs.getAsciiStream(columnLabel); + } + + @Override + public InputStream getUnicodeStream(String columnLabel) throws SQLException { + return rs.getUnicodeStream(columnLabel); + } + + @Override + public InputStream getBinaryStream(String columnLabel) throws SQLException { + return rs.getBinaryStream(columnLabel); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return rs.getWarnings(); + } + + @Override + public void clearWarnings() throws SQLException { + rs.clearWarnings(); + } + + @Override + public String getCursorName() throws SQLException { + return rs.getCursorName(); + } + + @Override + public ResultSetMetaData getMetaData() throws SQLException { + return rs.getMetaData(); + } + + @Override + public Object getObject(int columnIndex) throws SQLException { + return rs.getObject(columnIndex); + } + + @Override + public Object getObject(String columnLabel) throws SQLException { + return rs.getObject(columnLabel); + } + + @Override + public int findColumn(String columnLabel) throws SQLException { + return rs.findColumn(columnLabel); + } + + @Override + public Reader getCharacterStream(int columnIndex) throws SQLException { + return rs.getCharacterStream(columnIndex); + } + + @Override + public Reader getCharacterStream(String columnLabel) throws SQLException { + return rs.getCharacterStream(columnLabel); + } + + @Override + public BigDecimal getBigDecimal(int columnIndex) throws SQLException { + return rs.getBigDecimal(columnIndex); + } + + @Override + public BigDecimal getBigDecimal(String columnLabel) throws SQLException { + return rs.getBigDecimal(columnLabel); + } + + @Override + public boolean isBeforeFirst() throws SQLException { + return rs.isBeforeFirst(); + } + + @Override + public boolean isAfterLast() throws SQLException { + return rs.isAfterLast(); + } + + @Override + public boolean isFirst() throws SQLException { + return rs.isFirst(); + } + + @Override + public boolean isLast() throws SQLException { + return rs.isLast(); + } + + @Override + public void beforeFirst() throws SQLException { + rs.beforeFirst(); + } + + @Override + public void afterLast() throws SQLException { + rs.afterLast(); + } + + @Override + public boolean first() throws SQLException { + return rs.first(); + } + + @Override + public boolean last() throws SQLException { + return rs.last(); + } + + @Override + public int getRow() throws SQLException { + return rs.getRow(); + } + + @Override + public boolean absolute(int row) throws SQLException { + return rs.absolute(row); + } + + @Override + public boolean relative(int rows) throws SQLException { + return rs.relative(rows); + } + + @Override + public boolean previous() throws SQLException { + return rs.previous(); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + rs.setFetchDirection(direction); + } + + @Override + public int getFetchDirection() throws SQLException { + return rs.getFetchDirection(); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + rs.setFetchSize(rows); + } + + @Override + public int getFetchSize() throws SQLException { + return rs.getFetchSize(); + } + + @Override + public int getType() throws SQLException { + return rs.getType(); + } + + @Override + public int getConcurrency() throws SQLException { + return rs.getConcurrency(); + } + + @Override + public boolean rowUpdated() throws SQLException { + return rs.rowUpdated(); + } + + @Override + public boolean rowInserted() throws SQLException { + return rs.rowInserted(); + } + + @Override + public boolean rowDeleted() throws SQLException { + return rs.rowDeleted(); + } + + @Override + public void updateNull(int columnIndex) throws SQLException { + rs.updateNull(columnIndex); + } + + @Override + public void updateBoolean(int columnIndex, boolean x) throws SQLException { + rs.updateBoolean(columnIndex, x); + } + + @Override + public void updateByte(int columnIndex, byte x) throws SQLException { + rs.updateByte(columnIndex, x); + } + + @Override + public void updateShort(int columnIndex, short x) throws SQLException { + rs.updateShort(columnIndex, x); + } + + @Override + public void updateInt(int columnIndex, int x) throws SQLException { + rs.updateInt(columnIndex, x); + } + + @Override + public void updateLong(int columnIndex, long x) throws SQLException { + rs.updateLong(columnIndex, x); + } + + @Override + public void updateFloat(int columnIndex, float x) throws SQLException { + rs.updateFloat(columnIndex, x); + } + + @Override + public void updateDouble(int columnIndex, double x) throws SQLException { + rs.updateDouble(columnIndex, x); + } + + @Override + public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException { + rs.updateBigDecimal(columnIndex, x); + } + + @Override + public void updateString(int columnIndex, String x) throws SQLException { + rs.updateString(columnIndex, x); + } + + @Override + public void updateBytes(int columnIndex, byte[] x) throws SQLException { + rs.updateBytes(columnIndex, x); + } + + @Override + public void updateDate(int columnIndex, Date x) throws SQLException { + rs.updateDate(columnIndex, x); + } + + @Override + public void updateTime(int columnIndex, Time x) throws SQLException { + rs.updateTime(columnIndex, x); + } + + @Override + public void updateTimestamp(int columnIndex, Timestamp x) throws SQLException { + rs.updateTimestamp(columnIndex, x); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException { + rs.updateAsciiStream(columnIndex, x, length); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, int length) throws SQLException { + rs.updateBinaryStream(columnIndex, x, length); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, int length) throws SQLException { + rs.updateCharacterStream(columnIndex, x, length); + } + + @Override + public void updateObject(int columnIndex, Object x, int scaleOrLength) throws SQLException { + rs.updateObject(columnIndex, x, scaleOrLength); + } + + @Override + public void updateObject(int columnIndex, Object x) throws SQLException { + rs.updateObject(columnIndex, x); + } + + @Override + public void updateNull(String columnLabel) throws SQLException { + rs.updateNull(columnLabel); + } + + @Override + public void updateBoolean(String columnLabel, boolean x) throws SQLException { + rs.updateBoolean(columnLabel, x); + } + + @Override + public void updateByte(String columnLabel, byte x) throws SQLException { + rs.updateByte(columnLabel, x); + } + + @Override + public void updateShort(String columnLabel, short x) throws SQLException { + rs.updateShort(columnLabel, x); + } + + @Override + public void updateInt(String columnLabel, int x) throws SQLException { + rs.updateInt(columnLabel, x); + } + + @Override + public void updateLong(String columnLabel, long x) throws SQLException { + rs.updateLong(columnLabel, x); + } + + @Override + public void updateFloat(String columnLabel, float x) throws SQLException { + rs.updateFloat(columnLabel, x); + } + + @Override + public void updateDouble(String columnLabel, double x) throws SQLException { + rs.updateDouble(columnLabel, x); + } + + @Override + public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException { + rs.updateBigDecimal(columnLabel, x); + } + + @Override + public void updateString(String columnLabel, String x) throws SQLException { + rs.updateString(columnLabel, x); + } + + @Override + public void updateBytes(String columnLabel, byte[] x) throws SQLException { + rs.updateBytes(columnLabel, x); + } + + @Override + public void updateDate(String columnLabel, Date x) throws SQLException { + rs.updateDate(columnLabel, x); + } + + @Override + public void updateTime(String columnLabel, Time x) throws SQLException { + rs.updateTime(columnLabel, x); + } + + @Override + public void updateTimestamp(String columnLabel, Timestamp x) throws SQLException { + rs.updateTimestamp(columnLabel, x); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, int length) + throws SQLException { + rs.updateAsciiStream(columnLabel, x, length); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, int length) + throws SQLException { + rs.updateBinaryStream(columnLabel, x, length); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, int length) + throws SQLException { + rs.updateCharacterStream(columnLabel, reader, length); + } + + @Override + public void updateObject(String columnLabel, Object x, int scaleOrLength) throws SQLException { + rs.updateObject(columnLabel, x, scaleOrLength); + } + + @Override + public void updateObject(String columnLabel, Object x) throws SQLException { + rs.updateObject(columnLabel, x); + } + + @Override + public void insertRow() throws SQLException { + rs.insertRow(); + } + + @Override + public void updateRow() throws SQLException { + rs.updateRow(); + } + + @Override + public void deleteRow() throws SQLException { + rs.deleteRow(); + } + + @Override + public void refreshRow() throws SQLException { + rs.refreshRow(); + } + + @Override + public void cancelRowUpdates() throws SQLException { + rs.cancelRowUpdates(); + } + + @Override + public void moveToInsertRow() throws SQLException { + rs.moveToInsertRow(); + } + + @Override + public void moveToCurrentRow() throws SQLException { + rs.moveToCurrentRow(); + } + + @Override + public Statement getStatement() throws SQLException { + return rs.getStatement(); + } + + @Override + public Object getObject(int columnIndex, Map> map) throws SQLException { + return rs.getObject(columnIndex, map); + } + + @Override + public Ref getRef(int columnIndex) throws SQLException { + return rs.getRef(columnIndex); + } + + @Override + public Blob getBlob(int columnIndex) throws SQLException { + return rs.getBlob(columnIndex); + } + + @Override + public Clob getClob(int columnIndex) throws SQLException { + return rs.getClob(columnIndex); + } + + @Override + public Array getArray(int columnIndex) throws SQLException { + return rs.getArray(columnIndex); + } + + @Override + public Object getObject(String columnLabel, Map> map) throws SQLException { + return rs.getObject(columnLabel, map); + } + + @Override + public Ref getRef(String columnLabel) throws SQLException { + return rs.getRef(columnLabel); + } + + @Override + public Blob getBlob(String columnLabel) throws SQLException { + return rs.getBlob(columnLabel); + } + + @Override + public Clob getClob(String columnLabel) throws SQLException { + return rs.getClob(columnLabel); + } + + @Override + public Array getArray(String columnLabel) throws SQLException { + return rs.getArray(columnLabel); + } + + @Override + public Date getDate(int columnIndex, Calendar cal) throws SQLException { + return rs.getDate(columnIndex, cal); + } + + @Override + public Date getDate(String columnLabel, Calendar cal) throws SQLException { + return rs.getDate(columnLabel, cal); + } + + @Override + public Time getTime(int columnIndex, Calendar cal) throws SQLException { + return rs.getTime(columnIndex, cal); + } + + @Override + public Time getTime(String columnLabel, Calendar cal) throws SQLException { + return rs.getTime(columnLabel, cal); + } + + @Override + public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException { + return rs.getTimestamp(columnIndex, cal); + } + + @Override + public Timestamp getTimestamp(String columnLabel, Calendar cal) throws SQLException { + return rs.getTimestamp(columnLabel, cal); + } + + @Override + public URL getURL(int columnIndex) throws SQLException { + return rs.getURL(columnIndex); + } + + @Override + public URL getURL(String columnLabel) throws SQLException { + return rs.getURL(columnLabel); + } + + @Override + public void updateRef(int columnIndex, Ref x) throws SQLException { + rs.updateRef(columnIndex, x); + } + + @Override + public void updateRef(String columnLabel, Ref x) throws SQLException { + rs.updateRef(columnLabel, x); + } + + @Override + public void updateBlob(int columnIndex, Blob x) throws SQLException { + rs.updateBlob(columnIndex, x); + } + + @Override + public void updateBlob(String columnLabel, Blob x) throws SQLException { + rs.updateBlob(columnLabel, x); + } + + @Override + public void updateClob(int columnIndex, Clob x) throws SQLException { + rs.updateClob(columnIndex, x); + } + + @Override + public void updateClob(String columnLabel, Clob x) throws SQLException { + rs.updateClob(columnLabel, x); + } + + @Override + public void updateArray(int columnIndex, Array x) throws SQLException { + rs.updateArray(columnIndex, x); + } + + @Override + public void updateArray(String columnLabel, Array x) throws SQLException { + rs.updateArray(columnLabel, x); + } + + @Override + public RowId getRowId(int columnIndex) throws SQLException { + return rs.getRowId(columnIndex); + } + + @Override + public RowId getRowId(String columnLabel) throws SQLException { + return rs.getRowId(columnLabel); + } + + @Override + public void updateRowId(int columnIndex, RowId x) throws SQLException { + rs.updateRowId(columnIndex, x); + } + + @Override + public void updateRowId(String columnLabel, RowId x) throws SQLException { + rs.updateRowId(columnLabel, x); + } + + @Override + public int getHoldability() throws SQLException { + return rs.getHoldability(); + } + + @Override + public boolean isClosed() throws SQLException { + return rs.isClosed(); + } + + @Override + public void updateNString(int columnIndex, String nString) throws SQLException { + rs.updateNString(columnIndex, nString); + } + + @Override + public void updateNString(String columnLabel, String nString) throws SQLException { + rs.updateNString(columnLabel, nString); + } + + @Override + public void updateNClob(int columnIndex, NClob nClob) throws SQLException { + rs.updateNClob(columnIndex, nClob); + } + + @Override + public void updateNClob(String columnLabel, NClob nClob) throws SQLException { + rs.updateNClob(columnLabel, nClob); + } + + @Override + public NClob getNClob(int columnIndex) throws SQLException { + return rs.getNClob(columnIndex); + } + + @Override + public NClob getNClob(String columnLabel) throws SQLException { + return rs.getNClob(columnLabel); + } + + @Override + public SQLXML getSQLXML(int columnIndex) throws SQLException { + return rs.getSQLXML(columnIndex); + } + + @Override + public SQLXML getSQLXML(String columnLabel) throws SQLException { + return rs.getSQLXML(columnLabel); + } + + @Override + public void updateSQLXML(int columnIndex, SQLXML xmlObject) throws SQLException { + rs.updateSQLXML(columnIndex, xmlObject); + } + + @Override + public void updateSQLXML(String columnLabel, SQLXML xmlObject) throws SQLException { + rs.updateSQLXML(columnLabel, xmlObject); + } + + @Override + public String getNString(int columnIndex) throws SQLException { + return rs.getNString(columnIndex); + } + + @Override + public String getNString(String columnLabel) throws SQLException { + return rs.getNString(columnLabel); + } + + @Override + public Reader getNCharacterStream(int columnIndex) throws SQLException { + return rs.getNCharacterStream(columnIndex); + } + + @Override + public Reader getNCharacterStream(String columnLabel) throws SQLException { + return rs.getNCharacterStream(columnLabel); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + rs.updateNCharacterStream(columnIndex, x, length); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader, long length) + throws SQLException { + rs.updateNCharacterStream(columnLabel, reader, length); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException { + rs.updateAsciiStream(columnIndex, x, length); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x, long length) + throws SQLException { + rs.updateBinaryStream(columnIndex, x, length); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x, long length) throws SQLException { + rs.updateCharacterStream(columnIndex, x, length); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x, long length) + throws SQLException { + rs.updateAsciiStream(columnLabel, x, length); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x, long length) + throws SQLException { + rs.updateBinaryStream(columnLabel, x, length); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader, long length) + throws SQLException { + rs.updateCharacterStream(columnLabel, reader, length); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream, long length) + throws SQLException { + rs.updateBlob(columnIndex, inputStream, length); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream, long length) + throws SQLException { + rs.updateBlob(columnLabel, inputStream, length); + } + + @Override + public void updateClob(int columnIndex, Reader reader, long length) throws SQLException { + rs.updateClob(columnIndex, reader, length); + } + + @Override + public void updateClob(String columnLabel, Reader reader, long length) throws SQLException { + rs.updateClob(columnLabel, reader, length); + } + + @Override + public void updateNClob(int columnIndex, Reader reader, long length) throws SQLException { + rs.updateNClob(columnIndex, reader, length); + } + + @Override + public void updateNClob(String columnLabel, Reader reader, long length) throws SQLException { + rs.updateNClob(columnLabel, reader, length); + } + + @Override + public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException { + rs.updateNCharacterStream(columnIndex, x); + } + + @Override + public void updateNCharacterStream(String columnLabel, Reader reader) throws SQLException { + rs.updateNCharacterStream(columnLabel, reader); + } + + @Override + public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException { + rs.updateAsciiStream(columnIndex, x); + } + + @Override + public void updateBinaryStream(int columnIndex, InputStream x) throws SQLException { + rs.updateBinaryStream(columnIndex, x); + } + + @Override + public void updateCharacterStream(int columnIndex, Reader x) throws SQLException { + rs.updateCharacterStream(columnIndex, x); + } + + @Override + public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException { + rs.updateAsciiStream(columnLabel, x); + } + + @Override + public void updateBinaryStream(String columnLabel, InputStream x) throws SQLException { + rs.updateBinaryStream(columnLabel, x); + } + + @Override + public void updateCharacterStream(String columnLabel, Reader reader) throws SQLException { + rs.updateCharacterStream(columnLabel, reader); + } + + @Override + public void updateBlob(int columnIndex, InputStream inputStream) throws SQLException { + rs.updateBlob(columnIndex, inputStream); + } + + @Override + public void updateBlob(String columnLabel, InputStream inputStream) throws SQLException { + rs.updateBlob(columnLabel, inputStream); + } + + @Override + public void updateClob(int columnIndex, Reader reader) throws SQLException { + rs.updateClob(columnIndex, reader); + } + + @Override + public void updateClob(String columnLabel, Reader reader) throws SQLException { + rs.updateClob(columnLabel, reader); + } + + @Override + public void updateNClob(int columnIndex, Reader reader) throws SQLException { + rs.updateNClob(columnIndex, reader); + } + + @Override + public void updateNClob(String columnLabel, Reader reader) throws SQLException { + rs.updateNClob(columnLabel, reader); + } + + @Override + public T getObject(int columnIndex, Class type) throws SQLException { + return rs.getObject(columnIndex, type); + } + + @Override + public T getObject(String columnLabel, Class type) throws SQLException { + return rs.getObject(columnLabel, type); + } + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateStatement.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateStatement.java new file mode 100644 index 0000000..dfe2ba2 --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/DelegateStatement.java @@ -0,0 +1,254 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; + +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.Statement; + +public class DelegateStatement implements Statement { + + protected Statement stmt; + + public DelegateStatement(Statement stmt) { + this.stmt = stmt; + } + + @Override + public T unwrap(Class iface) throws SQLException { + return stmt.unwrap(iface); + } + + @Override + public ResultSet executeQuery(String sql) throws SQLException { + return stmt.executeQuery(sql); + } + + @Override + public boolean isWrapperFor(Class iface) throws SQLException { + return stmt.isWrapperFor(iface); + } + + @Override + public int executeUpdate(String sql) throws SQLException { + return stmt.executeUpdate(sql); + } + + @Override + public void close() throws SQLException { + stmt.close(); + } + + @Override + public int getMaxFieldSize() throws SQLException { + return stmt.getMaxFieldSize(); + } + + @Override + public void setMaxFieldSize(int max) throws SQLException { + stmt.setMaxFieldSize(max); + } + + @Override + public int getMaxRows() throws SQLException { + return stmt.getMaxRows(); + } + + @Override + public void setMaxRows(int max) throws SQLException { + stmt.setMaxRows(max); + } + + @Override + public void setEscapeProcessing(boolean enable) throws SQLException { + stmt.setEscapeProcessing(enable); + } + + @Override + public int getQueryTimeout() throws SQLException { + return stmt.getQueryTimeout(); + } + + @Override + public void setQueryTimeout(int seconds) throws SQLException { + stmt.setQueryTimeout(seconds); + } + + @Override + public void cancel() throws SQLException { + stmt.cancel(); + } + + @Override + public SQLWarning getWarnings() throws SQLException { + return stmt.getWarnings(); + } + + @Override + public void clearWarnings() throws SQLException { + stmt.clearWarnings(); + } + + @Override + public void setCursorName(String name) throws SQLException { + stmt.setCursorName(name); + } + + @Override + public boolean execute(String sql) throws SQLException { + return stmt.execute(sql); + } + + @Override + public ResultSet getResultSet() throws SQLException { + return stmt.getResultSet(); + } + + @Override + public int getUpdateCount() throws SQLException { + return stmt.getUpdateCount(); + } + + @Override + public boolean getMoreResults() throws SQLException { + return stmt.getMoreResults(); + } + + @Override + public void setFetchDirection(int direction) throws SQLException { + stmt.setFetchDirection(direction); + } + + @Override + public int getFetchDirection() throws SQLException { + return stmt.getFetchDirection(); + } + + @Override + public void setFetchSize(int rows) throws SQLException { + stmt.setFetchSize(rows); + } + + @Override + public int getFetchSize() throws SQLException { + return stmt.getFetchSize(); + } + + @Override + public int getResultSetConcurrency() throws SQLException { + return stmt.getResultSetConcurrency(); + } + + @Override + public int getResultSetType() throws SQLException { + return stmt.getResultSetType(); + } + + @Override + public void addBatch(String sql) throws SQLException { + stmt.addBatch(sql); + } + + @Override + public void clearBatch() throws SQLException { + stmt.clearBatch(); + } + + @Override + public int[] executeBatch() throws SQLException { + return stmt.executeBatch(); + } + + @Override + public Connection getConnection() throws SQLException { + return stmt.getConnection(); + } + + @Override + public boolean getMoreResults(int current) throws SQLException { + return stmt.getMoreResults(current); + } + + @Override + public ResultSet getGeneratedKeys() throws SQLException { + return stmt.getGeneratedKeys(); + } + + @Override + public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException { + return stmt.executeUpdate(sql, autoGeneratedKeys); + } + + @Override + public int executeUpdate(String sql, int[] columnIndexes) throws SQLException { + return stmt.executeUpdate(sql, columnIndexes); + } + + @Override + public int executeUpdate(String sql, String[] columnNames) throws SQLException { + return stmt.executeUpdate(sql, columnNames); + } + + @Override + public boolean execute(String sql, int autoGeneratedKeys) throws SQLException { + return stmt.execute(sql, autoGeneratedKeys); + } + + @Override + public boolean execute(String sql, int[] columnIndexes) throws SQLException { + return stmt.execute(sql, columnIndexes); + } + + @Override + public boolean execute(String sql, String[] columnNames) throws SQLException { + return stmt.execute(sql, columnNames); + } + + @Override + public int getResultSetHoldability() throws SQLException { + return stmt.getResultSetHoldability(); + } + + @Override + public boolean isClosed() throws SQLException { + return stmt.isClosed(); + } + + @Override + public void setPoolable(boolean poolable) throws SQLException { + stmt.setPoolable(poolable); + } + + @Override + public boolean isPoolable() throws SQLException { + return stmt.isPoolable(); + } + + @Override + public void closeOnCompletion() throws SQLException { + stmt.closeOnCompletion(); + } + + @Override + public boolean isCloseOnCompletion() throws SQLException { + return stmt.isCloseOnCompletion(); + } + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixConnection.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixConnection.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixConnection.java new file mode 100644 index 0000000..e1b5dee --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixConnection.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.Statement; + +import org.apache.phoenix.util.PhoenixRuntime; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LoggingPhoenixConnection extends DelegateConnection { + + private static final Logger logger = LoggerFactory.getLogger(LoggingPhoenixResultSet.class); + private PhoenixMetricsLog phoenixMetricsLog; + + public LoggingPhoenixConnection(Connection conn, + PhoenixMetricsLog phoenixMetricsLog) { + super(conn); + this.phoenixMetricsLog = phoenixMetricsLog; + } + + @Override + public Statement createStatement() throws SQLException { + return new LoggingPhoenixStatement(super.createStatement(), phoenixMetricsLog); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency) + throws SQLException { + return new LoggingPhoenixStatement( + super.createStatement(resultSetType, resultSetConcurrency), phoenixMetricsLog); + } + + @Override + public Statement createStatement(int resultSetType, int resultSetConcurrency, + int resultSetHoldability) throws SQLException { + return new LoggingPhoenixStatement( + super.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability), + phoenixMetricsLog); + } + + @Override + public PreparedStatement prepareStatement(String sql) throws SQLException { + return new LoggingPhoenixPreparedStatement(super.prepareStatement(sql), + phoenixMetricsLog); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, + int resultSetConcurrency) throws SQLException { + return new LoggingPhoenixPreparedStatement( + super.prepareStatement(sql, resultSetType, resultSetConcurrency), + phoenixMetricsLog); + } + + @Override + public PreparedStatement prepareStatement(String sql, int resultSetType, + int resultSetConcurrency, int resultSetHoldability) throws SQLException { + return new LoggingPhoenixPreparedStatement(super.prepareStatement(sql, resultSetType, + resultSetConcurrency, resultSetHoldability), phoenixMetricsLog); + } + + @Override + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) + throws SQLException { + return new LoggingPhoenixPreparedStatement(super.prepareStatement(sql, autoGeneratedKeys), + phoenixMetricsLog); + } + + @Override + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { + return new LoggingPhoenixPreparedStatement(super.prepareStatement(sql, columnIndexes), + phoenixMetricsLog); + } + + @Override + public PreparedStatement prepareStatement(String sql, String[] columnNames) + throws SQLException { + return new LoggingPhoenixPreparedStatement(super.prepareStatement(sql, columnNames), + phoenixMetricsLog); + } + + @Override + public void commit() throws SQLException { + super.commit(); + phoenixMetricsLog.logWriteMetricsfoForMutations(logger, PhoenixRuntime.getWriteMetricInfoForMutationsSinceLastReset(conn)); + phoenixMetricsLog.logReadMetricInfoForMutationsSinceLastReset(logger, PhoenixRuntime.getReadMetricInfoForMutationsSinceLastReset(conn)); + PhoenixRuntime.resetMetrics(conn); + } + +} http://git-wip-us.apache.org/repos/asf/phoenix/blob/bd35b0e8/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixPreparedStatement.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixPreparedStatement.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixPreparedStatement.java new file mode 100644 index 0000000..cc8ec1f --- /dev/null +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixPreparedStatement.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.phoenix.jdbc; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; + +public class LoggingPhoenixPreparedStatement extends DelegatePreparedStatement { + + private PhoenixMetricsLog phoenixMetricsLog; + + public LoggingPhoenixPreparedStatement(PreparedStatement stmt, PhoenixMetricsLog phoenixMetricsLog) { + super(stmt); + this.phoenixMetricsLog = phoenixMetricsLog; + } + + @Override + public ResultSet executeQuery(String sql) throws SQLException { + return new LoggingPhoenixResultSet(super.executeQuery(sql), phoenixMetricsLog); + } + + @Override + public ResultSet executeQuery() throws SQLException { + return new LoggingPhoenixResultSet(super.executeQuery(), phoenixMetricsLog); + } + + @Override + public ResultSet getResultSet() throws SQLException { + return new LoggingPhoenixResultSet(super.getResultSet(), phoenixMetricsLog); + } + + @Override + public ResultSet getGeneratedKeys() throws SQLException { + return new LoggingPhoenixResultSet(super.getGeneratedKeys(), phoenixMetricsLog); + } + +}