1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase;
21
22 import java.util.Map.Entry;
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.hadoop.conf.Configuration;
27 import org.apache.hadoop.hbase.util.VersionInfo;
28
29
30
31
32 public class HBaseConfiguration extends Configuration {
33
34 private static final Log LOG = LogFactory.getLog(HBaseConfiguration.class);
35
36
37
38
39
40 @Deprecated
41 public HBaseConfiguration() {
42
43 super();
44 addHbaseResources(this);
45 LOG.warn("instantiating HBaseConfiguration() is deprecated. Please use" +
46 " HBaseConfiguration#create() to construct a plain Configuration");
47 }
48
49
50
51
52
53 @Deprecated
54 public HBaseConfiguration(final Configuration c) {
55
56 this();
57 for (Entry<String, String>e: c) {
58 set(e.getKey(), e.getValue());
59 }
60 }
61
62 private static void checkDefaultsVersion(Configuration conf) {
63 String defaultsVersion = conf.get("hbase.defaults.for.version");
64 String thisVersion = VersionInfo.getVersion();
65 if (!thisVersion.equals(defaultsVersion)) {
66 throw new RuntimeException(
67 "hbase-default.xml file seems to be for and old version of HBase (" +
68 defaultsVersion + "), this version is " + thisVersion);
69 }
70 }
71
72 public static Configuration addHbaseResources(Configuration conf) {
73 conf.addResource("hbase-default.xml");
74 conf.addResource("hbase-site.xml");
75
76 checkDefaultsVersion(conf);
77 return conf;
78 }
79
80
81
82
83
84 public static Configuration create() {
85 Configuration conf = new Configuration();
86 return addHbaseResources(conf);
87 }
88
89
90
91
92
93
94
95 public static Configuration create(final Configuration that) {
96 Configuration conf = create();
97 for (Entry<String, String>e: that) {
98 conf.set(e.getKey(), e.getValue());
99 }
100 return conf;
101 }
102 }