1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.omid.tso;
19
20 import com.google.inject.AbstractModule;
21 import com.google.inject.Provides;
22 import com.google.inject.name.Names;
23 import org.apache.omid.HBaseConfigModule;
24 import org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig;
25 import org.apache.omid.tso.LeaseManagement.LeaseManagementException;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
28
29 import javax.inject.Singleton;
30
31 import static org.apache.omid.timestamp.storage.HBaseTimestampStorageConfig.DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
32
33 public class VoidLeaseManagementModule extends AbstractModule {
34 private static final Logger LOG = LoggerFactory.getLogger(VoidLeaseManagementModule.class);
35 private String keytab;
36 private String principal;
37 private String tableName = DEFAULT_TIMESTAMP_STORAGE_TABLE_NAME;
38
39 @Override
40 protected void configure() {
41 LOG.info(this.toString());
42 bindConstant().annotatedWith(Names.named(HBaseTimestampStorageConfig.TIMESTAMP_STORAGE_TABLE_NAME_KEY)).to(tableName);
43 install(new HBaseConfigModule(principal, keytab));
44 }
45
46 @Provides
47 @Singleton
48 LeaseManagement provideLeaseManager(TSOChannelHandler tsoChannelHandler, TSOStateManager stateManager)
49 throws LeaseManagementException {
50
51 return new VoidLeaseManager(tsoChannelHandler, stateManager);
52
53 }
54
55
56
57
58
59 public String getTableName() {
60 return tableName;
61 }
62
63 public void setTableName(String tableName) {
64 this.tableName = tableName;
65 }
66
67 public String getPrincipal() {
68 return principal;
69 }
70
71 public void setPrincipal(String principal) {
72 this.principal = principal;
73 }
74
75 public String getKeytab() {
76 return keytab;
77 }
78
79 public void setKeytab(String keytab) {
80 this.keytab = keytab;
81 }
82
83 @Override
84 public String toString() {
85 final StringBuilder sb = new StringBuilder("VoidLeaseManagementModule{");
86 sb.append("keytab='").append(keytab).append('\'');
87 sb.append(", principal='").append(principal).append('\'');
88 sb.append(", tableName='").append(tableName).append('\'');
89 sb.append('}');
90 return sb.toString();
91 }
92 }