Index: src/main/java/org/apache/hadoop/hbase/client/ConnectionClosedException.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/ConnectionClosedException.java (revision 0) +++ src/main/java/org/apache/hadoop/hbase/client/ConnectionClosedException.java (revision 0) @@ -0,0 +1,36 @@ +/** + * 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 java.io.IOException; + +/** + * Thrown when HConnection has been closed. + */ +public class ConnectionClosedException extends IOException { + private static final long serialVersionUID = 8792360655678089586L; + + public ConnectionClosedException() { + super(); + } + + public ConnectionClosedException(String s) { + super(s); + } +} Property changes on: src\main\java\org\apache\hadoop\hbase\client\ConnectionClosedException.java ___________________________________________________________________ Added: svn:needs-lock + * Index: src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (revision 1229032) +++ src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java (working copy) @@ -29,8 +29,8 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.NoSuchElementException; -import java.util.Map.Entry; import java.util.Set; import java.util.SortedMap; import java.util.TreeSet; @@ -787,7 +787,8 @@ private HRegionLocation locateRegion(final byte [] tableName, final byte [] row, boolean useCache) throws IOException { - if (this.closed) throw new IOException(toString() + " closed"); + if (this.closed) + throw new ConnectionClosedException(toString() + " closed"); if (tableName == null || tableName.length == 0) { throw new IllegalArgumentException( "table name cannot be null or zero length"); Index: src/main/java/org/apache/hadoop/hbase/client/HTable.java =================================================================== --- src/main/java/org/apache/hadoop/hbase/client/HTable.java (revision 1229032) +++ src/main/java/org/apache/hadoop/hbase/client/HTable.java (working copy) @@ -50,7 +50,6 @@ import org.apache.hadoop.hbase.KeyValue; import org.apache.hadoop.hbase.NotServingRegionException; import org.apache.hadoop.hbase.UnknownScannerException; -import org.apache.hadoop.hbase.ZooKeeperConnectionException; import org.apache.hadoop.hbase.client.HConnectionManager.HConnectable; import org.apache.hadoop.hbase.client.MetaScanner.MetaScannerVisitor; import org.apache.hadoop.hbase.util.Bytes; @@ -857,6 +856,12 @@ public void flushCommits() throws IOException { try { connection.processBatchOfPuts(writeBuffer, tableName, pool); + } catch (IOException ioe) { + if (ioe instanceof ConnectionClosedException) { + this.connection = HConnectionManager.getConnection(this + .getConfiguration()); + } + throw ioe; } finally { if (clearBufferOnFail) { writeBuffer.clear();