phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tdsi...@apache.org
Subject [1/2] phoenix git commit: PHOENIX-4022 Add PhoenixMetricsLog interface that can be used to log metrics for queries and mutations
Date Mon, 31 Jul 2017 19:54:03 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.2 82fe4e793 -> 15f623b4e


http://git-wip-us.apache.org/repos/asf/phoenix/blob/15f623b4/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixResultSet.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixResultSet.java
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixResultSet.java
new file mode 100644
index 0000000..cc3b567
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixResultSet.java
@@ -0,0 +1,45 @@
+/*
+ * 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.ResultSet;
+import java.sql.SQLException;
+
+import org.apache.phoenix.util.PhoenixRuntime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LoggingPhoenixResultSet extends DelegateResultSet {
+    
+    private static final Logger logger = LoggerFactory.getLogger(LoggingPhoenixResultSet.class);
+    private PhoenixMetricsLog phoenixMetricsLog;
+    
+    public LoggingPhoenixResultSet(ResultSet rs, PhoenixMetricsLog phoenixMetricsLog) {
+        super(rs);
+        this.phoenixMetricsLog = phoenixMetricsLog;
+    }
+    
+    @Override
+    public void close() throws SQLException {
+        phoenixMetricsLog.logOverAllReadRequestMetrics(logger, PhoenixRuntime.getOverAllReadRequestMetricInfo(rs));
+        phoenixMetricsLog.logRequestReadMetrics(logger, PhoenixRuntime.getRequestReadMetricInfo(rs));
+        PhoenixRuntime.resetMetrics(rs);
+        super.close();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/15f623b4/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixStatement.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixStatement.java
b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixStatement.java
new file mode 100644
index 0000000..ea919ed
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/LoggingPhoenixStatement.java
@@ -0,0 +1,48 @@
+/*
+ * 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.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class LoggingPhoenixStatement extends DelegateStatement {
+
+    private PhoenixMetricsLog phoenixMetricsLog;
+    
+    public LoggingPhoenixStatement(Statement 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 getResultSet() throws SQLException {
+        return new LoggingPhoenixResultSet(super.getResultSet(), phoenixMetricsLog);
+    }
+    
+    @Override
+    public ResultSet getGeneratedKeys() throws SQLException {
+        return new LoggingPhoenixResultSet(super.getGeneratedKeys(), phoenixMetricsLog);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/15f623b4/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixMetricsLog.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixMetricsLog.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixMetricsLog.java
new file mode 100644
index 0000000..eac9bb8
--- /dev/null
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixMetricsLog.java
@@ -0,0 +1,35 @@
+/*
+ * 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.util.Map;
+
+import org.apache.phoenix.monitoring.MetricType;
+import org.slf4j.Logger;
+
+public interface PhoenixMetricsLog {
+
+    void logOverAllReadRequestMetrics(Logger logger, Map<MetricType, Long> overAllQueryMetrics);
+
+    void logRequestReadMetrics(Logger logger, Map<String, Map<MetricType, Long>>
requestReadMetrics);
+    
+    void logWriteMetricsfoForMutations(Logger logger,  Map<String, Map<MetricType,
Long>> mutationWriteMetrics);
+    
+    void logReadMetricInfoForMutationsSinceLastReset(Logger logger, Map<String, Map<MetricType,
Long>> mutationReadMetrics);
+
+}


Mime
View raw message