HBASE-919 Master and Region Server need to provide root region location if they are using HTable
git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@705338 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a171d57765
commit
f5ded90780
|
@ -31,6 +31,8 @@ Release 0.19.0 - Unreleased
|
||||||
log java.io.IOException: Could not get block locations. Aborting...
|
log java.io.IOException: Could not get block locations. Aborting...
|
||||||
HBASE-926 If no master, regionservers should hang out rather than fail on
|
HBASE-926 If no master, regionservers should hang out rather than fail on
|
||||||
connection and shut themselves down
|
connection and shut themselves down
|
||||||
|
HBASE-919 Master and Region Server need to provide root region location if
|
||||||
|
they are using HTable
|
||||||
|
|
||||||
IMPROVEMENTS
|
IMPROVEMENTS
|
||||||
HBASE-901 Add a limit to key length, check key and value length on client side
|
HBASE-901 Add a limit to key length, check key and value length on client side
|
||||||
|
|
|
@ -62,11 +62,9 @@ import org.apache.hadoop.ipc.RemoteException;
|
||||||
*/
|
*/
|
||||||
public class HConnectionManager implements HConstants {
|
public class HConnectionManager implements HConstants {
|
||||||
/*
|
/*
|
||||||
* Private. Not instantiable.
|
* Not instantiable.
|
||||||
*/
|
*/
|
||||||
private HConnectionManager() {
|
protected HConnectionManager() {}
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
// A Map of master HServerAddress -> connection information for that instance
|
// A Map of master HServerAddress -> connection information for that instance
|
||||||
// Note that although the Map is synchronized, the objects it contains
|
// Note that although the Map is synchronized, the objects it contains
|
||||||
|
@ -109,7 +107,7 @@ public class HConnectionManager implements HConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Encapsulates finding the servers for an HBase instance */
|
/* Encapsulates finding the servers for an HBase instance */
|
||||||
private static class TableServers implements HConnection, HConstants {
|
private static class TableServers implements ServerConnection, HConstants {
|
||||||
private static final Log LOG = LogFactory.getLog(TableServers.class);
|
private static final Log LOG = LogFactory.getLog(TableServers.class);
|
||||||
private final Class<? extends HRegionInterface> serverInterfaceClass;
|
private final Class<? extends HRegionInterface> serverInterfaceClass;
|
||||||
private final long pause;
|
private final long pause;
|
||||||
|
@ -168,9 +166,14 @@ public class HConnectionManager implements HConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getPauseTime(int tries) {
|
private long getPauseTime(int tries) {
|
||||||
if (tries >= HConstants.RETRY_BACKOFF.length)
|
int ntries = tries;
|
||||||
tries = HConstants.RETRY_BACKOFF.length - 1;
|
if (ntries >= HConstants.RETRY_BACKOFF.length)
|
||||||
return this.pause * HConstants.RETRY_BACKOFF[tries];
|
ntries = HConstants.RETRY_BACKOFF.length - 1;
|
||||||
|
return this.pause * HConstants.RETRY_BACKOFF[ntries];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRootRegionLocation(HRegionLocation rootRegion) {
|
||||||
|
this.rootRegionLocation = rootRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HMasterInterface getMaster() throws MasterNotRunningException {
|
public HMasterInterface getMaster() throws MasterNotRunningException {
|
||||||
|
@ -366,8 +369,7 @@ public class HConnectionManager implements HConstants {
|
||||||
implements MetaScanner.MetaScannerVisitor {
|
implements MetaScanner.MetaScannerVisitor {
|
||||||
byte[] tableName;
|
byte[] tableName;
|
||||||
HTableDescriptor result;
|
HTableDescriptor result;
|
||||||
//TODO: change visibility to protected
|
protected HTableDescriptorFinder(byte[] tableName) {
|
||||||
public HTableDescriptorFinder(byte[] tableName) {
|
|
||||||
this.tableName = tableName;
|
this.tableName = tableName;
|
||||||
}
|
}
|
||||||
public boolean processRow(RowResult rowResult) throws IOException {
|
public boolean processRow(RowResult rowResult) throws IOException {
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
/**
|
||||||
|
* 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.HRegionLocation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by master and region server, so that they do not need to wait for the
|
||||||
|
* cluster to be up to get a connection.
|
||||||
|
*/
|
||||||
|
public interface ServerConnection extends HConnection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set root region location in connection
|
||||||
|
* @param rootRegion
|
||||||
|
*/
|
||||||
|
public void setRootRegionLocation(HRegionLocation rootRegion);
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* 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.HBaseConfiguration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by server processes to expose HServerConnection method
|
||||||
|
* setRootRegionLocation
|
||||||
|
*/
|
||||||
|
public class ServerConnectionManager extends HConnectionManager {
|
||||||
|
/*
|
||||||
|
* Not instantiable
|
||||||
|
*/
|
||||||
|
private ServerConnectionManager() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the connection object for the instance specified by the configuration
|
||||||
|
* If no current connection exists, create a new connection for that instance
|
||||||
|
* @param conf
|
||||||
|
* @return HConnection object for the instance specified by the configuration
|
||||||
|
*/
|
||||||
|
public static ServerConnection getConnection(HBaseConfiguration conf) {
|
||||||
|
return (ServerConnection) HConnectionManager.getConnection(conf);
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@ import org.apache.hadoop.ipc.VersionedProtocol;
|
||||||
import org.apache.hadoop.hbase.HServerInfo;
|
import org.apache.hadoop.hbase.HServerInfo;
|
||||||
import org.apache.hadoop.hbase.HMsg;
|
import org.apache.hadoop.hbase.HMsg;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
|
import org.apache.hadoop.hbase.HServerAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HRegionServers interact with the HMasterRegionInterface to report on local
|
* HRegionServers interact with the HMasterRegionInterface to report on local
|
||||||
|
@ -67,4 +68,11 @@ public interface HMasterRegionInterface extends VersionedProtocol {
|
||||||
public HMsg[] regionServerReport(HServerInfo info, HMsg msgs[],
|
public HMsg[] regionServerReport(HServerInfo info, HMsg msgs[],
|
||||||
HRegionInfo mostLoadedRegions[])
|
HRegionInfo mostLoadedRegions[])
|
||||||
throws IOException;
|
throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Root region region server address. Unlike
|
||||||
|
* HMasterInterface.findRootRegion, does not wait until all regions are
|
||||||
|
* assigned.
|
||||||
|
*/
|
||||||
|
public HServerAddress getRootRegionLocation();
|
||||||
}
|
}
|
|
@ -52,8 +52,8 @@ import org.apache.hadoop.hbase.RegionHistorian;
|
||||||
import org.apache.hadoop.hbase.RemoteExceptionHandler;
|
import org.apache.hadoop.hbase.RemoteExceptionHandler;
|
||||||
import org.apache.hadoop.hbase.TableExistsException;
|
import org.apache.hadoop.hbase.TableExistsException;
|
||||||
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
import org.apache.hadoop.hbase.client.HBaseAdmin;
|
||||||
import org.apache.hadoop.hbase.client.HConnection;
|
import org.apache.hadoop.hbase.client.ServerConnection;
|
||||||
import org.apache.hadoop.hbase.client.HConnectionManager;
|
import org.apache.hadoop.hbase.client.ServerConnectionManager;
|
||||||
import org.apache.hadoop.hbase.io.Cell;
|
import org.apache.hadoop.hbase.io.Cell;
|
||||||
import org.apache.hadoop.hbase.io.RowResult;
|
import org.apache.hadoop.hbase.io.RowResult;
|
||||||
import org.apache.hadoop.hbase.ipc.HMasterInterface;
|
import org.apache.hadoop.hbase.ipc.HMasterInterface;
|
||||||
|
@ -116,7 +116,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
||||||
private final Server server;
|
private final Server server;
|
||||||
private final HServerAddress address;
|
private final HServerAddress address;
|
||||||
|
|
||||||
final HConnection connection;
|
final ServerConnection connection;
|
||||||
|
|
||||||
final int metaRescanInterval;
|
final int metaRescanInterval;
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
||||||
this.address = new HServerAddress(server.getListenerAddress());
|
this.address = new HServerAddress(server.getListenerAddress());
|
||||||
conf.set(MASTER_ADDRESS, address.toString());
|
conf.set(MASTER_ADDRESS, address.toString());
|
||||||
|
|
||||||
this.connection = HConnectionManager.getConnection(conf);
|
this.connection = ServerConnectionManager.getConnection(conf);
|
||||||
|
|
||||||
this.metaRescanInterval =
|
this.metaRescanInterval =
|
||||||
conf.getInt("hbase.master.meta.thread.rescanfrequency", 60 * 1000);
|
conf.getInt("hbase.master.meta.thread.rescanfrequency", 60 * 1000);
|
||||||
|
@ -679,7 +679,11 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
|
||||||
}
|
}
|
||||||
|
|
||||||
public HServerAddress findRootRegion() {
|
public HServerAddress findRootRegion() {
|
||||||
return regionManager.getRootRegionLocation();
|
HServerAddress rootServer = null;
|
||||||
|
if (regionManager.allRegionsAssigned()) {
|
||||||
|
rootServer = regionManager.getRootRegionLocation();
|
||||||
|
}
|
||||||
|
return rootServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.LeaseException;
|
||||||
import org.apache.hadoop.hbase.Leases;
|
import org.apache.hadoop.hbase.Leases;
|
||||||
import org.apache.hadoop.hbase.LeaseListener;
|
import org.apache.hadoop.hbase.LeaseListener;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
|
import org.apache.hadoop.hbase.HRegionLocation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ServerManager class manages info about region servers - HServerInfo,
|
* The ServerManager class manages info about region servers - HServerInfo,
|
||||||
|
@ -444,7 +445,10 @@ class ServerManager implements HConstants {
|
||||||
|
|
||||||
if (region.isRootRegion()) {
|
if (region.isRootRegion()) {
|
||||||
// Store the Root Region location (in memory)
|
// Store the Root Region location (in memory)
|
||||||
master.regionManager.setRootRegionLocation(serverInfo.getServerAddress());
|
HServerAddress rootServer = serverInfo.getServerAddress();
|
||||||
|
master.connection.setRootRegionLocation(
|
||||||
|
new HRegionLocation(region, rootServer));
|
||||||
|
master.regionManager.setRootRegionLocation(rootServer);
|
||||||
} else {
|
} else {
|
||||||
// Note that the table has been assigned and is waiting for the
|
// Note that the table has been assigned and is waiting for the
|
||||||
// meta table to be updated.
|
// meta table to be updated.
|
||||||
|
@ -470,6 +474,7 @@ class ServerManager implements HConstants {
|
||||||
LOG.fatal("root region is marked offline");
|
LOG.fatal("root region is marked offline");
|
||||||
master.shutdown();
|
master.shutdown();
|
||||||
}
|
}
|
||||||
|
master.connection.setRootRegionLocation(null);
|
||||||
master.regionManager.unassignRootRegion();
|
master.regionManager.unassignRootRegion();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -57,6 +57,7 @@ import org.apache.hadoop.hbase.HColumnDescriptor;
|
||||||
import org.apache.hadoop.hbase.HConstants;
|
import org.apache.hadoop.hbase.HConstants;
|
||||||
import org.apache.hadoop.hbase.HMsg;
|
import org.apache.hadoop.hbase.HMsg;
|
||||||
import org.apache.hadoop.hbase.HRegionInfo;
|
import org.apache.hadoop.hbase.HRegionInfo;
|
||||||
|
import org.apache.hadoop.hbase.HRegionLocation;
|
||||||
import org.apache.hadoop.hbase.HServerAddress;
|
import org.apache.hadoop.hbase.HServerAddress;
|
||||||
import org.apache.hadoop.hbase.HServerInfo;
|
import org.apache.hadoop.hbase.HServerInfo;
|
||||||
import org.apache.hadoop.hbase.HServerLoad;
|
import org.apache.hadoop.hbase.HServerLoad;
|
||||||
|
@ -72,6 +73,8 @@ import org.apache.hadoop.hbase.UnknownScannerException;
|
||||||
import org.apache.hadoop.hbase.UnknownRowLockException;
|
import org.apache.hadoop.hbase.UnknownRowLockException;
|
||||||
import org.apache.hadoop.hbase.ValueOverMaxLengthException;
|
import org.apache.hadoop.hbase.ValueOverMaxLengthException;
|
||||||
import org.apache.hadoop.hbase.Leases.LeaseStillHeldException;
|
import org.apache.hadoop.hbase.Leases.LeaseStillHeldException;
|
||||||
|
import org.apache.hadoop.hbase.client.ServerConnection;
|
||||||
|
import org.apache.hadoop.hbase.client.ServerConnectionManager;
|
||||||
import org.apache.hadoop.hbase.filter.RowFilterInterface;
|
import org.apache.hadoop.hbase.filter.RowFilterInterface;
|
||||||
import org.apache.hadoop.hbase.io.BatchOperation;
|
import org.apache.hadoop.hbase.io.BatchOperation;
|
||||||
import org.apache.hadoop.hbase.io.BatchUpdate;
|
import org.apache.hadoop.hbase.io.BatchUpdate;
|
||||||
|
@ -117,6 +120,9 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
||||||
|
|
||||||
protected final HServerInfo serverInfo;
|
protected final HServerInfo serverInfo;
|
||||||
protected final HBaseConfiguration conf;
|
protected final HBaseConfiguration conf;
|
||||||
|
|
||||||
|
private final ServerConnection connection;
|
||||||
|
private final AtomicBoolean haveRootRegion = new AtomicBoolean(false);
|
||||||
private FileSystem fs;
|
private FileSystem fs;
|
||||||
private Path rootDir;
|
private Path rootDir;
|
||||||
private final Random rand = new Random();
|
private final Random rand = new Random();
|
||||||
|
@ -226,6 +232,7 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
||||||
this.abortRequested = false;
|
this.abortRequested = false;
|
||||||
this.fsOk = true;
|
this.fsOk = true;
|
||||||
this.conf = conf;
|
this.conf = conf;
|
||||||
|
this.connection = ServerConnectionManager.getConnection(conf);
|
||||||
|
|
||||||
this.isOnline = false;
|
this.isOnline = false;
|
||||||
|
|
||||||
|
@ -626,6 +633,17 @@ public class HRegionServer implements HConstants, HRegionInterface, Runnable {
|
||||||
* the end of the main HRegionServer run loop.
|
* the end of the main HRegionServer run loop.
|
||||||
*/
|
*/
|
||||||
private void housekeeping() {
|
private void housekeeping() {
|
||||||
|
// Try to get the root region location from the master.
|
||||||
|
if (!haveRootRegion.get()) {
|
||||||
|
HServerAddress rootServer = hbaseMaster.getRootRegionLocation();
|
||||||
|
if (rootServer != null) {
|
||||||
|
// By setting the root region location, we bypass the wait imposed on
|
||||||
|
// HTable for all regions being assigned.
|
||||||
|
this.connection.setRootRegionLocation(
|
||||||
|
new HRegionLocation(HRegionInfo.ROOT_REGIONINFO, rootServer));
|
||||||
|
haveRootRegion.set(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
// If the todo list has > 0 messages, iterate looking for open region
|
// If the todo list has > 0 messages, iterate looking for open region
|
||||||
// messages. Send the master a message that we're working on its
|
// messages. Send the master a message that we're working on its
|
||||||
// processing so it doesn't assign the region elsewhere.
|
// processing so it doesn't assign the region elsewhere.
|
||||||
|
|
Loading…
Reference in New Issue