HBASE-81 When a scanner lease times out, throw a more "user friendly" exception
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@709852 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5418547132
commit
7a5768ca85
|
@ -92,6 +92,7 @@ Release 0.19.0 - Unreleased
|
|||
0.19.0 RC
|
||||
HBASE-785 Remove InfoServer, use HADOOP-3824 StatusHttpServer
|
||||
instead (requires hadoop 0.19)
|
||||
HBASE-81 When a scanner lease times out, throw a more "user friendly" exception
|
||||
|
||||
NEW FEATURES
|
||||
HBASE-875 Use MurmurHash instead of JenkinsHash [in bloomfilters]
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.HRegionLocation;
|
|||
import org.apache.hadoop.hbase.HServerAddress;
|
||||
import org.apache.hadoop.hbase.HStoreKey;
|
||||
import org.apache.hadoop.hbase.HTableDescriptor;
|
||||
import org.apache.hadoop.hbase.UnknownScannerException;
|
||||
import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor;
|
||||
import org.apache.hadoop.hbase.filter.RowFilterInterface;
|
||||
import org.apache.hadoop.hbase.filter.StopRowFilter;
|
||||
|
@ -53,12 +54,13 @@ import org.apache.hadoop.hbase.util.Writables;
|
|||
public class HTable {
|
||||
private final HConnection connection;
|
||||
private final byte [] tableName;
|
||||
private HBaseConfiguration configuration;
|
||||
protected final int scannerTimeout;
|
||||
private volatile HBaseConfiguration configuration;
|
||||
private ArrayList<BatchUpdate> writeBuffer;
|
||||
private long writeBufferSize;
|
||||
private boolean autoFlush;
|
||||
private long currentWriteBufferSize;
|
||||
private int scannerCaching;
|
||||
protected int scannerCaching;
|
||||
|
||||
/**
|
||||
* Creates an object to access a HBase table
|
||||
|
@ -104,8 +106,10 @@ public class HTable {
|
|||
public HTable(HBaseConfiguration conf, final byte [] tableName)
|
||||
throws IOException {
|
||||
this.connection = HConnectionManager.getConnection(conf);
|
||||
this.configuration = conf;
|
||||
this.tableName = tableName;
|
||||
this.scannerTimeout =
|
||||
conf.getInt("hbase.regionserver.lease.period", 60 * 1000);
|
||||
this.configuration = conf;
|
||||
this.connection.locateRegion(tableName, HConstants.EMPTY_START_ROW);
|
||||
this.writeBuffer = new ArrayList<BatchUpdate>();
|
||||
this.writeBufferSize =
|
||||
|
@ -1038,6 +1042,7 @@ public class HTable {
|
|||
/**
|
||||
* Release held resources
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void close() throws IOException{
|
||||
flushCommits();
|
||||
|
@ -1154,8 +1159,10 @@ public class HTable {
|
|||
private HRegionInfo currentRegion = null;
|
||||
private ScannerCallable callable = null;
|
||||
protected RowFilterInterface filter;
|
||||
final private LinkedList<RowResult> cache = new LinkedList<RowResult>();
|
||||
final private int scannerCaching = HTable.this.scannerCaching;
|
||||
private final LinkedList<RowResult> cache = new LinkedList<RowResult>();
|
||||
@SuppressWarnings("hiding")
|
||||
private final int scannerCaching = HTable.this.scannerCaching;
|
||||
private long lastNext;
|
||||
|
||||
protected ClientScanner(final byte[][] columns, final byte [] startRow,
|
||||
final long timestamp, final RowFilterInterface filter) {
|
||||
|
@ -1175,6 +1182,7 @@ public class HTable {
|
|||
if (filter != null) {
|
||||
filter.validate(columns);
|
||||
}
|
||||
this.lastNext = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
//TODO: change visibility to protected
|
||||
|
@ -1280,7 +1288,19 @@ public class HTable {
|
|||
// with a countdown in nextScanner
|
||||
callable.setCaching(this.scannerCaching);
|
||||
do {
|
||||
try {
|
||||
values = getConnection().getRegionServerWithRetries(callable);
|
||||
} catch (IOException e) {
|
||||
if (e instanceof UnknownScannerException &&
|
||||
lastNext + scannerTimeout < System.currentTimeMillis()) {
|
||||
|
||||
ScannerTimeoutException ex = new ScannerTimeoutException();
|
||||
ex.initCause(e);
|
||||
throw ex;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
lastNext = System.currentTimeMillis();
|
||||
if (values != null && values.length > 0) {
|
||||
for (RowResult rs : values) {
|
||||
cache.add(rs);
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* Copyright 2008 The Apache Software Foundation
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.hadoop.hbase.client;
|
||||
|
||||
import org.apache.hadoop.hbase.DoNotRetryIOException;
|
||||
|
||||
/**
|
||||
* Thrown when a scanner has timed out.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class ScannerTimeoutException extends DoNotRetryIOException {
|
||||
/** default constructor */
|
||||
ScannerTimeoutException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/** @param s */
|
||||
ScannerTimeoutException(String s) {
|
||||
super(s);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue