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