View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.omid.tso;
19  
20  import org.apache.phoenix.thirdparty.com.google.common.annotations.VisibleForTesting;
21  import com.google.inject.Module;
22  
23  import org.apache.omid.NetworkUtils;
24  import org.apache.omid.YAMLUtils;
25  import org.apache.omid.metrics.MetricsRegistry;
26  import org.apache.omid.tools.hbase.SecureHBaseConfig;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  
30  /**
31   * Reads the configuration parameters of a TSO server instance from CONFIG_FILE_NAME.
32   * If file CONFIG_FILE_NAME is missing defaults to DEFAULT_CONFIG_FILE_NAME
33   */
34  @SuppressWarnings("all")
35  public class TSOServerConfig extends SecureHBaseConfig {
36  
37      private static final Logger LOG = LoggerFactory.getLogger(TSOServerConfig.class);
38  
39      private static final String CONFIG_FILE_NAME = "omid-server-configuration.yml";
40      private static final String DEFAULT_CONFIG_FILE_NAME = "default-omid-server-configuration.yml";
41  
42      public static enum WAIT_STRATEGY {
43          HIGH_THROUGHPUT,
44          LOW_CPU
45      };
46  
47      public static enum TIMESTAMP_TYPE {
48        INCREMENTAL,
49        WORLD_TIME
50      };
51  
52      // ----------------------------------------------------------------------------------------------------------------
53      // Instantiation
54      // ----------------------------------------------------------------------------------------------------------------
55      public TSOServerConfig() {
56          this(CONFIG_FILE_NAME);
57      }
58  
59      @VisibleForTesting
60      TSOServerConfig(String configFileName) {
61          new YAMLUtils().loadSettings(configFileName, DEFAULT_CONFIG_FILE_NAME, this);
62      }
63  
64      // ----------------------------------------------------------------------------------------------------------------
65      // Configuration parameters
66      // ----------------------------------------------------------------------------------------------------------------
67  
68      private Module timestampStoreModule;
69  
70      private Module commitTableStoreModule;
71  
72      private Module leaseModule;
73  
74      private int port;
75  
76      private MetricsRegistry metrics;
77  
78      private int conflictMapSize;
79  
80      private int numConcurrentCTWriters;
81  
82      private int batchSizePerCTWriter;
83  
84      private int batchPersistTimeoutInMs;
85  
86      private String waitStrategy;
87  
88      private String networkIfaceName = NetworkUtils.getDefaultNetworkInterface();
89  
90      private String timestampType;
91  
92      private Boolean lowLatency;
93  
94      public boolean monitorContext;
95  
96      public boolean getMonitorContext() {
97          return monitorContext;
98      }
99  
100     public void setMonitorContext(boolean monitorContext) {
101         this.monitorContext = monitorContext;
102     }
103 
104     public Boolean getLowLatency() {
105         return lowLatency;
106     }
107 
108     public void setLowLatency(Boolean lowLatency) {
109         this.lowLatency = lowLatency;
110     }
111 
112     public int getPort() {
113         return port;
114     }
115 
116     public void setPort(int port) {
117         this.port = port;
118     }
119 
120     public int getConflictMapSize() {
121         return conflictMapSize;
122     }
123 
124     public void setConflictMapSize(int conflictMapSize) {
125         this.conflictMapSize = conflictMapSize;
126     }
127 
128     public int getNumConcurrentCTWriters() {
129         return numConcurrentCTWriters;
130     }
131 
132     public void setNumConcurrentCTWriters(int numConcurrentCTWriters) {
133         this.numConcurrentCTWriters = numConcurrentCTWriters;
134     }
135 
136     public int getBatchSizePerCTWriter() {
137         return batchSizePerCTWriter;
138     }
139 
140     public void setBatchSizePerCTWriter(int batchSizePerCTWriter) {
141         this.batchSizePerCTWriter = batchSizePerCTWriter;
142     }
143 
144     public int getBatchPersistTimeoutInMs() {
145         return batchPersistTimeoutInMs;
146     }
147 
148     public void setBatchPersistTimeoutInMs(int value) {
149         this.batchPersistTimeoutInMs = value;
150     }
151 
152     public String getNetworkIfaceName() {
153         return networkIfaceName;
154     }
155 
156     public void setNetworkIfaceName(String networkIfaceName) {
157         this.networkIfaceName = networkIfaceName;
158     }
159 
160     public String getTimestampType() {
161         return timestampType;
162     }
163 
164     public void setTimestampType(String type) {
165         this.timestampType = type;
166     }
167 
168     public TIMESTAMP_TYPE getTimestampTypeEnum() {
169         return TSOServerConfig.TIMESTAMP_TYPE.valueOf(timestampType);
170     }
171 
172     public Module getTimestampStoreModule() {
173         return timestampStoreModule;
174     }
175 
176     public void setTimestampStoreModule(Module timestampStoreModule) {
177         this.timestampStoreModule = timestampStoreModule;
178     }
179 
180     public Module getCommitTableStoreModule() {
181         return commitTableStoreModule;
182     }
183 
184     public void setCommitTableStoreModule(Module commitTableStoreModule) {
185         this.commitTableStoreModule = commitTableStoreModule;
186     }
187 
188     public Module getLeaseModule() {
189         return leaseModule;
190     }
191 
192     public void setLeaseModule(Module leaseModule) {
193         this.leaseModule = leaseModule;
194     }
195 
196     public MetricsRegistry getMetrics() {
197         return metrics;
198     }
199 
200     public void setMetrics(MetricsRegistry metrics) {
201         this.metrics = metrics;
202     }
203 
204     public String getWaitStrategy() {
205         return waitStrategy;
206     }
207 
208     public WAIT_STRATEGY getWaitStrategyEnum() {
209         return TSOServerConfig.WAIT_STRATEGY.valueOf(waitStrategy);
210     }
211 
212     public void setWaitStrategy(String waitStrategy) {
213         this.waitStrategy = waitStrategy;
214     }
215 }