You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by an...@apache.org on 2017/11/15 06:01:42 UTC
phoenix git commit: PHOENIX-4377 Port PHOENIX-3081 to HBase-2.0
Repository: phoenix
Updated Branches:
refs/heads/5.x-HBase-2.0 e1238aa3c -> c85e06581
PHOENIX-4377 Port PHOENIX-3081 to HBase-2.0
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/c85e0658
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/c85e0658
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/c85e0658
Branch: refs/heads/5.x-HBase-2.0
Commit: c85e06581643f97242131d03b604781546817e4b
Parents: e1238aa
Author: Ankit Singhal <an...@gmail.com>
Authored: Wed Nov 15 11:31:31 2017 +0530
Committer: Ankit Singhal <an...@gmail.com>
Committed: Wed Nov 15 11:31:31 2017 +0530
----------------------------------------------------------------------
.../phoenix/schema/stats/StatisticsScanner.java | 26 +++++++++++---------
1 file changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/c85e0658/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsScanner.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsScanner.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsScanner.java
index 2fb6f14..3f5809b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsScanner.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/stats/StatisticsScanner.java
@@ -29,13 +29,13 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.Mutation;
+import org.apache.hadoop.hbase.client.RegionInfo;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.apache.hadoop.hbase.regionserver.Region;
-import org.apache.hadoop.hbase.regionserver.RegionServerServices;
import org.apache.hadoop.hbase.regionserver.ScannerContext;
import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
@@ -50,15 +50,15 @@ public class StatisticsScanner implements InternalScanner {
private StatisticsCollector tracker;
private ImmutableBytesPtr family;
private final Configuration config;
- private final RegionServerServices regionServerServices;
+ private final RegionCoprocessorEnvironment env;
public StatisticsScanner(StatisticsCollector tracker, StatisticsWriter stats, RegionCoprocessorEnvironment env,
InternalScanner delegate, ImmutableBytesPtr family) {
this.tracker = tracker;
this.statsWriter = stats;
this.delegate = delegate;
- this.regionServerServices = env.getRegionServerServices();
this.region = env.getRegion();
+ this.env = env;
this.family = family;
this.config = env.getConfiguration();
StatisticsCollectionRunTracker.getInstance(config).addCompactingRegion(region.getRegionInfo());
@@ -94,7 +94,7 @@ public class StatisticsScanner implements InternalScanner {
boolean async = getConfig().getBoolean(COMMIT_STATS_ASYNC, DEFAULT_COMMIT_STATS_ASYNC);
StatisticsCollectionRunTracker collectionTracker = getStatsCollectionRunTracker(config);
StatisticsScannerCallable callable = createCallable();
- if (getRegionServerServices().isStopping() || getRegionServerServices().isStopped()) {
+ if (isConnectionClosed()) {
LOG.debug("Not updating table statistics because the server is stopping/stopped");
return;
}
@@ -118,13 +118,13 @@ public class StatisticsScanner implements InternalScanner {
return statsWriter;
}
- RegionServerServices getRegionServerServices() {
- return regionServerServices;
- }
-
Region getRegion() {
return region;
}
+
+ Connection getConnection() {
+ return env.getConnection();
+ }
StatisticsScannerCallable createCallable() {
return new StatisticsScannerCallable();
@@ -143,7 +143,7 @@ public class StatisticsScanner implements InternalScanner {
public Void call() throws IOException {
IOException toThrow = null;
StatisticsCollectionRunTracker collectionTracker = getStatsCollectionRunTracker(config);
- final HRegionInfo regionInfo = getRegion().getRegionInfo();
+ final RegionInfo regionInfo = getRegion().getRegionInfo();
try {
// update the statistics table
// Just verify if this if fine
@@ -165,7 +165,7 @@ public class StatisticsScanner implements InternalScanner {
}
getStatisticsWriter().commitStats(mutations, tracker);
} catch (IOException e) {
- if (getRegionServerServices().isStopping() || getRegionServerServices().isStopped()) {
+ if (isConnectionClosed()) {
LOG.debug("Ignoring error updating statistics because region is closing/closed");
} else {
LOG.error("Failed to update statistics table!", e);
@@ -195,4 +195,8 @@ public class StatisticsScanner implements InternalScanner {
}
}
+ private boolean isConnectionClosed() {
+ return getConnection() == null || getConnection().isClosed() || getConnection().isAborted();
+ }
+
}