1#
2#
3# Licensed to the Apache Software Foundation (ASF) under one
4# or more contributor license agreements.  See the NOTICE file
5# distributed with this work for additional information
6# regarding copyright ownership.  The ASF licenses this file
7# to you under the Apache License, Version 2.0 (the
8# "License"); you may not use this file except in compliance
9# with the License.  You may obtain a copy of the License at
10#
11#     http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19
20# HBase ruby classes.
21# Has wrapper classes for org.apache.hadoop.hbase.client.Admin
22# and for org.apache.hadoop.hbase.client.Table.  Classes take
23# Formatters on construction and outputs any results using
24# Formatter methods.  These classes are only really for use by
25# the hirb.rb HBase Shell script; they don't make much sense elsewhere.
26# For example, the exists method on Admin class prints to the formatter
27# whether the table exists and returns nil regardless.
28include Java
29
30include_class('java.lang.Integer') {|package,name| "J#{name}" }
31include_class('java.lang.Long') {|package,name| "J#{name}" }
32include_class('java.lang.Boolean') {|package,name| "J#{name}" }
33
34module HBaseConstants
35  COLUMN = "COLUMN"
36  COLUMNS = "COLUMNS"
37  TIMESTAMP = "TIMESTAMP"
38  TIMERANGE = "TIMERANGE"
39  NAME = org.apache.hadoop.hbase.HConstants::NAME
40  VERSIONS = org.apache.hadoop.hbase.HConstants::VERSIONS
41  IN_MEMORY = org.apache.hadoop.hbase.HConstants::IN_MEMORY
42  METADATA = org.apache.hadoop.hbase.HConstants::METADATA
43  STOPROW = "STOPROW"
44  STARTROW = "STARTROW"
45  ROWPREFIXFILTER = "ROWPREFIXFILTER"
46  ENDROW = STOPROW
47  RAW = "RAW"
48  LIMIT = "LIMIT"
49  METHOD = "METHOD"
50  MAXLENGTH = "MAXLENGTH"
51  CACHE_BLOCKS = "CACHE_BLOCKS"
52  ALL_METRICS = "ALL_METRICS"
53  METRICS = "METRICS"
54  REVERSED = "REVERSED"
55  REPLICATION_SCOPE = "REPLICATION_SCOPE"
56  INTERVAL = 'INTERVAL'
57  CACHE = 'CACHE'
58  FILTER = 'FILTER'
59  SPLITS = 'SPLITS'
60  SPLITS_FILE = 'SPLITS_FILE'
61  SPLITALGO = 'SPLITALGO'
62  NUMREGIONS = 'NUMREGIONS'
63  REGION_REPLICATION = 'REGION_REPLICATION'
64  REGION_REPLICA_ID = 'REGION_REPLICA_ID'
65  CONFIGURATION = org.apache.hadoop.hbase.HConstants::CONFIGURATION
66  ATTRIBUTES="ATTRIBUTES"
67  VISIBILITY="VISIBILITY"
68  AUTHORIZATIONS = "AUTHORIZATIONS"
69  SKIP_FLUSH = 'SKIP_FLUSH'
70  CONSISTENCY = "CONSISTENCY"
71  ENDPOINT_CLASSNAME = 'ENDPOINT_CLASSNAME'
72  CLUSTER_KEY = 'CLUSTER_KEY'
73  TABLE_CFS = 'TABLE_CFS'
74  CONFIG = 'CONFIG'
75  DATA = 'DATA'
76  USER = 'USER'
77  TABLE = 'TABLE'
78  NAMESPACE = 'NAMESPACE'
79  TYPE = 'TYPE'
80  NONE = 'NONE'
81  VALUE = 'VALUE'
82
83  # Load constants from hbase java API
84  def self.promote_constants(constants)
85    # The constants to import are all in uppercase
86    constants.each do |c|
87      next if c =~ /DEFAULT_.*/ || c != c.upcase
88      next if eval("defined?(#{c})")
89      eval("#{c} = '#{c}'")
90    end
91  end
92
93  promote_constants(org.apache.hadoop.hbase.HColumnDescriptor.constants)
94  promote_constants(org.apache.hadoop.hbase.HTableDescriptor.constants)
95end
96
97# Include classes definition
98require 'hbase/hbase'
99require 'hbase/admin'
100require 'hbase/table'
101require 'hbase/quotas'
102require 'hbase/replication_admin'
103require 'hbase/security'
104require 'hbase/visibility_labels'
105
106
107include HBaseQuotasConstants