diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
index e231967..923cb57 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnection.java
@@ -333,12 +333,10 @@ public interface HConnection extends Abortable, Closeable {
public boolean getRegionCachePrefetch(final byte[] tableName);
/**
- * Scan zookeeper to get the number of region servers
* @return the number of region servers that are currently running
* @throws IOException if a remote or network exception occurs
* @deprecated This method will be changed from public to package protected.
*/
- @Deprecated
public int getCurrentNrHRS() throws IOException;
/**
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
index d08ab95..7069ffc 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HConnectionManager.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.hbase.client;
import java.io.Closeable;
import java.io.IOException;
+import java.lang.reflect.Constructor;
import java.lang.reflect.UndeclaredThrowableException;
import java.net.SocketException;
import java.util.ArrayList;
@@ -144,9 +145,6 @@ import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.hbase.util.SoftValueSortedMap;
import org.apache.hadoop.hbase.util.Triple;
import org.apache.hadoop.hbase.zookeeper.MasterAddressTracker;
-import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
-import org.apache.hadoop.hbase.zookeeper.ZKClusterId;
-import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
import org.apache.hadoop.hbase.zookeeper.ZKUtil;
import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
import org.apache.hadoop.ipc.RemoteException;
@@ -251,17 +249,18 @@ public class HConnectionManager {
* @return HConnection object for conf
* @throws ZooKeeperConnectionException
*/
+ @SuppressWarnings("resource")
public static HConnection getConnection(final Configuration conf)
throws IOException {
HConnectionKey connectionKey = new HConnectionKey(conf);
synchronized (CONNECTION_INSTANCES) {
HConnectionImplementation connection = CONNECTION_INSTANCES.get(connectionKey);
if (connection == null) {
- connection = new HConnectionImplementation(conf, true);
+ connection = (HConnectionImplementation)createConnection(conf, true);
CONNECTION_INSTANCES.put(connectionKey, connection);
} else if (connection.isClosed()) {
HConnectionManager.deleteConnection(connectionKey, true);
- connection = new HConnectionImplementation(conf, true);
+ connection = (HConnectionImplementation)createConnection(conf, true);
CONNECTION_INSTANCES.put(connectionKey, connection);
}
connection.incCount();
@@ -280,7 +279,28 @@ public class HConnectionManager {
*/
public static HConnection createConnection(Configuration conf)
throws IOException {
- return new HConnectionImplementation(conf, false);
+ return createConnection(conf, false);
+ }
+
+ static HConnection createConnection(final Configuration conf, final boolean managed)
+ throws IOException {
+ String className = conf.get("hbase.client.connection.impl",
+ HConnectionManager.HConnectionImplementation.class.getName());
+ Class> clazz = null;
+ try {
+ clazz = Class.forName(className);
+ } catch (ClassNotFoundException e) {
+ throw new IOException(e);
+ }
+ try {
+ // Default HCM#HCI is not accessible; make it so before invoking.
+ Constructor> constructor =
+ clazz.getDeclaredConstructor(Configuration.class, boolean.class);
+ constructor.setAccessible(true);
+ return (HConnection) constructor.newInstance(conf, managed);
+ } catch (Exception e) {
+ throw new IOException(e);
+ }
}
/**
@@ -418,7 +438,7 @@ public class HConnectionManager {
static final Log LOG = LogFactory.getLog(HConnectionImplementation.class);
private final long pause;
private final int numTries;
- private final int rpcTimeout;
+ final int rpcTimeout;
private final int prefetchRegionLimit;
private final boolean useServerTrackerForRetries;
private final long serverTrackerTimeout;
@@ -473,6 +493,11 @@ public class HConnectionManager {
private final boolean managed;
/**
+ * Cluster registry of basic info such as clusterid and meta region location.
+ */
+ final Registry registry;
+
+ /**
* constructor
* @param conf Configuration object
* @param managed If true, does not do full shutdown on close; i.e. cleanup of connection
@@ -512,6 +537,7 @@ public class HConnectionManager {
}
}
this.serverTrackerTimeout = serverTrackerTimeout;
+ this.registry = setupRegistry();
retrieveClusterId();
this.rpcClient = new RpcClient(this.conf, this.clusterId);
@@ -534,6 +560,20 @@ public class HConnectionManager {
}, conf, listenerClass);
}
}
+
+ /**
+ * @return The cluster registry implementation to use.
+ * @throws IOException
+ */
+ private Registry setupRegistry() throws IOException {
+ String registryClass = this.conf.get("hbase.client.registry.impl",
+ ZooKeeperRegistry.class.getName());
+ try {
+ return (Registry)Class.forName(registryClass).newInstance();
+ } catch (Throwable t) {
+ throw new IOException(t);
+ }
+ }
/**
* For tests only.
@@ -554,31 +594,11 @@ public class HConnectionManager {
return "hconnection-0x" + Integer.toHexString(hashCode());
}
- private String clusterId = null;
+ protected String clusterId = null;
- public final void retrieveClusterId(){
- if (clusterId != null) {
- return;
- }
-
- // No synchronized here, worse case we will retrieve it twice, that's
- // not an issue.
- ZooKeeperKeepAliveConnection zkw = null;
- try {
- zkw = getKeepAliveZooKeeperWatcher();
- clusterId = ZKClusterId.readClusterIdZNode(zkw);
- if (clusterId == null) {
- LOG.info("ClusterId read in ZooKeeper is null");
- }
- } catch (KeeperException e) {
- LOG.warn("Can't retrieve clusterId from Zookeeper", e);
- } catch (IOException e) {
- LOG.warn("Can't retrieve clusterId from Zookeeper", e);
- } finally {
- if (zkw != null) {
- zkw.close();
- }
- }
+ void retrieveClusterId() {
+ if (clusterId != null) return;
+ this.clusterId = this.registry.getClusterId();
if (clusterId == null) {
clusterId = HConstants.CLUSTER_ID_DEFAULT;
}
@@ -639,12 +659,12 @@ public class HConnectionManager {
@Override
public boolean isTableEnabled(byte[] tableName) throws IOException {
- return testTableOnlineState(tableName, true);
+ return this.registry.isTableOnlineState(tableName, true);
}
@Override
public boolean isTableDisabled(byte[] tableName) throws IOException {
- return testTableOnlineState(tableName, false);
+ return this.registry.isTableOnlineState(tableName, false);
}
@Override
@@ -716,26 +736,6 @@ public class HConnectionManager {
return available.get() && (regionCount.get() == splitKeys.length + 1);
}
- /*
- * @param enabled True if table is enabled
- */
- private boolean testTableOnlineState(byte [] tableName, boolean enabled)
- throws IOException {
- String tableNameStr = Bytes.toString(tableName);
- ZooKeeperKeepAliveConnection zkw = getKeepAliveZooKeeperWatcher();
- try {
- if (enabled) {
- return ZKTableReadOnly.isEnabledTable(zkw, tableNameStr);
- }
- return ZKTableReadOnly.isDisabledTable(zkw, tableNameStr);
- } catch (KeeperException e) {
- throw new IOException("Enable/Disable failed", e);
- }finally {
- zkw.close();
- }
- }
-
-
@Override
public HRegionLocation locateRegion(final byte[] regionName) throws IOException {
return locateRegion(HRegionInfo.getTableName(regionName),
@@ -801,26 +801,7 @@ public class HConnectionManager {
}
if (Bytes.equals(tableName, HConstants.META_TABLE_NAME)) {
- ZooKeeperKeepAliveConnection zkw = getKeepAliveZooKeeperWatcher();
- try {
- if (LOG.isTraceEnabled()) {
- LOG.trace("Looking up meta region location in ZK," + " connection=" + this);
- }
- ServerName servername =
- MetaRegionTracker.blockUntilAvailable(zkw, this.rpcTimeout);
-
- if (LOG.isTraceEnabled()) {
- LOG.debug("Looked up meta region location, connection=" + this +
- "; serverName=" + ((servername == null) ? "null" : servername));
- }
- if (servername == null) return null;
- return new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, servername, 0);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- return null;
- } finally {
- zkw.close();
- }
+ return this.registry.getMetaRegionLocation();
} else {
// Region not in the cache - have to go to the meta RS
return locateRegionInMeta(HConstants.META_TABLE_NAME, tableName, row,
@@ -1532,7 +1513,7 @@ public class HConnectionManager {
stub = (ClientService.BlockingInterface)this.stubs.get(key);
if (stub == null) {
BlockingRpcChannel channel = this.rpcClient.createBlockingRpcChannel(sn,
- User.getCurrent(), this.rpcTimeout);
+ User.getCurrent(), this.rpcTimeout);
stub = ClientService.newBlockingStub(channel);
// In old days, after getting stub/proxy, we'd make a call. We are not doing that here.
// Just fail on first actual call rather than in here on setup.
@@ -1557,7 +1538,7 @@ public class HConnectionManager {
* Retrieve a shared ZooKeeperWatcher. You must close it it once you've have finished with it.
* @return The shared instance. Never returns null.
*/
- public ZooKeeperKeepAliveConnection getKeepAliveZooKeeperWatcher()
+ ZooKeeperKeepAliveConnection getKeepAliveZooKeeperWatcher()
throws IOException {
synchronized (masterAndZKLock) {
if (keepAliveZookeeper == null) {
@@ -1566,8 +1547,7 @@ public class HConnectionManager {
}
// We don't check that our link to ZooKeeper is still valid
// But there is a retry mechanism in the ZooKeeperWatcher itself
- keepAliveZookeeper = new ZooKeeperKeepAliveConnection(
- conf, this.toString(), this);
+ keepAliveZookeeper = new ZooKeeperKeepAliveConnection(conf, this.toString(), this);
}
keepAliveZookeeperUserCount++;
keepZooKeeperWatcherAliveUntil = Long.MAX_VALUE;
@@ -1575,20 +1555,18 @@ public class HConnectionManager {
}
}
- void releaseZooKeeperWatcher(ZooKeeperWatcher zkw) {
+ void releaseZooKeeperWatcher(final ZooKeeperWatcher zkw) {
if (zkw == null){
return;
}
synchronized (masterAndZKLock) {
--keepAliveZookeeperUserCount;
- if (keepAliveZookeeperUserCount <=0 ){
- keepZooKeeperWatcherAliveUntil =
- System.currentTimeMillis() + keepAlive;
+ if (keepAliveZookeeperUserCount <= 0 ){
+ keepZooKeeperWatcherAliveUntil = System.currentTimeMillis() + keepAlive;
}
}
}
-
/**
* Creates a Chore thread to check the connections to master & zookeeper
* and close them when they reach their closing time (
@@ -2581,17 +2559,7 @@ public class HConnectionManager {
@Override
public int getCurrentNrHRS() throws IOException {
- ZooKeeperKeepAliveConnection zkw = getKeepAliveZooKeeperWatcher();
-
- try {
- // We go to zk rather than to master to get count of regions to avoid
- // HTable having a Master dependency. See HBase-2828
- return ZKUtil.getNumberOfChildren(zkw, zkw.rsZNode);
- } catch (KeeperException ke) {
- throw new IOException("Unexpected ZooKeeper exception", ke);
- } finally {
- zkw.close();
- }
+ return this.registry.getCurrentNrHRS();
}
/**
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
index bc1a686..f50911e 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/HTable.java
@@ -243,7 +243,8 @@ public class HTable implements HTableInterface {
*/
private void finishSetup() throws IOException {
this.connection.locateRegion(tableName, HConstants.EMPTY_START_ROW);
- this.operationTimeout = HTableDescriptor.isMetaTable(tableName) ? HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT
+ this.operationTimeout =
+ HTableDescriptor.isMetaTable(tableName) ? HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT
: this.configuration.getInt(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT,
HConstants.DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT);
this.writeBufferSize = this.configuration.getLong(
@@ -547,8 +548,7 @@ public class HTable implements HTableInterface {
if (scan.getCaching() <= 0) {
scan.setCaching(getScannerCaching());
}
- return new ClientScanner(getConfiguration(), scan, getTableName(),
- this.connection);
+ return new ClientScanner(getConfiguration(), scan, getTableName(), this.connection);
}
/**
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java
index 578959d..63a39f9 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/MetaScanner.java
@@ -134,7 +134,7 @@ public class MetaScanner {
}
});
} finally {
- visitor.close();
+ if (visitor != null) visitor.close();
}
}
@@ -217,8 +217,9 @@ public class MetaScanner {
if (processedRows >= rowUpperLimit) {
break done;
}
- if (!visitor.processRow(rr))
- break done; //exit completely
+ if (visitor != null) {
+ if (!visitor.processRow(rr)) break done; //exit completely
+ }
processedRows++;
}
//here, we didn't break anywhere. Check if we have more rows
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Registry.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Registry.java
new file mode 100644
index 0000000..338788d
--- /dev/null
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Registry.java
@@ -0,0 +1,39 @@
+package org.apache.hadoop.hbase.client;
+
+import java.io.IOException;
+
+import org.apache.hadoop.hbase.HRegionLocation;
+
+/**
+ * Cluster registry.
+ * Implemenations hold cluster information such as this cluster's id, location of .META., etc.
+ */
+interface Registry {
+ /**
+ * @param connection
+ */
+ void init(HConnection connection);
+
+ /**
+ * @return Meta region location
+ * @throws IOException
+ */
+ HRegionLocation getMetaRegionLocation() throws IOException;
+
+ /**
+ * @return Cluster id.
+ */
+ String getClusterId();
+
+ /**
+ * @param enabled Return true if table is enabled
+ * @throws IOException
+ */
+ boolean isTableOnlineState(byte [] tableName, boolean enabled) throws IOException;
+
+ /**
+ * @return Count of 'running' regionservers
+ * @throws IOException
+ */
+ int getCurrentNrHRS() throws IOException;
+}
\ No newline at end of file
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
index 1b2e54a..973cfe7 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ServerCallable.java
@@ -169,8 +169,7 @@ public abstract class ServerCallable implements Callable {
prepare(tries != 0); // if called with false, check table status on ZK
return call();
} catch (Throwable t) {
- LOG.warn("Received exception, tries=" + tries + ", numRetries=" + numRetries + ":" +
- t.getMessage());
+ LOG.warn("Received exception, tries=" + tries + ", numRetries=" + numRetries + ":" + t);
t = translateException(t);
// translateException throws an exception when we should not retry, i.e. when it's the
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZooKeeperRegistry.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZooKeeperRegistry.java
new file mode 100644
index 0000000..2e2ef74
--- /dev/null
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/ZooKeeperRegistry.java
@@ -0,0 +1,107 @@
+/**
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.hadoop.hbase.zookeeper.MetaRegionTracker;
+import org.apache.hadoop.hbase.zookeeper.ZKTableReadOnly;
+import org.apache.hadoop.hbase.zookeeper.ZKUtil;
+import org.apache.zookeeper.KeeperException;
+
+/**
+ * A cluster registry that stores to zookeeper.
+ */
+class ZooKeeperRegistry implements Registry {
+ static final Log LOG = LogFactory.getLog(ZooKeeperRegistry.class);
+ // Needs an instance of hci to function. Set after construct this instance.
+ HConnectionManager.HConnectionImplementation hci;
+
+ @Override
+ public void init(HConnection connection) {
+ if (!(connection instanceof HConnectionManager.HConnectionImplementation)) {
+ throw new RuntimeException("This registry depends on HConnectionImplementation");
+ }
+ }
+
+ @Override
+ public HRegionLocation getMetaRegionLocation() throws IOException {
+ ZooKeeperKeepAliveConnection zkw = hci.getKeepAliveZooKeeperWatcher();
+
+ try {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Looking up meta region location in ZK," + " connection=" + this);
+ }
+ ServerName servername = MetaRegionTracker.blockUntilAvailable(zkw, hci.rpcTimeout);
+ if (LOG.isTraceEnabled()) {
+ LOG.debug("Looked up meta region location, connection=" + this +
+ "; serverName=" + ((servername == null) ? "null" : servername));
+ }
+ if (servername == null) return null;
+ return new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, servername, 0);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ return null;
+ } finally {
+ zkw.close();
+ }
+ }
+
+ @Override
+ public String getClusterId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean isTableOnlineState(byte [] tableName, boolean enabled)
+ throws IOException {
+ String tableNameStr = Bytes.toString(tableName);
+ ZooKeeperKeepAliveConnection zkw = hci.getKeepAliveZooKeeperWatcher();
+ try {
+ if (enabled) {
+ return ZKTableReadOnly.isEnabledTable(zkw, tableNameStr);
+ }
+ return ZKTableReadOnly.isDisabledTable(zkw, tableNameStr);
+ } catch (KeeperException e) {
+ throw new IOException("Enable/Disable failed", e);
+ } finally {
+ zkw.close();
+ }
+ }
+
+ @Override
+ public int getCurrentNrHRS() throws IOException {
+ ZooKeeperKeepAliveConnection zkw = hci.getKeepAliveZooKeeperWatcher();
+ try {
+ // We go to zk rather than to master to get count of regions to avoid
+ // HTable having a Master dependency. See HBase-2828
+ return ZKUtil.getNumberOfChildren(zkw, zkw.rsZNode);
+ } catch (KeeperException ke) {
+ throw new IOException("Unexpected ZooKeeper exception", ke);
+ } finally {
+ zkw.close();
+ }
+ }
+}
\ No newline at end of file
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
new file mode 100644
index 0000000..6c86774
--- /dev/null
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/client/TestClientNoCluster.java
@@ -0,0 +1,142 @@
+/**
+ * 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;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.HBaseConfiguration;
+import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HRegionLocation;
+import org.apache.hadoop.hbase.ServerName;
+import org.apache.hadoop.hbase.exceptions.RegionServerStoppedException;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService;
+import org.apache.hadoop.hbase.protobuf.generated.ClientProtos.ClientService.BlockingInterface;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import com.google.protobuf.RpcController;
+import com.google.protobuf.ServiceException;
+
+/**
+ * Test client behavior.
+ * Mock up cluster emissions.
+ */
+public class TestClientNoCluster {
+ private static final Log LOG = LogFactory.getLog(TestClientNoCluster.class);
+ private final Configuration conf = HBaseConfiguration.create();
+
+ @Before
+ public void setUp() throws Exception {
+ // Run my HConnection overrides. Use my little HConnectionImplementation below which
+ // allows me insert mocks and also use my Registry below rather than the default zk based
+ // one so tests run faster and don't have zk dependency.
+ this.conf.set("hbase.client.connection.impl", NoClusterConnection.class.getName());
+ this.conf.set("hbase.client.registry.impl", SimpleRegistry.class.getName());
+ }
+
+ /**
+ * Simple cluster registry inserted in place of our usual zookeeper based one.
+ */
+ static class SimpleRegistry implements Registry {
+ final ServerName META_HOST = new ServerName("10.10.10.10", 60010, 12345);
+
+ @Override
+ public void init(HConnection connection) {
+ }
+
+ @Override
+ public HRegionLocation getMetaRegionLocation() throws IOException {
+ return new HRegionLocation(HRegionInfo.FIRST_META_REGIONINFO, META_HOST);
+ }
+
+ @Override
+ public String getClusterId() {
+ return HConstants.CLUSTER_ID_DEFAULT;
+ }
+
+ @Override
+ public boolean isTableOnlineState(byte[] tableName, boolean enabled)
+ throws IOException {
+ return enabled;
+ }
+
+ @Override
+ public int getCurrentNrHRS() throws IOException {
+ return 1;
+ }
+ }
+
+ @Test
+ public void testDoNotRetryMetaScanner() throws IOException {
+ MetaScanner.metaScan(this.conf, null);
+ }
+
+ @Test
+ public void testDoNotRetryOnScan() throws IOException {
+ // Go against meta else we will try to find first region for the table on construction which
+ // means we'll have to do a bunch more mocking. Tests that go against meta only should be
+ // good for a bit of testing.
+ HTable table = new HTable(this.conf, HConstants.META_TABLE_NAME);
+ ResultScanner scanner = table.getScanner(HConstants.CATALOG_FAMILY);
+ try {
+ Result result = null;
+ while ((result = scanner.next()) != null) {
+ LOG.info(result);
+ }
+ } finally {
+ scanner.close();
+ table.close();
+ }
+ }
+
+ /**
+ * Override to shutdown going to zookeeper for cluster id and meta location.
+ */
+ static class NoClusterConnection extends HConnectionManager.HConnectionImplementation {
+ final ClientService.BlockingInterface stub;
+
+ NoClusterConnection(Configuration conf, boolean managed) throws IOException {
+ super(conf, managed);
+ // Mock up my stub so open scanner returns a scanner id and then on next, we throw
+ // exceptions for three times and then after that, we return no more to scan.
+ this.stub = Mockito.mock(ClientService.BlockingInterface.class);
+ long sid = 12345L;
+ try {
+ Mockito.when(stub.scan((RpcController)Mockito.any(),
+ (ClientProtos.ScanRequest)Mockito.any())).
+ thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid).build()).
+ thenThrow(new ServiceException(new RegionServerStoppedException("From Mockito"))).
+ thenReturn(ClientProtos.ScanResponse.newBuilder().setScannerId(sid).
+ setMoreResults(false).build());
+ } catch (ServiceException e) {
+ throw new IOException(e);
+ }
+ }
+
+ @Override
+ public BlockingInterface getClient(ServerName sn) throws IOException {
+ return this.stub;
+ }
+ }
+}
\ No newline at end of file
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
index 84b5f6b..435faa9 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/util/RegionSplitter.java
@@ -1,5 +1,4 @@
/**
- *
* 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
@@ -394,8 +393,7 @@ public class RegionSplitter {
HTable table = new HTable(conf, tableName);
// max outstanding splits. default == 50% of servers
- final int MAX_OUTSTANDING =
- Math.max(table.getConnection().getCurrentNrHRS() / 2, minOS);
+ final int MAX_OUTSTANDING = Math.max(table.getConnection().getCurrentNrHRS() / 2, minOS);
Path hbDir = FSUtils.getRootDir(conf);
Path tableDir = HTableDescriptor.getTableDir(hbDir, table.getTableName());
diff --git a/hbase-server/src/test/resources/hbase-site.xml b/hbase-server/src/test/resources/hbase-site.xml
index 3cb7c1a..d2ff3eb 100644
--- a/hbase-server/src/test/resources/hbase-site.xml
+++ b/hbase-server/src/test/resources/hbase-site.xml
@@ -36,10 +36,6 @@
before running a retry of a failed get, region lookup, etc.
- hbase.defaults.for.version.skip
- true
-
-
hbase.client.retries.number
10
Maximum retries. Used as maximum for all retryable
diff --git a/pom.xml b/pom.xml
index 8eca6bf..b74f5c8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -890,7 +890,7 @@
1.50
1.4.3
1.2.17
- 1.9.0
+ 1.9.5
2.4.1
1.0.1
0.9.0