1
|
package eu.dnetlib.data.hadoop.hbase;
|
2
|
|
3
|
import eu.dnetlib.data.hadoop.HadoopClientMap;
|
4
|
import eu.dnetlib.data.hadoop.HadoopServiceCore;
|
5
|
import eu.dnetlib.data.hadoop.config.ConfigurationEnumerator;
|
6
|
import eu.dnetlib.data.hadoop.config.ConfigurationFactory;
|
7
|
import eu.dnetlib.data.hadoop.mapred.JobClientFactory;
|
8
|
import eu.dnetlib.data.hadoop.oozie.OozieClientFactory;
|
9
|
import org.springframework.context.annotation.Bean;
|
10
|
import org.springframework.context.annotation.Configuration;
|
11
|
import org.springframework.context.annotation.Profile;
|
12
|
import org.springframework.core.io.ClassPathResource;
|
13
|
import org.springframework.core.io.Resource;
|
14
|
|
15
|
@Configuration
|
16
|
@Profile(value = "test")
|
17
|
public class HBaseTestContextConfiguration {
|
18
|
|
19
|
public static final String ENABLED_CLIENTS = "{"
|
20
|
+ "\"DM\":{\"oozie\":\"false\",\"mapred\":\"false\",\"hbase\":\"true\"},"
|
21
|
+ "\"IIS\":{\"oozie\":\"false\",\"mapred\":\"false\",\"hbase\":\"false\"}"
|
22
|
+ "}";
|
23
|
|
24
|
public static final int MAX_VERSIONS = 10;
|
25
|
|
26
|
@Bean
|
27
|
public HadoopServiceCore hadoopServiceCore() {
|
28
|
final HadoopServiceCore core = new HadoopServiceCore();
|
29
|
|
30
|
core.setMaxVersions(MAX_VERSIONS);
|
31
|
|
32
|
System.out.println("using hbase max versions: " + MAX_VERSIONS);
|
33
|
return core;
|
34
|
}
|
35
|
|
36
|
@Bean
|
37
|
public HadoopClientMap hadoopClientMap() throws InterruptedException {
|
38
|
final HadoopClientMap clientMap = new HadoopClientMap();
|
39
|
clientMap.setEnabledClients(ENABLED_CLIENTS);
|
40
|
|
41
|
return clientMap;
|
42
|
}
|
43
|
|
44
|
@Bean
|
45
|
public HBaseAdminFactory hBaseAdminFactory() {
|
46
|
return new HBaseAdminFactory();
|
47
|
}
|
48
|
|
49
|
@Bean
|
50
|
public OozieClientFactory oozieClientFactory() {
|
51
|
return new OozieClientFactory();
|
52
|
}
|
53
|
|
54
|
@Bean
|
55
|
public JobClientFactory jobClientFactory() {
|
56
|
return new JobClientFactory();
|
57
|
}
|
58
|
|
59
|
@Bean
|
60
|
public ConfigurationEnumerator configurationEnumerator() {
|
61
|
return new ConfigurationEnumerator();
|
62
|
}
|
63
|
|
64
|
@Bean
|
65
|
public ConfigurationFactory DM() {
|
66
|
return get(new ClassPathResource("/eu/dnetlib/data/hadoop/config/hadoop-default.dm.cnr.properties"));
|
67
|
}
|
68
|
|
69
|
@Bean
|
70
|
public ConfigurationFactory IIS() {
|
71
|
return get(new ClassPathResource("/eu/dnetlib/data/hadoop/config/hadoop-default.iis.icm.properties"));
|
72
|
}
|
73
|
|
74
|
protected ConfigurationFactory get(final Resource props) {
|
75
|
final ConfigurationFactory configurationFactory = new ConfigurationFactory();
|
76
|
configurationFactory.setDefaults(props);
|
77
|
return configurationFactory;
|
78
|
}
|
79
|
|
80
|
}
|