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.committable.hbase;
19  
20  import com.google.inject.Inject;
21  import com.google.inject.name.Named;
22  import org.apache.hadoop.hbase.util.Bytes;
23  
24  import static com.google.common.base.Charsets.UTF_8;
25  
26  public class HBaseCommitTableConfig {
27  
28      public static final String COMMIT_TABLE_NAME_KEY = "omid.committable.tablename";
29      public static final String COMMIT_TABLE_CF_NAME_KEY = "omid.committable.cfname";
30      public static final String COMMIT_TABLE_LWM_CF_NAME_KEY = "omid.committable.lwm.cfname";
31  
32      public static final String DEFAULT_COMMIT_TABLE_NAME = "OMID_COMMIT_TABLE";
33      public static final String DEFAULT_COMMIT_TABLE_CF_NAME = "F";
34      public static final String DEFAULT_COMMIT_TABLE_LWM_CF_NAME = "LWF";
35  
36      static final byte[] COMMIT_TABLE_QUALIFIER = "C".getBytes(UTF_8);
37      static final byte[] INVALID_TX_QUALIFIER = "IT".getBytes(UTF_8);
38      static final byte[] LOW_WATERMARK_QUALIFIER = "LWC".getBytes(UTF_8);
39      static final byte[] LOW_WATERMARK_ROW = "LOW_WATERMARK".getBytes(UTF_8);
40  
41      // ----------------------------------------------------------------------------------------------------------------
42      // Configuration parameters
43      // ----------------------------------------------------------------------------------------------------------------
44  
45      private String tableName = DEFAULT_COMMIT_TABLE_NAME;
46      private byte[] commitTableFamily = Bytes.toBytes(DEFAULT_COMMIT_TABLE_CF_NAME);
47      private byte[] lowWatermarkFamily = Bytes.toBytes(DEFAULT_COMMIT_TABLE_LWM_CF_NAME);
48  
49      // ----------------------------------------------------------------------------------------------------------------
50      // Getters and setters
51      // ----------------------------------------------------------------------------------------------------------------
52  
53      public String getTableName() {
54          return tableName;
55      }
56  
57  
58      @Inject(optional = true)
59      public void setTableName(@Named(COMMIT_TABLE_NAME_KEY) String tableName) {
60          this.tableName = tableName;
61      }
62  
63      public byte[] getCommitTableFamily() {
64          return commitTableFamily;
65      }
66  
67  
68      @Inject(optional = true)
69      public void setCommitTableFamily(@Named(COMMIT_TABLE_CF_NAME_KEY) String commitTableFamily) {
70          this.commitTableFamily = commitTableFamily.getBytes(UTF_8);
71      }
72  
73      public byte[] getLowWatermarkFamily() {
74          return lowWatermarkFamily;
75      }
76  
77      @Inject(optional = true)
78      public void setLowWatermarkFamily(@Named(COMMIT_TABLE_LWM_CF_NAME_KEY) String lowWatermarkFamily) {
79          this.lowWatermarkFamily = lowWatermarkFamily.getBytes(UTF_8);
80      }
81  
82  }