1 /** 2 * Copyright 2010 The Apache Software Foundation 3 * 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 package org.apache.hadoop.hbase; 21 22 import org.apache.hadoop.hbase.ipc.HRegionInterface; 23 import org.apache.hadoop.hbase.util.Bytes; 24 25 /** 26 * HConstants holds a bunch of HBase-related constants 27 */ 28 public final class HConstants { 29 /** 30 * Status codes used for return values of bulk operations. 31 */ 32 public enum OperationStatusCode { 33 NOT_RUN, 34 SUCCESS, 35 BAD_FAMILY, 36 FAILURE; 37 } 38 39 /** long constant for zero */ 40 public static final Long ZERO_L = Long.valueOf(0L); 41 public static final String NINES = "99999999999999"; 42 public static final String ZEROES = "00000000000000"; 43 44 // For migration 45 46 /** name of version file */ 47 public static final String VERSION_FILE_NAME = "hbase.version"; 48 49 /** 50 * Current version of file system. 51 * Version 4 supports only one kind of bloom filter. 52 * Version 5 changes versions in catalog table regions. 53 * Version 6 enables blockcaching on catalog tables. 54 * Version 7 introduces hfile -- hbase 0.19 to 0.20.. 55 */ 56 // public static final String FILE_SYSTEM_VERSION = "6"; 57 public static final String FILE_SYSTEM_VERSION = "7"; 58 59 // Configuration parameters 60 61 //TODO: Is having HBase homed on port 60k OK? 62 63 /** Cluster is in distributed mode or not */ 64 public static final String CLUSTER_DISTRIBUTED = "hbase.cluster.distributed"; 65 66 /** Cluster is standalone or pseudo-distributed */ 67 public static final String CLUSTER_IS_LOCAL = "false"; 68 69 /** Cluster is fully-distributed */ 70 public static final String CLUSTER_IS_DISTRIBUTED = "true"; 71 72 /** default host address */ 73 public static final String DEFAULT_HOST = "0.0.0.0"; 74 75 /** Parameter name for port master listens on. */ 76 public static final String MASTER_PORT = "hbase.master.port"; 77 78 /** default port that the master listens on */ 79 public static final int DEFAULT_MASTER_PORT = 60000; 80 81 /** default port for master web api */ 82 public static final int DEFAULT_MASTER_INFOPORT = 60010; 83 84 /** Name of ZooKeeper quorum configuration parameter. */ 85 public static final String ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum"; 86 87 /** Name of ZooKeeper config file in conf/ directory. */ 88 public static final String ZOOKEEPER_CONFIG_NAME = "zoo.cfg"; 89 90 /** Parameter name for number of times to retry writes to ZooKeeper. */ 91 public static final String ZOOKEEPER_RETRIES = "zookeeper.retries"; 92 /** Default number of times to retry writes to ZooKeeper. */ 93 public static final int DEFAULT_ZOOKEEPER_RETRIES = 5; 94 95 /** Parameter name for ZooKeeper pause between retries. In milliseconds. */ 96 public static final String ZOOKEEPER_PAUSE = "zookeeper.pause"; 97 /** Default ZooKeeper pause value. In milliseconds. */ 98 public static final int DEFAULT_ZOOKEEPER_PAUSE = 2 * 1000; 99 100 /** default client port that the zookeeper listens on */ 101 public static final int DEFAULT_ZOOKEPER_CLIENT_PORT = 2181; 102 103 /** Parameter name for the root dir in ZK for this cluster */ 104 public static final String ZOOKEEPER_ZNODE_PARENT = "zookeeper.znode.parent"; 105 106 public static final String DEFAULT_ZOOKEEPER_ZNODE_PARENT = "/hbase"; 107 108 /** Parameter name for port region server listens on. */ 109 public static final String REGIONSERVER_PORT = "hbase.regionserver.port"; 110 111 /** Default port region server listens on. */ 112 public static final int DEFAULT_REGIONSERVER_PORT = 60020; 113 114 /** default port for region server web api */ 115 public static final int DEFAULT_REGIONSERVER_INFOPORT = 60030; 116 117 /** Parameter name for what region server interface to use. */ 118 public static final String REGION_SERVER_CLASS = "hbase.regionserver.class"; 119 120 /** Parameter name for what region server implementation to use. */ 121 public static final String REGION_SERVER_IMPL= "hbase.regionserver.impl"; 122 123 /** Default region server interface class name. */ 124 public static final String DEFAULT_REGION_SERVER_CLASS = HRegionInterface.class.getName(); 125 126 /** Parameter name for how often threads should wake up */ 127 public static final String THREAD_WAKE_FREQUENCY = "hbase.server.thread.wakefrequency"; 128 129 /** Parameter name for how often a region should should perform a major compaction */ 130 public static final String MAJOR_COMPACTION_PERIOD = "hbase.hregion.majorcompaction"; 131 132 /** Parameter name for HBase instance root directory */ 133 public static final String HBASE_DIR = "hbase.rootdir"; 134 135 /** Used to construct the name of the log directory for a region server 136 * Use '.' as a special character to seperate the log files from table data */ 137 public static final String HREGION_LOGDIR_NAME = ".logs"; 138 139 /** Like the previous, but for old logs that are about to be deleted */ 140 public static final String HREGION_OLDLOGDIR_NAME = ".oldlogs"; 141 142 /** Used to construct the name of the compaction directory during compaction */ 143 public static final String HREGION_COMPACTIONDIR_NAME = "compaction.dir"; 144 145 /** Default maximum file size */ 146 public static final long DEFAULT_MAX_FILE_SIZE = 256 * 1024 * 1024; 147 148 /** Default size of a reservation block */ 149 public static final int DEFAULT_SIZE_RESERVATION_BLOCK = 1024 * 1024 * 5; 150 151 /** Maximum value length, enforced on KeyValue construction */ 152 public static final int MAXIMUM_VALUE_LENGTH = Integer.MAX_VALUE; 153 154 // Always store the location of the root table's HRegion. 155 // This HRegion is never split. 156 157 // region name = table + startkey + regionid. This is the row key. 158 // each row in the root and meta tables describes exactly 1 region 159 // Do we ever need to know all the information that we are storing? 160 161 // Note that the name of the root table starts with "-" and the name of the 162 // meta table starts with "." Why? it's a trick. It turns out that when we 163 // store region names in memory, we use a SortedMap. Since "-" sorts before 164 // "." (and since no other table name can start with either of these 165 // characters, the root region will always be the first entry in such a Map, 166 // followed by all the meta regions (which will be ordered by their starting 167 // row key as well), followed by all user tables. So when the Master is 168 // choosing regions to assign, it will always choose the root region first, 169 // followed by the meta regions, followed by user regions. Since the root 170 // and meta regions always need to be on-line, this ensures that they will 171 // be the first to be reassigned if the server(s) they are being served by 172 // should go down. 173 174 175 // 176 // New stuff. Making a slow transition. 177 // 178 179 /** The root table's name.*/ 180 public static final byte [] ROOT_TABLE_NAME = Bytes.toBytes("-ROOT-"); 181 182 /** The META table's name. */ 183 public static final byte [] META_TABLE_NAME = Bytes.toBytes(".META."); 184 185 /** delimiter used between portions of a region name */ 186 public static final int META_ROW_DELIMITER = ','; 187 188 /** The catalog family as a string*/ 189 public static final String CATALOG_FAMILY_STR = "info"; 190 191 /** The catalog family */ 192 public static final byte [] CATALOG_FAMILY = Bytes.toBytes(CATALOG_FAMILY_STR); 193 194 /** The catalog historian family */ 195 public static final byte [] CATALOG_HISTORIAN_FAMILY = Bytes.toBytes("historian"); 196 197 /** The regioninfo column qualifier */ 198 public static final byte [] REGIONINFO_QUALIFIER = Bytes.toBytes("regioninfo"); 199 200 /** The server column qualifier */ 201 public static final byte [] SERVER_QUALIFIER = Bytes.toBytes("server"); 202 203 /** The startcode column qualifier */ 204 public static final byte [] STARTCODE_QUALIFIER = Bytes.toBytes("serverstartcode"); 205 206 /** The lower-half split region column qualifier */ 207 public static final byte [] SPLITA_QUALIFIER = Bytes.toBytes("splitA"); 208 209 /** The upper-half split region column qualifier */ 210 public static final byte [] SPLITB_QUALIFIER = Bytes.toBytes("splitB"); 211 212 // Other constants 213 214 /** 215 * An empty instance. 216 */ 217 public static final byte [] EMPTY_BYTE_ARRAY = new byte [0]; 218 219 /** 220 * Used by scanners, etc when they want to start at the beginning of a region 221 */ 222 public static final byte [] EMPTY_START_ROW = EMPTY_BYTE_ARRAY; 223 224 /** 225 * Last row in a table. 226 */ 227 public static final byte [] EMPTY_END_ROW = EMPTY_START_ROW; 228 229 /** 230 * Used by scanners and others when they're trying to detect the end of a 231 * table 232 */ 233 public static final byte [] LAST_ROW = EMPTY_BYTE_ARRAY; 234 235 /** 236 * Max length a row can have because of the limitation in TFile. 237 */ 238 public static final int MAX_ROW_LENGTH = Short.MAX_VALUE; 239 240 /** When we encode strings, we always specify UTF8 encoding */ 241 public static final String UTF8_ENCODING = "UTF-8"; 242 243 /** 244 * Timestamp to use when we want to refer to the latest cell. 245 * This is the timestamp sent by clients when no timestamp is specified on 246 * commit. 247 */ 248 public static final long LATEST_TIMESTAMP = Long.MAX_VALUE; 249 250 /** 251 * LATEST_TIMESTAMP in bytes form 252 */ 253 public static final byte [] LATEST_TIMESTAMP_BYTES = Bytes.toBytes(LATEST_TIMESTAMP); 254 255 /** 256 * Define for 'return-all-versions'. 257 */ 258 public static final int ALL_VERSIONS = Integer.MAX_VALUE; 259 260 /** 261 * Unlimited time-to-live. 262 */ 263 // public static final int FOREVER = -1; 264 public static final int FOREVER = Integer.MAX_VALUE; 265 266 /** 267 * Seconds in a week 268 */ 269 public static final int WEEK_IN_SECONDS = 7 * 24 * 3600; 270 271 //TODO: HBASE_CLIENT_RETRIES_NUMBER_KEY is only used by TestMigrate. Move it 272 // there. 273 public static final String HBASE_CLIENT_RETRIES_NUMBER_KEY = 274 "hbase.client.retries.number"; 275 276 //TODO: although the following are referenced widely to format strings for 277 // the shell. They really aren't a part of the public API. It would be 278 // nice if we could put them somewhere where they did not need to be 279 // public. They could have package visibility 280 public static final String NAME = "NAME"; 281 public static final String VERSIONS = "VERSIONS"; 282 public static final String IN_MEMORY = "IN_MEMORY"; 283 284 /** 285 * This is a retry backoff multiplier table similar to the BSD TCP syn 286 * backoff table, a bit more aggressive than simple exponential backoff. 287 */ 288 public static int RETRY_BACKOFF[] = { 1, 1, 1, 2, 2, 4, 4, 8, 16, 32 }; 289 290 public static final String REGION_IMPL = "hbase.hregion.impl"; 291 292 /** modifyTable op for replacing the table descriptor */ 293 public static enum Modify { 294 CLOSE_REGION, 295 TABLE_COMPACT, 296 TABLE_FLUSH, 297 TABLE_MAJOR_COMPACT, 298 TABLE_SET_HTD, 299 TABLE_SPLIT 300 } 301 302 /** 303 * Scope tag for locally scoped data. 304 * This data will not be replicated. 305 */ 306 public static final int REPLICATION_SCOPE_LOCAL = 0; 307 308 /** 309 * Scope tag for globally scoped data. 310 * This data will be replicated to all peers. 311 */ 312 public static final int REPLICATION_SCOPE_GLOBAL = 1; 313 314 /** 315 * Default cluster ID, cannot be used to identify a cluster so a key with 316 * this value means it wasn't meant for replication. 317 */ 318 public static final byte DEFAULT_CLUSTER_ID = 0; 319 320 /** 321 * Parameter name for maximum number of bytes returned when calling a 322 * scanner's next method. 323 */ 324 public static String HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY = "hbase.client.scanner.max.result.size"; 325 326 /** 327 * Maximum number of bytes returned when calling a scanner's next method. 328 * Note that when a single row is larger than this limit the row is still 329 * returned completely. 330 * 331 * The default value is unlimited. 332 */ 333 public static long DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE = Long.MAX_VALUE; 334 335 336 /** 337 * HRegion server lease period in milliseconds. Clients must report in within this period 338 * else they are considered dead. Unit measured in ms (milliseconds). 339 */ 340 public static String HBASE_REGIONSERVER_LEASE_PERIOD_KEY = "hbase.regionserver.lease.period"; 341 342 343 /** 344 * Default value of {@link #HBASE_REGIONSERVER_LEASE_PERIOD_KEY}. 345 */ 346 public static long DEFAULT_HBASE_REGIONSERVER_LEASE_PERIOD = 60000; 347 348 public static final String 349 REPLICATION_ENABLE_KEY = "hbase.replication"; 350 351 private HConstants() { 352 // Can't be instantiated with this ctor. 353 } 354 }