HBASE-1289 Remove hbase.fully.distributed option and update docs

git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@758471 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2009-03-26 00:02:33 +00:00
parent a84378ea29
commit 18f891cde5
9 changed files with 75 additions and 36 deletions

View File

@ -9,6 +9,8 @@ Release 0.20.0 - Unreleased
(Ryan Rawson via Stack)
HBASE-1145 Ensure that there is only 1 Master with Zookeeper (Removes
hbase.master) (Nitay Joffe via Stack)
HBASE-1289 Remove "hbase.fully.distributed" option and update docs
(Nitay Joffe via Stack)
BUG FIXES
HBASE-1140 "ant clean test" fails (Nitay Joffe via Stack)

View File

@ -65,15 +65,14 @@ public interface HConstants {
/** Parameter name for master address */
static final String MASTER_ADDRESS = "hbase.master";
/** Parameter name for master host name. */
static final String MASTER_HOST_NAME = "hbase.master.hostname";
/** default host address */
static final String DEFAULT_HOST = "0.0.0.0";
/** default port that the master listens on */
static final int DEFAULT_MASTER_PORT = 60000;
/** Default master address */
static final String DEFAULT_MASTER_ADDRESS = DEFAULT_HOST + ":" +
DEFAULT_MASTER_PORT;
/** default port for master web api */
static final int DEFAULT_MASTER_INFOPORT = 60010;

View File

@ -323,20 +323,26 @@ public class LocalHBaseCluster implements HConstants {
* @return The passed <code>c</code> configuration modified if hbase.master
* value was 'local' otherwise, unaltered.
*/
public static HBaseConfiguration doLocal(final HBaseConfiguration c) {
private static HBaseConfiguration doLocal(final HBaseConfiguration c) {
if (!isLocal(c)) {
return c;
}
// Need to rewrite address in Configuration if not done already. This is
// for the case when we're using the deprecated master.address property.
// Need to rewrite address in Configuration if not done already.
String address = c.get(MASTER_ADDRESS);
if (address == null) {
return c;
if (address != null) {
String port = address.startsWith(LOCAL_COLON)?
address.substring(LOCAL_COLON.length()):
Integer.toString(DEFAULT_MASTER_PORT);
c.set(MASTER_ADDRESS, "localhost:" + port);
}
String port = address.startsWith(LOCAL_COLON)?
address.substring(LOCAL_COLON.length()):
Integer.toString(DEFAULT_MASTER_PORT);
c.set(MASTER_ADDRESS, "localhost:" + port);
// Need to rewrite host in Configuration if not done already.
String host = c.get(MASTER_HOST_NAME);
if (host != null && host.equals(LOCAL)) {
c.set(MASTER_HOST_NAME, "localhost");
}
return c;
}
@ -348,10 +354,11 @@ public class LocalHBaseCluster implements HConstants {
String address = c.get(MASTER_ADDRESS);
boolean addressIsLocal = address == null || address.equals(LOCAL) ||
address.startsWith(LOCAL_COLON);
boolean distributedOff = !c.getBoolean("run.distributed", false);
return addressIsLocal && distributedOff;
String host = c.get(MASTER_HOST_NAME);
boolean hostIsLocal = host == null || host.equals(LOCAL);
return addressIsLocal && hostIsLocal;
}
/**
* Test things basically work.
* @param args

View File

@ -40,7 +40,6 @@ 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.LocalHBaseCluster;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.RemoteExceptionHandler;
import org.apache.hadoop.hbase.TableNotFoundException;
@ -152,8 +151,8 @@ public class HConnectionManager implements HConstants {
*/
@SuppressWarnings("unchecked")
public TableServers(HBaseConfiguration conf) {
this.conf = LocalHBaseCluster.doLocal(new HBaseConfiguration(conf));
this.conf = conf;
String serverClassName =
conf.get(REGION_SERVER_CLASS, DEFAULT_REGION_SERVER_CLASS);

View File

@ -161,7 +161,7 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
// up in DNS.
String addressStr = conf.get(MASTER_ADDRESS);
if (addressStr == null) {
addressStr = conf.get("hbase.master.hostname");
addressStr = conf.get(MASTER_HOST_NAME);
if (addressStr == null) {
addressStr = InetAddress.getLocalHost().getCanonicalHostName();
}
@ -968,8 +968,8 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
" from meta region: " +
Bytes.toString(metaRegionName) + " because HRegionInfo was empty");
} catch (IOException e) {
LOG.error("deleting region: " + regionName + " from meta region: " +
metaRegionName, e);
LOG.error("deleting region: " + Bytes.toString(regionName) +
" from meta region: " + Bytes.toString(metaRegionName), e);
}
}
}
@ -1037,9 +1037,6 @@ public class HMaster extends Thread implements HConstants, HMasterInterface,
}
if (cmd.equals("stop")) {
if (LocalHBaseCluster.isLocal(conf)) {
conf = LocalHBaseCluster.doLocal(conf);
}
HBaseAdmin adm = null;
try {
adm = new HBaseAdmin(conf);

View File

@ -120,6 +120,10 @@ public class HQuorumPeer implements HConstants {
LOG.fatal(msg);
throw new IOException(msg);
}
// Special case for 'hbase.master.hostname' property being 'local'
if (variable.equals(HConstants.MASTER_HOST_NAME) && substituteValue.equals("local")) {
substituteValue = "localhost";
}
newValue.append(substituteValue);
varEnd += VARIABLE_END_LENGTH;

View File

@ -335,6 +335,11 @@ public class ZooKeeperWrapper implements HConstants {
return createRootRegionLocation(addressString);
}
/**
* Write address of master to ZooKeeper.
* @param address HServerAddress of master.
* @return true if operation succeeded, false otherwise.
*/
public boolean writeMasterAddress(HServerAddress address) {
if (!ensureParentExists(masterElectionZNode)) {
return false;

View File

@ -119,22 +119,24 @@ create them if you let it).
</p>
<h3><a name="fully-distrib">Fully-Distributed Operation</a></h3>
For running a fully-distributed operation on more than one host, the following configurations
must be made <i>in addition</i> to those described in the
<a href="#pseudo-distrib">pseudo-distributed operation</a> section above. In
<code>hbase-site.xml</code>, you must also configure <code>hbase.master</code> to the
<code>host:port</code> pair on which the HMaster runs
(<a href="http://wiki.apache.org/lucene-hadoop/Hbase/HbaseArchitecture">read about the HBase master,
regionservers, etc</a>). For example, adding the below to your <code>hbase-site.xml</code> says the
master is up on port 60000 on the host example.org:
For running a fully-distributed operation on more than one host, the following
configurations must be made <i>in addition</i> to those described in the
<a href="#pseudo-distrib">pseudo-distributed operation</a> section above.
In <code>hbase-site.xml</code>, you must also configure
<code>hbase.master.hostname</code> to the host on which the HBase master runs
(<a href="http://wiki.apache.org/lucene-hadoop/Hbase/HbaseArchitecture">read
about the HBase master, regionservers, etc</a>).
For example, adding the below to your <code>hbase-site.xml</code> says the
master is up on the host example.org:
</p>
<pre>
&lt;configuration&gt;
...
&lt;property&gt;
&lt;name&gt;hbase.master&lt;/name&gt;
&lt;value&gt;example.org:60000&lt;/value&gt;
&lt;description&gt;The host and port that the HBase master runs at.
&lt;name&gt;hbase.master.hostname&lt;/name&gt;
&lt;value&gt;example.org&lt;/value&gt;
&lt;description&gt;The host that the HBase master runs at.
A value of 'local' runs the master and regionserver in a single process.
&lt;/description&gt;
&lt;/property&gt;
...

View File

@ -71,5 +71,29 @@ public class HQuorumPeerTest extends HBaseTestCase {
assertTrue(servers.containsKey(Long.valueOf(0)));
QuorumServer server = servers.get(Long.valueOf(0));
assertEquals("localhost", server.addr.getHostName());
// Override with system property.
System.setProperty("hbase.master.hostname", "foo.bar");
is = new ByteArrayInputStream(s.getBytes());
properties = HQuorumPeer.parseConfig(is);
assertEquals("foo.bar:2888:3888", properties.get("server.0"));
QuorumPeerConfig.parseProperties(properties);
servers = QuorumPeerConfig.getServers();
server = servers.get(Long.valueOf(0));
assertEquals("foo.bar", server.addr.getHostName());
// Special case for property 'hbase.master.hostname' being 'local'
System.setProperty("hbase.master.hostname", "local");
is = new ByteArrayInputStream(s.getBytes());
properties = HQuorumPeer.parseConfig(is);
assertEquals("localhost:2888:3888", properties.get("server.0"));
QuorumPeerConfig.parseProperties(properties);
servers = QuorumPeerConfig.getServers();
server = servers.get(Long.valueOf(0));
assertEquals("localhost", server.addr.getHostName());
}
}