Navigation Menu

Skip to content

Commit

Permalink
WHIRR-206. [HBase] Extract strings to a HBaseServiceConstants interfa…
Browse files Browse the repository at this point in the history
…ce. Contributed by Lars George.

git-svn-id: https://svn.apache.org/repos/asf/incubator/whirr/trunk@1059205 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
tomwhite committed Jan 14, 2011
1 parent 999de90 commit deee213
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Expand Up @@ -65,6 +65,9 @@ Trunk (unreleased changes)

WHIRR-203. General documentation improvements for 0.3.0. (tomwhite)

WHIRR-206. [HBase] Extract strings to a HBaseServiceConstants interface.
(Lars George via tomwhite)

BUG FIXES

WHIRR-128. Fix DNS resolution for clients running within EC2.
Expand Down
Expand Up @@ -52,11 +52,13 @@ public String getRole() {
@Override
protected void beforeBootstrap(ClusterActionEvent event) throws IOException {
ClusterSpec clusterSpec = event.getClusterSpec();
addRunUrl(event, "util/configure-hostnames", "-c", clusterSpec.getProvider());
addRunUrl(event, "util/configure-hostnames",
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
addRunUrl(event, "sun/java/install");
String hbaseInstallRunUrl = clusterSpec.getConfiguration().getString(
"whirr.hbase-install-runurl", "apache/hbase/install");
addRunUrl(event, hbaseInstallRunUrl, "-c", clusterSpec.getProvider());
HBaseConstants.KEY_INSTALL_RUNURL, HBaseConstants.SCRIPT_INSTALL);
addRunUrl(event, hbaseInstallRunUrl,
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
event.setTemplateBuilderStrategy(new HBaseTemplateBuilderStrategy());
}

Expand All @@ -80,12 +82,14 @@ protected void beforeConfigure(ClusterActionEvent event)
clusterSpec, port);

String hbaseConfigureRunUrl = clusterSpec.getConfiguration().getString(
"whirr.hbase-configure-runurl", "apache/hbase/post-configure");
HBaseConstants.KEY_CONFIGURE_RUNURL,
HBaseConstants.SCRIPT_POST_CONFIGURE);
String master = DnsUtil.resolveAddress(masterPublicAddress.getHostAddress());
String quorum = ZooKeeperCluster.getHosts(cluster);
addRunUrl(event, hbaseConfigureRunUrl, role,
"-m", DnsUtil.resolveAddress(masterPublicAddress.getHostAddress()),
"-q", quorum,
"-p", Integer.toString(port),
"-c", clusterSpec.getProvider());
addRunUrl(event, hbaseConfigureRunUrl, role,
HBaseConstants.PARAM_MASTER, master,
HBaseConstants.PARAM_QUORUM, quorum,
HBaseConstants.PARAM_PORT, Integer.toString(port),
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
}
}
@@ -0,0 +1,42 @@
/**
* 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.whirr.service.hbase;

public final class HBaseConstants {

public static final String KEY_INSTALL_RUNURL = "whirr.hbase.install-runurl";
public static final String KEY_CONFIGURE_RUNURL = "whirr.hbase.configure-runurl";
public static final String KEY_VERSION = "whirr.hbase.version";

public static final String SCRIPT_INSTALL = "apache/hbase/install";
public static final String SCRIPT_POST_CONFIGURE = "apache/hbase/post-configure";

public static final String PARAM_PROVIDER = "-c";
public static final String PARAM_MASTER = "-m";
public static final String PARAM_QUORUM = "-q";
public static final String PARAM_PORT = "-p";
public static final String PARAM_VERSION = "-v";

public static final String PROP_HBASE_ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum";

public static final String FILE_HBASE_SITE_XML = "hbase-site.xml";

private HBaseConstants() {
}
}
Expand Up @@ -57,11 +57,13 @@ public String getRole() {
@Override
protected void beforeBootstrap(ClusterActionEvent event) throws IOException {
ClusterSpec clusterSpec = event.getClusterSpec();
addRunUrl(event, "util/configure-hostnames", "-c", clusterSpec.getProvider());
addRunUrl(event, "util/configure-hostnames",
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
addRunUrl(event, "sun/java/install");
String hadoopInstallRunUrl = clusterSpec.getConfiguration().getString(
"whirr.hbase-install-runurl", "apache/hbase/install");
addRunUrl(event, hadoopInstallRunUrl, "-c", clusterSpec.getProvider());
String hbaseInstallRunUrl = clusterSpec.getConfiguration().getString(
HBaseConstants.KEY_INSTALL_RUNURL, HBaseConstants.SCRIPT_INSTALL);
addRunUrl(event, hbaseInstallRunUrl,
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
event.setTemplateBuilderStrategy(new HBaseTemplateBuilderStrategy());
}

Expand All @@ -77,17 +79,18 @@ protected void beforeConfigure(ClusterActionEvent event) throws IOException, Int
ComputeServiceContext computeServiceContext =
ComputeServiceContextBuilder.build(clusterSpec);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
MASTER_WEB_UI_PORT);
MASTER_WEB_UI_PORT);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
masterPublicAddress.getHostAddress(), MASTER_PORT);

String hbaseConfigureRunUrl = clusterSpec.getConfiguration().getString(
"whirr.hbase-configure-runurl", "apache/hbase/post-configure");
HBaseConstants.KEY_CONFIGURE_RUNURL, HBaseConstants.SCRIPT_POST_CONFIGURE);
String master = DnsUtil.resolveAddress(masterPublicAddress.getHostAddress());
String quorum = ZooKeeperCluster.getHosts(cluster);
addRunUrl(event, hbaseConfigureRunUrl, ROLE,
"-m", DnsUtil.resolveAddress(masterPublicAddress.getHostAddress()),
"-q", quorum,
"-c", clusterSpec.getProvider());
addRunUrl(event, hbaseConfigureRunUrl, ROLE,
HBaseConstants.PARAM_MASTER, master,
HBaseConstants.PARAM_QUORUM, quorum,
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
}

@Override
Expand All @@ -112,13 +115,13 @@ protected void afterConfigure(ClusterActionEvent event) throws IOException {

private Properties createClientSideProperties(InetAddress master, String quorum) throws IOException {
Properties config = new Properties();
config.setProperty("hbase.zookeeper.quorum", quorum);
config.setProperty(HBaseConstants.PROP_HBASE_ZOOKEEPER_QUORUM, quorum);
return config;
}

private void createClientSideHadoopSiteFile(ClusterSpec clusterSpec, Properties config) {
File configDir = getConfigDir(clusterSpec);
File hbaseSiteFile = new File(configDir, "hbase-site.xml");
File hbaseSiteFile = new File(configDir, HBaseConstants.FILE_HBASE_SITE_XML);
try {
Files.write(generateHBaseConfigurationFile(config), hbaseSiteFile, Charsets.UTF_8);
LOG.info("Wrote HBase site file {}", hbaseSiteFile);
Expand Down
Expand Up @@ -45,11 +45,13 @@ public String getRole() {
@Override
protected void beforeBootstrap(ClusterActionEvent event) throws IOException {
ClusterSpec clusterSpec = event.getClusterSpec();
addRunUrl(event, "util/configure-hostnames", "-c", clusterSpec.getProvider());
String hbaseInstallRunUrl = clusterSpec.getConfiguration().getString(
"whirr.hbase-install-runurl", "apache/hbase/install");
addRunUrl(event, "util/configure-hostnames",
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
addRunUrl(event, "sun/java/install");
addRunUrl(event, hbaseInstallRunUrl, "-c", clusterSpec.getProvider());
String hbaseInstallRunUrl = clusterSpec.getConfiguration().getString(
HBaseConstants.KEY_INSTALL_RUNURL, HBaseConstants.SCRIPT_INSTALL);
addRunUrl(event, hbaseInstallRunUrl,
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
event.setTemplateBuilderStrategy(new HBaseTemplateBuilderStrategy());
}

Expand All @@ -68,15 +70,17 @@ protected void beforeConfigure(ClusterActionEvent event)
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
REGIONSERVER_WEB_UI_PORT);
FirewallSettings.authorizeIngress(computeServiceContext, instance, clusterSpec,
masterPublicAddress.getHostAddress(), REGIONSERVER_PORT);
masterPublicAddress.getHostAddress(), REGIONSERVER_PORT);

String hbaseConfigureRunUrl = clusterSpec.getConfiguration().getString(
"whirr.hbase-configure-runurl", "apache/hbase/post-configure");
HBaseConstants.KEY_CONFIGURE_RUNURL,
HBaseConstants.SCRIPT_POST_CONFIGURE);
String master = DnsUtil.resolveAddress(masterPublicAddress.getHostAddress());
String quorum = ZooKeeperCluster.getHosts(cluster);
addRunUrl(event, hbaseConfigureRunUrl, ROLE,
"-m", DnsUtil.resolveAddress(masterPublicAddress.getHostAddress()),
"-q", quorum,
"-c", clusterSpec.getProvider());
addRunUrl(event, hbaseConfigureRunUrl, ROLE,
HBaseConstants.PARAM_MASTER, master,
HBaseConstants.PARAM_QUORUM, quorum,
HBaseConstants.PARAM_PROVIDER, clusterSpec.getProvider());
}

}

0 comments on commit deee213

Please sign in to comment.