HBASE-3517. Store build version in hbase-default.xml and verify at runtime

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1069038 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2011-02-09 19:12:08 +00:00
parent b43483b764
commit 614f8f665f
5 changed files with 38 additions and 0 deletions

View File

@ -110,6 +110,7 @@ Release 0.90.1 - Unreleased
aborts. Instead, should just cancel region open.
HBASE-3515 [replication] ReplicationSource can miss a log after RS comes
out of GC
HBASE-3517 Store build version in hbase-default.xml and verify at runtime
Release 0.90.0 - January 19th, 2011
INCOMPATIBLE CHANGES

12
pom.xml
View File

@ -423,6 +423,18 @@
<goal>run</goal>
</goals>
</execution>
<execution>
<phase>process-resources</phase>
<configuration>
<tasks>
<replace file="${project.build.outputDirectory}/hbase-default.xml"
token="@@@VERSION@@@" value="${project.version}" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>

View File

@ -24,6 +24,7 @@ import java.util.Map.Entry;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.util.VersionInfo;
/**
* Adds HBase configuration files to a Configuration
@ -58,9 +59,21 @@ public class HBaseConfiguration extends Configuration {
}
}
private static void checkDefaultsVersion(Configuration conf) {
String defaultsVersion = conf.get("hbase.defaults.for.version");
String thisVersion = VersionInfo.getVersion();
if (!thisVersion.equals(defaultsVersion)) {
throw new RuntimeException(
"hbase-default.xml file seems to be for and old version of HBase (" +
defaultsVersion + "), this version is " + thisVersion);
}
}
public static Configuration addHbaseResources(Configuration conf) {
conf.addResource("hbase-default.xml");
conf.addResource("hbase-site.xml");
checkDefaultsVersion(conf);
return conf;
}

View File

@ -609,4 +609,14 @@
true: Only the GET method is permitted.
</description>
</property>
<property skipInDoc="true">
<name>hbase.defaults.for.version</name>
<value>@@@VERSION@@@</value>
<description>
This defaults file was compiled for version @@@VERSION@@@. This variable is used
to make sure that a user doesn't have an old version of hbase-default.xml on the
classpath.
</description>
</property>
</configuration>

View File

@ -45,6 +45,7 @@ This documentation is generated using the default hbase configuration file,
</para>
<xsl:for-each select="property">
<xsl:if test="not(@skipInDoc)">
<glossentry>
<xsl:attribute name="id">
<xsl:value-of select="name" />
@ -57,6 +58,7 @@ This documentation is generated using the default hbase configuration file,
<para>Default: <varname><xsl:value-of select="value"/></varname></para>
</glossdef>
</glossentry>
</xsl:if>
</xsl:for-each>
</glossary>