1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.omid.timestamp.storage;
19
20 import com.google.inject.AbstractModule;
21 import com.google.inject.Provides;
22 import org.apache.curator.framework.CuratorFramework;
23 import org.apache.omid.zk.ZKUtils;
24
25 import javax.inject.Singleton;
26 import java.io.IOException;
27
28
29 public class ZKModule extends AbstractModule {
30
31 private final String zkCluster;
32 private final String namespace;
33
34 public ZKModule(String zkCluster, String namespace) {
35 this.zkCluster = zkCluster;
36 this.namespace = namespace;
37 }
38
39 @Override
40 public void configure() {
41 }
42
43 @Provides
44 @Singleton
45 CuratorFramework provideInitializedZookeeperClient() throws IOException {
46 return ZKUtils.initZKClient(zkCluster, namespace, 10);
47 }
48
49
50
51
52
53 @Override
54 public boolean equals(Object o) {
55
56 if (this == o) return true;
57 if (o == null || getClass() != o.getClass()) return false;
58
59 ZKModule zkModule = (ZKModule) o;
60
61 if (!zkCluster.equals(zkModule.zkCluster)) return false;
62 return namespace.equals(zkModule.namespace);
63
64 }
65
66 @Override
67 public int hashCode() {
68
69 int result = zkCluster.hashCode();
70 result = 31 * result + namespace.hashCode();
71 return result;
72
73 }
74
75 }