1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.hadoop.hbase.constraint;
19
20 import org.apache.hadoop.conf.Configuration;
21 import org.apache.hadoop.hbase.client.Put;
22
23
24
25
26 public class CheckConfigurationConstraint extends BaseConstraint {
27
28 private static String key = "testKey";
29 private static String value = "testValue";
30
31 public static Configuration getConfiguration() {
32 Configuration conf = new Configuration(false);
33 conf.set(key, value);
34 return conf;
35 }
36
37 @Override
38 public void check(Put p) {
39
40 }
41
42 @Override
43 public void setConf(Configuration conf) {
44 super.setConf(conf);
45 if (conf != null) {
46 String val = conf.get(key);
47 if (val == null || !val.equals(value))
48 throw new IllegalArgumentException(
49 "Configuration was not passed correctly");
50
51
52 if (conf.getRaw("fs.file.impl") != null)
53 throw new IllegalArgumentException(
54 "Configuration was created using 'new Configuration()', should be "
55 + "done via 'new Configuration(false) to exclude defaut hadoop "
56 + "configurations values.");
57 }
58 }
59
60 }