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 /** Parameter name for the master type being backup (waits for primary to go inactive). */ 85 public static final String MASTER_TYPE_BACKUP = "hbase.master.backup"; 86 87 /** by default every master is a possible primary master unless the conf explicitly overrides it */ 88 public static final boolean DEFAULT_MASTER_TYPE_BACKUP = false; 89 90 /** Name of ZooKeeper quorum configuration parameter. */ 91 public static final String ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum"; 92 93 /** Name of ZooKeeper config file in conf/ directory. */ 94 public static final String ZOOKEEPER_CONFIG_NAME = "zoo.cfg"; 95 96 /** Parameter name for number of times to retry writes to ZooKeeper. */ 97 public static final String ZOOKEEPER_RETRIES = "zookeeper.retries"; 98 /** Default number of times to retry writes to ZooKeeper. */ 99 public static final int DEFAULT_ZOOKEEPER_RETRIES = 5; 100 101 /** Parameter name for ZooKeeper pause between retries. In milliseconds. */ 102 public static final String ZOOKEEPER_PAUSE = "zookeeper.pause"; 103 /** Default ZooKeeper pause value. In milliseconds. */ 104 public static final int DEFAULT_ZOOKEEPER_PAUSE = 2 * 1000; 105 106 /** default client port that the zookeeper listens on */ 107 public static final int DEFAULT_ZOOKEPER_CLIENT_PORT = 2181; 108 109 /** Parameter name for the root dir in ZK for this cluster */ 110 public static final String ZOOKEEPER_ZNODE_PARENT = "zookeeper.znode.parent"; 111 112 public static final String DEFAULT_ZOOKEEPER_ZNODE_PARENT = "/hbase"; 113 114 /** Parameter name for port region server listens on. */ 115 public static final String REGIONSERVER_PORT = "hbase.regionserver.port"; 116 117 /** Default port region server listens on. */ 118 public static final int DEFAULT_REGIONSERVER_PORT = 60020; 119 120 /** default port for region server web api */ 121 public static final int DEFAULT_REGIONSERVER_INFOPORT = 60030; 122 123 /** Parameter name for what region server interface to use. */ 124 public static final String REGION_SERVER_CLASS = "hbase.regionserver.class"; 125 126 /** Parameter name for what region server implementation to use. */ 127 public static final String REGION_SERVER_IMPL= "hbase.regionserver.impl"; 128 129 /** Default region server interface class name. */ 130 public static final String DEFAULT_REGION_SERVER_CLASS = HRegionInterface.class.getName(); 131 132 /** Parameter name for how often threads should wake up */ 133 public static final String THREAD_WAKE_FREQUENCY = "hbase.server.thread.wakefrequency"; 134 135 /** Parameter name for how often a region should should perform a major compaction */ 136 public static final String MAJOR_COMPACTION_PERIOD = "hbase.hregion.majorcompaction"; 137 138 /** Parameter name for HBase instance root directory */ 139 public static final String HBASE_DIR = "hbase.rootdir"; 140 141 /** Used to construct the name of the log directory for a region server 142 * Use '.' as a special character to seperate the log files from table data */ 143 public static final String HREGION_LOGDIR_NAME = ".logs"; 144 145 /** Like the previous, but for old logs that are about to be deleted */ 146 public static final String HREGION_OLDLOGDIR_NAME = ".oldlogs"; 147 148 /** Used to construct the name of the compaction directory during compaction */ 149 public static final String HREGION_COMPACTIONDIR_NAME = "compaction.dir"; 150 151 /** Default maximum file size */ 152 public static final long DEFAULT_MAX_FILE_SIZE = 256 * 1024 * 1024; 153 154 /** Default size of a reservation block */ 155 public static final int DEFAULT_SIZE_RESERVATION_BLOCK = 1024 * 1024 * 5; 156 157 /** Maximum value length, enforced on KeyValue construction */ 158 public static final int MAXIMUM_VALUE_LENGTH = Integer.MAX_VALUE; 159 160 // Always store the location of the root table's HRegion. 161 // This HRegion is never split. 162 163 // region name = table + startkey + regionid. This is the row key. 164 // each row in the root and meta tables describes exactly 1 region 165 // Do we ever need to know all the information that we are storing? 166 167 // Note that the name of the root table starts with "-" and the name of the 168 // meta table starts with "." Why? it's a trick. It turns out that when we 169 // store region names in memory, we use a SortedMap. Since "-" sorts before 170 // "." (and since no other table name can start with either of these 171 // characters, the root region will always be the first entry in such a Map, 172 // followed by all the meta regions (which will be ordered by their starting 173 // row key as well), followed by all user tables. So when the Master is 174 // choosing regions to assign, it will always choose the root region first, 175 // followed by the meta regions, followed by user regions. Since the root 176 // and meta regions always need to be on-line, this ensures that they will 177 // be the first to be reassigned if the server(s) they are being served by 178 // should go down. 179 180 181 // 182 // New stuff. Making a slow transition. 183 // 184 185 /** The root table's name.*/ 186 public static final byte [] ROOT_TABLE_NAME = Bytes.toBytes("-ROOT-"); 187 188 /** The META table's name. */ 189 public static final byte [] META_TABLE_NAME = Bytes.toBytes(".META."); 190 191 /** delimiter used between portions of a region name */ 192 public static final int META_ROW_DELIMITER = ','; 193 194 /** The catalog family as a string*/ 195 public static final String CATALOG_FAMILY_STR = "info"; 196 197 /** The catalog family */ 198 public static final byte [] CATALOG_FAMILY = Bytes.toBytes(CATALOG_FAMILY_STR); 199 200 /** The catalog historian family */ 201 public static final byte [] CATALOG_HISTORIAN_FAMILY = Bytes.toBytes("historian"); 202 203 /** The regioninfo column qualifier */ 204 public static final byte [] REGIONINFO_QUALIFIER = Bytes.toBytes("regioninfo"); 205 206 /** The server column qualifier */ 207 public static final byte [] SERVER_QUALIFIER = Bytes.toBytes("server"); 208 209 /** The startcode column qualifier */ 210 public static final byte [] STARTCODE_QUALIFIER = Bytes.toBytes("serverstartcode"); 211 212 /** The lower-half split region column qualifier */ 213 public static final byte [] SPLITA_QUALIFIER = Bytes.toBytes("splitA"); 214 215 /** The upper-half split region column qualifier */ 216 public static final byte [] SPLITB_QUALIFIER = Bytes.toBytes("splitB"); 217 218 // Other constants 219 220 /** 221 * An empty instance. 222 */ 223 public static final byte [] EMPTY_BYTE_ARRAY = new byte [0]; 224 225 /** 226 * Used by scanners, etc when they want to start at the beginning of a region 227 */ 228 public static final byte [] EMPTY_START_ROW = EMPTY_BYTE_ARRAY; 229 230 /** 231 * Last row in a table. 232 */ 233 public static final byte [] EMPTY_END_ROW = EMPTY_START_ROW; 234 235 /** 236 * Used by scanners and others when they're trying to detect the end of a 237 * table 238 */ 239 public static final byte [] LAST_ROW = EMPTY_BYTE_ARRAY; 240 241 /** 242 * Max length a row can have because of the limitation in TFile. 243 */ 244 public static final int MAX_ROW_LENGTH = Short.MAX_VALUE; 245 246 /** When we encode strings, we always specify UTF8 encoding */ 247 public static final String UTF8_ENCODING = "UTF-8"; 248 249 /** 250 * Timestamp to use when we want to refer to the latest cell. 251 * This is the timestamp sent by clients when no timestamp is specified on 252 * commit. 253 */ 254 public static final long LATEST_TIMESTAMP = Long.MAX_VALUE; 255 256 /** 257 * LATEST_TIMESTAMP in bytes form 258 */ 259 public static final byte [] LATEST_TIMESTAMP_BYTES = Bytes.toBytes(LATEST_TIMESTAMP); 260 261 /** 262 * Define for 'return-all-versions'. 263 */ 264 public static final int ALL_VERSIONS = Integer.MAX_VALUE; 265 266 /** 267 * Unlimited time-to-live. 268 */ 269 // public static final int FOREVER = -1; 270 public static final int FOREVER = Integer.MAX_VALUE; 271 272 /** 273 * Seconds in a week 274 */ 275 public static final int WEEK_IN_SECONDS = 7 * 24 * 3600; 276 277 //TODO: HBASE_CLIENT_RETRIES_NUMBER_KEY is only used by TestMigrate. Move it 278 // there. 279 public static final String HBASE_CLIENT_RETRIES_NUMBER_KEY = 280 "hbase.client.retries.number"; 281 282 //TODO: although the following are referenced widely to format strings for 283 // the shell. They really aren't a part of the public API. It would be 284 // nice if we could put them somewhere where they did not need to be 285 // public. They could have package visibility 286 public static final String NAME = "NAME"; 287 public static final String VERSIONS = "VERSIONS"; 288 public static final String IN_MEMORY = "IN_MEMORY"; 289 290 /** 291 * This is a retry backoff multiplier table similar to the BSD TCP syn 292 * backoff table, a bit more aggressive than simple exponential backoff. 293 */ 294 public static int RETRY_BACKOFF[] = { 1, 1, 1, 2, 2, 4, 4, 8, 16, 32 }; 295 296 public static final String REGION_IMPL = "hbase.hregion.impl"; 297 298 /** modifyTable op for replacing the table descriptor */ 299 public static enum Modify { 300 CLOSE_REGION, 301 TABLE_COMPACT, 302 TABLE_FLUSH, 303 TABLE_MAJOR_COMPACT, 304 TABLE_SET_HTD, 305 TABLE_SPLIT 306 } 307 308 /** 309 * Scope tag for locally scoped data. 310 * This data will not be replicated. 311 */ 312 public static final int REPLICATION_SCOPE_LOCAL = 0; 313 314 /** 315 * Scope tag for globally scoped data. 316 * This data will be replicated to all peers. 317 */ 318 public static final int REPLICATION_SCOPE_GLOBAL = 1; 319 320 /** 321 * Default cluster ID, cannot be used to identify a cluster so a key with 322 * this value means it wasn't meant for replication. 323 */ 324 public static final byte DEFAULT_CLUSTER_ID = 0; 325 326 /** 327 * Parameter name for maximum number of bytes returned when calling a 328 * scanner's next method. 329 */ 330 public static String HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY = "hbase.client.scanner.max.result.size"; 331 332 /** 333 * Maximum number of bytes returned when calling a scanner's next method. 334 * Note that when a single row is larger than this limit the row is still 335 * returned completely. 336 * 337 * The default value is unlimited. 338 */ 339 public static long DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE = Long.MAX_VALUE; 340 341 342 /** 343 * HRegion server lease period in milliseconds. Clients must report in within this period 344 * else they are considered dead. Unit measured in ms (milliseconds). 345 */ 346 public static String HBASE_REGIONSERVER_LEASE_PERIOD_KEY = "hbase.regionserver.lease.period"; 347 348 349 /** 350 * Default value of {@link #HBASE_REGIONSERVER_LEASE_PERIOD_KEY}. 351 */ 352 public static long DEFAULT_HBASE_REGIONSERVER_LEASE_PERIOD = 60000; 353 354 public static final String 355 REPLICATION_ENABLE_KEY = "hbase.replication"; 356 357 private HConstants() { 358 // Can't be instantiated with this ctor. 359 } 360 }