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.hadoop.hbase;
19  
20  import static org.apache.hadoop.hbase.io.hfile.BlockType.MAGIC_LENGTH;
21  
22  import java.nio.ByteBuffer;
23  import java.nio.charset.Charset;
24  import java.util.Arrays;
25  import java.util.Collections;
26  import java.util.List;
27  import java.util.UUID;
28  import java.util.regex.Pattern;
29  
30  import org.apache.commons.lang.ArrayUtils;
31  import org.apache.hadoop.hbase.classification.InterfaceAudience;
32  import org.apache.hadoop.hbase.classification.InterfaceStability;
33  import org.apache.hadoop.hbase.util.Bytes;
34  
35  /**
36   * HConstants holds a bunch of HBase-related constants
37   */
38  @InterfaceAudience.Public
39  @InterfaceStability.Stable
40  public final class HConstants {
41    // NOTICE!!!! Please do not add a constants here, unless they are referenced by a lot of classes.
42  
43    //Bytes.UTF8_ENCODING should be updated if this changed
44    /** When we encode strings, we always specify UTF8 encoding */
45    public static final String UTF8_ENCODING = "UTF-8";
46  
47    //Bytes.UTF8_CHARSET should be updated if this changed
48    /** When we encode strings, we always specify UTF8 encoding */
49    public static final Charset UTF8_CHARSET = Charset.forName(UTF8_ENCODING);
50    /**
51     * Default block size for an HFile.
52     */
53    public final static int DEFAULT_BLOCKSIZE = 64 * 1024;
54  
55    /** Used as a magic return value while optimized index key feature enabled(HBASE-7845) */
56    public final static int INDEX_KEY_MAGIC = -2;
57    /*
58       * Name of directory that holds recovered edits written by the wal log
59       * splitting code, one per region
60       */
61    public static final String RECOVERED_EDITS_DIR = "recovered.edits";
62    /**
63     * The first four bytes of Hadoop RPC connections
64     */
65    public static final ByteBuffer RPC_HEADER = ByteBuffer.wrap("HBas".getBytes());
66    public static final byte RPC_CURRENT_VERSION = 0;
67  
68    // HFileBlock constants.
69  
70    /** The size data structures with minor version is 0 */
71    public static final int HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM = MAGIC_LENGTH + 2 * Bytes.SIZEOF_INT
72        + Bytes.SIZEOF_LONG;
73    /** The size of a version 2 HFile block header, minor version 1.
74     * There is a 1 byte checksum type, followed by a 4 byte bytesPerChecksum
75     * followed by another 4 byte value to store sizeofDataOnDisk.
76     */
77    public static final int HFILEBLOCK_HEADER_SIZE = HFILEBLOCK_HEADER_SIZE_NO_CHECKSUM +
78      Bytes.SIZEOF_BYTE + 2 * Bytes.SIZEOF_INT;
79    /** Just an array of bytes of the right size. */
80    public static final byte[] HFILEBLOCK_DUMMY_HEADER = new byte[HFILEBLOCK_HEADER_SIZE];
81  
82    //End HFileBlockConstants.
83  
84    /**
85     * Status codes used for return values of bulk operations.
86     */
87    public enum OperationStatusCode {
88      NOT_RUN,
89      SUCCESS,
90      BAD_FAMILY,
91      SANITY_CHECK_FAILURE,
92      FAILURE;
93    }
94  
95    /** long constant for zero */
96    public static final Long ZERO_L = Long.valueOf(0L);
97    public static final String NINES = "99999999999999";
98    public static final String ZEROES = "00000000000000";
99  
100   // For migration
101 
102   /** name of version file */
103   public static final String VERSION_FILE_NAME = "hbase.version";
104 
105   /**
106    * Current version of file system.
107    * Version 4 supports only one kind of bloom filter.
108    * Version 5 changes versions in catalog table regions.
109    * Version 6 enables blockcaching on catalog tables.
110    * Version 7 introduces hfile -- hbase 0.19 to 0.20..
111    * Version 8 introduces namespace
112    */
113   // public static final String FILE_SYSTEM_VERSION = "6";
114   public static final String FILE_SYSTEM_VERSION = "8";
115 
116   // Configuration parameters
117 
118   //TODO: Is having HBase homed on port 60k OK?
119 
120   /** Cluster is in distributed mode or not */
121   public static final String CLUSTER_DISTRIBUTED = "hbase.cluster.distributed";
122 
123   /** Config for pluggable load balancers */
124   public static final String HBASE_MASTER_LOADBALANCER_CLASS = "hbase.master.loadbalancer.class";
125 
126   /** Cluster is standalone or pseudo-distributed */
127   public static final boolean CLUSTER_IS_LOCAL = false;
128 
129   /** Cluster is fully-distributed */
130   public static final boolean CLUSTER_IS_DISTRIBUTED = true;
131 
132   /** Default value for cluster distributed mode */
133   public static final boolean DEFAULT_CLUSTER_DISTRIBUTED = CLUSTER_IS_LOCAL;
134 
135   /** default host address */
136   public static final String DEFAULT_HOST = "0.0.0.0";
137 
138   /** Parameter name for port master listens on. */
139   public static final String MASTER_PORT = "hbase.master.port";
140 
141   /** default port that the master listens on */
142   public static final int DEFAULT_MASTER_PORT = 60000;
143 
144   /** default port for master web api */
145   public static final int DEFAULT_MASTER_INFOPORT = 60010;
146 
147   /** Configuration key for master web API port */
148   public static final String MASTER_INFO_PORT = "hbase.master.info.port";
149 
150   /** Parameter name for the master type being backup (waits for primary to go inactive). */
151   public static final String MASTER_TYPE_BACKUP = "hbase.master.backup";
152 
153   /** by default every master is a possible primary master unless the conf explicitly overrides it */
154   public static final boolean DEFAULT_MASTER_TYPE_BACKUP = false;
155 
156   /** Name of ZooKeeper quorum configuration parameter. */
157   public static final String ZOOKEEPER_QUORUM = "hbase.zookeeper.quorum";
158 
159   /** Name of ZooKeeper config file in conf/ directory. */
160   public static final String ZOOKEEPER_CONFIG_NAME = "zoo.cfg";
161 
162   /** Common prefix of ZooKeeper configuration properties */
163   public static final String ZK_CFG_PROPERTY_PREFIX =
164       "hbase.zookeeper.property.";
165 
166   public static final int ZK_CFG_PROPERTY_PREFIX_LEN =
167       ZK_CFG_PROPERTY_PREFIX.length();
168 
169   /**
170    * The ZK client port key in the ZK properties map. The name reflects the
171    * fact that this is not an HBase configuration key.
172    */
173   public static final String CLIENT_PORT_STR = "clientPort";
174 
175   /** Parameter name for the client port that the zookeeper listens on */
176   public static final String ZOOKEEPER_CLIENT_PORT =
177       ZK_CFG_PROPERTY_PREFIX + CLIENT_PORT_STR;
178 
179   /** Default client port that the zookeeper listens on */
180   public static final int DEFAULT_ZOOKEPER_CLIENT_PORT = 2181;
181 
182   /** Parameter name for the wait time for the recoverable zookeeper */
183   public static final String ZOOKEEPER_RECOVERABLE_WAITTIME = "hbase.zookeeper.recoverable.waittime";
184 
185   /** Default wait time for the recoverable zookeeper */
186   public static final long DEFAULT_ZOOKEPER_RECOVERABLE_WAITIME = 10000;
187 
188   /** Parameter name for the root dir in ZK for this cluster */
189   public static final String ZOOKEEPER_ZNODE_PARENT = "zookeeper.znode.parent";
190 
191   public static final String DEFAULT_ZOOKEEPER_ZNODE_PARENT = "/hbase";
192 
193   /**
194    * Parameter name for the limit on concurrent client-side zookeeper
195    * connections
196    */
197   public static final String ZOOKEEPER_MAX_CLIENT_CNXNS =
198       ZK_CFG_PROPERTY_PREFIX + "maxClientCnxns";
199 
200   /** Parameter name for the ZK data directory */
201   public static final String ZOOKEEPER_DATA_DIR =
202       ZK_CFG_PROPERTY_PREFIX + "dataDir";
203 
204   /** Default limit on concurrent client-side zookeeper connections */
205   public static final int DEFAULT_ZOOKEPER_MAX_CLIENT_CNXNS = 300;
206 
207   /** Configuration key for ZooKeeper session timeout */
208   public static final String ZK_SESSION_TIMEOUT = "zookeeper.session.timeout";
209 
210   /** Default value for ZooKeeper session timeout */
211   public static final int DEFAULT_ZK_SESSION_TIMEOUT = 180 * 1000;
212 
213   /** Configuration key for whether to use ZK.multi */
214   public static final String ZOOKEEPER_USEMULTI = "hbase.zookeeper.useMulti";
215 
216   /** Parameter name for port region server listens on. */
217   public static final String REGIONSERVER_PORT = "hbase.regionserver.port";
218 
219   /** Default port region server listens on. */
220   public static final int DEFAULT_REGIONSERVER_PORT = 60020;
221 
222   /** default port for region server web api */
223   public static final int DEFAULT_REGIONSERVER_INFOPORT = 60030;
224 
225   /** A configuration key for regionserver info port */
226   public static final String REGIONSERVER_INFO_PORT =
227     "hbase.regionserver.info.port";
228 
229   /** A flag that enables automatic selection of regionserver info port */
230   public static final String REGIONSERVER_INFO_PORT_AUTO =
231       REGIONSERVER_INFO_PORT + ".auto";
232 
233   /** Parameter name for what region server implementation to use. */
234   public static final String REGION_SERVER_IMPL= "hbase.regionserver.impl";
235 
236   /** Parameter name for what master implementation to use. */
237   public static final String MASTER_IMPL= "hbase.master.impl";
238 
239   /** Parameter name for what hbase client implementation to use. */
240   public static final String HBASECLIENT_IMPL= "hbase.hbaseclient.impl";
241 
242   /** Parameter name for how often threads should wake up */
243   public static final String THREAD_WAKE_FREQUENCY = "hbase.server.thread.wakefrequency";
244 
245   /** Default value for thread wake frequency */
246   public static final int DEFAULT_THREAD_WAKE_FREQUENCY = 10 * 1000;
247 
248   /** Parameter name for how often we should try to write a version file, before failing */
249   public static final String VERSION_FILE_WRITE_ATTEMPTS = "hbase.server.versionfile.writeattempts";
250 
251   /** Parameter name for how often we should try to write a version file, before failing */
252   public static final int DEFAULT_VERSION_FILE_WRITE_ATTEMPTS = 3;
253 
254   /** Parameter name for how often a region should should perform a major compaction */
255   public static final String MAJOR_COMPACTION_PERIOD = "hbase.hregion.majorcompaction";
256 
257   /** Parameter name for the maximum batch of KVs to be used in flushes and compactions */
258   public static final String COMPACTION_KV_MAX = "hbase.hstore.compaction.kv.max";
259   public static final int COMPACTION_KV_MAX_DEFAULT = 10;
260 
261   /** Parameter name for HBase instance root directory */
262   public static final String HBASE_DIR = "hbase.rootdir";
263 
264   /** Parameter name for HBase client IPC pool type */
265   public static final String HBASE_CLIENT_IPC_POOL_TYPE = "hbase.client.ipc.pool.type";
266 
267   /** Parameter name for HBase client IPC pool size */
268   public static final String HBASE_CLIENT_IPC_POOL_SIZE = "hbase.client.ipc.pool.size";
269 
270   /** Parameter name for HBase client operation timeout, which overrides RPC timeout */
271   public static final String HBASE_CLIENT_OPERATION_TIMEOUT = "hbase.client.operation.timeout";
272 
273   /** Parameter name for HBase client operation timeout, which overrides RPC timeout */
274   public static final String HBASE_CLIENT_META_OPERATION_TIMEOUT =
275     "hbase.client.meta.operation.timeout";
276 
277   /** Default HBase client operation timeout, which is tantamount to a blocking call */
278   public static final int DEFAULT_HBASE_CLIENT_OPERATION_TIMEOUT = Integer.MAX_VALUE;
279 
280   /** Used to construct the name of the log directory for a region server */
281   public static final String HREGION_LOGDIR_NAME = "WALs";
282 
283   /** Used to construct the name of the splitlog directory for a region server */
284   public static final String SPLIT_LOGDIR_NAME = "splitWAL";
285 
286   /** Like the previous, but for old logs that are about to be deleted */
287   public static final String HREGION_OLDLOGDIR_NAME = "oldWALs";
288 
289   public static final String CORRUPT_DIR_NAME = "corrupt";
290 
291   /** Used by HBCK to sideline backup data */
292   public static final String HBCK_SIDELINEDIR_NAME = ".hbck";
293 
294   /** Any artifacts left from migration can be moved here */
295   public static final String MIGRATION_NAME = ".migration";
296 
297   /**
298    * The directory from which co-processor/custom filter jars can be loaded
299    * dynamically by the region servers. This value can be overridden by the
300    * hbase.dynamic.jars.dir config.
301    */
302   public static final String LIB_DIR = "lib";
303 
304   /** Used to construct the name of the compaction directory during compaction */
305   public static final String HREGION_COMPACTIONDIR_NAME = "compaction.dir";
306 
307   /** Conf key for the max file size after which we split the region */
308   public static final String HREGION_MAX_FILESIZE =
309       "hbase.hregion.max.filesize";
310 
311   /** Default maximum file size */
312   public static final long DEFAULT_MAX_FILE_SIZE = 10 * 1024 * 1024 * 1024L;
313 
314   /**
315    * The max number of threads used for opening and closing stores or store
316    * files in parallel
317    */
318   public static final String HSTORE_OPEN_AND_CLOSE_THREADS_MAX =
319     "hbase.hstore.open.and.close.threads.max";
320 
321   /**
322    * The default number for the max number of threads used for opening and
323    * closing stores or store files in parallel
324    */
325   public static final int DEFAULT_HSTORE_OPEN_AND_CLOSE_THREADS_MAX = 1;
326 
327 
328   /** Conf key for the memstore size at which we flush the memstore */
329   public static final String HREGION_MEMSTORE_FLUSH_SIZE =
330       "hbase.hregion.memstore.flush.size";
331 
332   public static final String HREGION_EDITS_REPLAY_SKIP_ERRORS =
333       "hbase.hregion.edits.replay.skip.errors";
334 
335   public static final boolean DEFAULT_HREGION_EDITS_REPLAY_SKIP_ERRORS =
336       false;
337 
338   /** Maximum value length, enforced on KeyValue construction */
339   public static final int MAXIMUM_VALUE_LENGTH = Integer.MAX_VALUE - 1;
340 
341   /** name of the file for unique cluster ID */
342   public static final String CLUSTER_ID_FILE_NAME = "hbase.id";
343 
344   /** Default value for cluster ID */
345   public static final String CLUSTER_ID_DEFAULT = "default-cluster";
346 
347   // Always store the location of the root table's HRegion.
348   // This HRegion is never split.
349 
350   // region name = table + startkey + regionid. This is the row key.
351   // each row in the root and meta tables describes exactly 1 region
352   // Do we ever need to know all the information that we are storing?
353 
354   // Note that the name of the root table starts with "-" and the name of the
355   // meta table starts with "." Why? it's a trick. It turns out that when we
356   // store region names in memory, we use a SortedMap. Since "-" sorts before
357   // "." (and since no other table name can start with either of these
358   // characters, the root region will always be the first entry in such a Map,
359   // followed by all the meta regions (which will be ordered by their starting
360   // row key as well), followed by all user tables. So when the Master is
361   // choosing regions to assign, it will always choose the root region first,
362   // followed by the meta regions, followed by user regions. Since the root
363   // and meta regions always need to be on-line, this ensures that they will
364   // be the first to be reassigned if the server(s) they are being served by
365   // should go down.
366 
367 
368   /** The hbase:meta table's name. */
369   @Deprecated  // for compat from 0.94 -> 0.96.
370   public static final byte[] META_TABLE_NAME = TableName.META_TABLE_NAME.getName();
371 
372   public static final String BASE_NAMESPACE_DIR = "data";
373 
374   /** delimiter used between portions of a region name */
375   public static final int META_ROW_DELIMITER = ',';
376 
377   /** The catalog family as a string*/
378   public static final String CATALOG_FAMILY_STR = "info";
379 
380   /** The catalog family */
381   public static final byte [] CATALOG_FAMILY = Bytes.toBytes(CATALOG_FAMILY_STR);
382 
383   /** The RegionInfo qualifier as a string */
384   public static final String REGIONINFO_QUALIFIER_STR = "regioninfo";
385 
386   /** The regioninfo column qualifier */
387   public static final byte [] REGIONINFO_QUALIFIER = Bytes.toBytes(REGIONINFO_QUALIFIER_STR);
388 
389   /** The server column qualifier */
390   public static final byte [] SERVER_QUALIFIER = Bytes.toBytes("server");
391 
392   /** The startcode column qualifier */
393   public static final byte [] STARTCODE_QUALIFIER = Bytes.toBytes("serverstartcode");
394 
395   /** The open seqnum column qualifier */
396   public static final byte [] SEQNUM_QUALIFIER = Bytes.toBytes("seqnumDuringOpen");
397 
398   /** The state column qualifier */
399   public static final byte [] STATE_QUALIFIER = Bytes.toBytes("state");
400 
401   /**
402    * The serverName column qualifier. Its the server where the region is
403    * transitioning on, while column server is the server where the region is
404    * opened on. They are the same when the region is in state OPEN.
405    */
406   public static final byte [] SERVERNAME_QUALIFIER = Bytes.toBytes("sn");
407 
408   /** The lower-half split region column qualifier */
409   public static final byte [] SPLITA_QUALIFIER = Bytes.toBytes("splitA");
410 
411   /** The upper-half split region column qualifier */
412   public static final byte [] SPLITB_QUALIFIER = Bytes.toBytes("splitB");
413 
414   /** The lower-half merge region column qualifier */
415   public static final byte[] MERGEA_QUALIFIER = Bytes.toBytes("mergeA");
416 
417   /** The upper-half merge region column qualifier */
418   public static final byte[] MERGEB_QUALIFIER = Bytes.toBytes("mergeB");
419 
420   /**
421    * The meta table version column qualifier.
422    * We keep current version of the meta table in this column in <code>-ROOT-</code>
423    * table: i.e. in the 'info:v' column.
424    */
425   public static final byte [] META_VERSION_QUALIFIER = Bytes.toBytes("v");
426 
427   /**
428    * The current version of the meta table.
429    * - pre-hbase 0.92.  There is no META_VERSION column in the root table
430    * in this case. The meta has HTableDescriptor serialized into the HRegionInfo;
431    * - version 0 is 0.92 and 0.94. Meta data has serialized HRegionInfo's using
432    * Writable serialization, and HRegionInfo's does not contain HTableDescriptors.
433    * - version 1 for 0.96+ keeps HRegionInfo data structures, but changes the
434    * byte[] serialization from Writables to Protobuf.
435    * See HRegionInfo.VERSION
436    */
437   public static final short META_VERSION = 1;
438 
439   // Other constants
440 
441   /**
442    * An empty instance.
443    */
444   public static final byte [] EMPTY_BYTE_ARRAY = new byte [0];
445 
446   /**
447    * Used by scanners, etc when they want to start at the beginning of a region
448    */
449   public static final byte [] EMPTY_START_ROW = EMPTY_BYTE_ARRAY;
450 
451   /**
452    * Last row in a table.
453    */
454   public static final byte [] EMPTY_END_ROW = EMPTY_START_ROW;
455 
456   /**
457     * Used by scanners and others when they're trying to detect the end of a
458     * table
459     */
460   public static final byte [] LAST_ROW = EMPTY_BYTE_ARRAY;
461 
462   /**
463    * Max length a row can have because of the limitation in TFile.
464    */
465   public static final int MAX_ROW_LENGTH = Short.MAX_VALUE;
466 
467   /**
468    * Timestamp to use when we want to refer to the latest cell.
469    * This is the timestamp sent by clients when no timestamp is specified on
470    * commit.
471    */
472   public static final long LATEST_TIMESTAMP = Long.MAX_VALUE;
473 
474   /**
475    * Timestamp to use when we want to refer to the oldest cell.
476    */
477   public static final long OLDEST_TIMESTAMP = Long.MIN_VALUE;
478 
479   /**
480    * LATEST_TIMESTAMP in bytes form
481    */
482   public static final byte [] LATEST_TIMESTAMP_BYTES = {
483     // big-endian
484     (byte) (LATEST_TIMESTAMP >>> 56),
485     (byte) (LATEST_TIMESTAMP >>> 48),
486     (byte) (LATEST_TIMESTAMP >>> 40),
487     (byte) (LATEST_TIMESTAMP >>> 32),
488     (byte) (LATEST_TIMESTAMP >>> 24),
489     (byte) (LATEST_TIMESTAMP >>> 16),
490     (byte) (LATEST_TIMESTAMP >>> 8),
491     (byte) LATEST_TIMESTAMP,
492   };
493 
494   /**
495    * Define for 'return-all-versions'.
496    */
497   public static final int ALL_VERSIONS = Integer.MAX_VALUE;
498 
499   /**
500    * Unlimited time-to-live.
501    */
502 //  public static final int FOREVER = -1;
503   public static final int FOREVER = Integer.MAX_VALUE;
504 
505   /**
506    * Seconds in a week
507    */
508   public static final int WEEK_IN_SECONDS = 7 * 24 * 3600;
509 
510   /**
511    * Seconds in a day, hour and minute
512    */
513   public static final int DAY_IN_SECONDS = 24 * 60 * 60;
514   public static final int HOUR_IN_SECONDS = 60 * 60;
515   public static final int MINUTE_IN_SECONDS = 60;
516 
517   //TODO: although the following are referenced widely to format strings for
518   //      the shell. They really aren't a part of the public API. It would be
519   //      nice if we could put them somewhere where they did not need to be
520   //      public. They could have package visibility
521   public static final String NAME = "NAME";
522   public static final String VERSIONS = "VERSIONS";
523   public static final String IN_MEMORY = "IN_MEMORY";
524   public static final String METADATA = "METADATA";
525   public static final String CONFIGURATION = "CONFIGURATION";
526 
527   /**
528    * Retrying we multiply hbase.client.pause setting by what we have in this array until we
529    * run out of array items.  Retries beyond this use the last number in the array.  So, for
530    * example, if hbase.client.pause is 1 second, and maximum retries count
531    * hbase.client.retries.number is 10, we will retry at the following intervals:
532    * 1, 2, 3, 5, 10, 20, 40, 100, 100, 100.
533    * With 100ms, a back-off of 200 means 20s
534    */
535   public static final int RETRY_BACKOFF[] = {1, 2, 3, 5, 10, 20, 40, 100, 100, 100, 100, 200, 200};
536 
537   public static final String REGION_IMPL = "hbase.hregion.impl";
538 
539   /** modifyTable op for replacing the table descriptor */
540   public static enum Modify {
541     CLOSE_REGION,
542     TABLE_COMPACT,
543     TABLE_FLUSH,
544     TABLE_MAJOR_COMPACT,
545     TABLE_SET_HTD,
546     TABLE_SPLIT
547   }
548 
549   /**
550    * Scope tag for locally scoped data.
551    * This data will not be replicated.
552    */
553   public static final int REPLICATION_SCOPE_LOCAL = 0;
554 
555   /**
556    * Scope tag for globally scoped data.
557    * This data will be replicated to all peers.
558    */
559   public static final int REPLICATION_SCOPE_GLOBAL = 1;
560 
561   /**
562    * Default cluster ID, cannot be used to identify a cluster so a key with
563    * this value means it wasn't meant for replication.
564    */
565   public static final UUID DEFAULT_CLUSTER_ID = new UUID(0L,0L);
566 
567     /**
568      * Parameter name for maximum number of bytes returned when calling a
569      * scanner's next method.
570      */
571   public static final String HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE_KEY =
572       "hbase.client.scanner.max.result.size";
573 
574   /**
575    * Maximum number of bytes returned when calling a scanner's next method.
576    * Note that when a single row is larger than this limit the row is still
577    * returned completely.
578    *
579    * The default value is 2MB.
580    */
581   public static final long DEFAULT_HBASE_CLIENT_SCANNER_MAX_RESULT_SIZE = 2 * 1024 * 1024;
582 
583   /**
584    * Parameter name for client pause value, used mostly as value to wait
585    * before running a retry of a failed get, region lookup, etc.
586    */
587   public static final String HBASE_CLIENT_PAUSE = "hbase.client.pause";
588 
589   /**
590    * Default value of {@link #HBASE_CLIENT_PAUSE}.
591    */
592   public static final long DEFAULT_HBASE_CLIENT_PAUSE = 100;
593 
594   /**
595    * The maximum number of concurrent connections the client will maintain.
596    */
597   public static final String HBASE_CLIENT_MAX_TOTAL_TASKS = "hbase.client.max.total.tasks";
598 
599   /**
600    * Default value of {@link #HBASE_CLIENT_MAX_TOTAL_TASKS}.
601    */
602   public static final int DEFAULT_HBASE_CLIENT_MAX_TOTAL_TASKS = 100;
603 
604   /**
605    * The maximum number of concurrent connections the client will maintain to a single
606    * RegionServer.
607    */
608   public static final String HBASE_CLIENT_MAX_PERSERVER_TASKS = "hbase.client.max.perserver.tasks";
609 
610   /**
611    * Default value of {@link #HBASE_CLIENT_MAX_PERSERVER_TASKS}.
612    */
613   public static final int DEFAULT_HBASE_CLIENT_MAX_PERSERVER_TASKS = 2;
614 
615   /**
616    * The maximum number of concurrent connections the client will maintain to a single
617    * Region.
618    */
619   public static final String HBASE_CLIENT_MAX_PERREGION_TASKS = "hbase.client.max.perregion.tasks";
620 
621   /**
622    * Default value of {@link #HBASE_CLIENT_MAX_PERREGION_TASKS}.
623    */
624   public static final int DEFAULT_HBASE_CLIENT_MAX_PERREGION_TASKS = 1;
625 
626   /**
627    * Parameter name for server pause value, used mostly as value to wait before
628    * running a retry of a failed operation.
629    */
630   public static final String HBASE_SERVER_PAUSE = "hbase.server.pause";
631 
632   /**
633    * Default value of {@link #HBASE_SERVER_PAUSE}.
634    */
635   public static final int DEFAULT_HBASE_SERVER_PAUSE = 1000;
636 
637   /**
638    * Parameter name for maximum retries, used as maximum for all retryable
639    * operations such as fetching of the root region from root region server,
640    * getting a cell's value, starting a row update, etc.
641    */
642   public static final String HBASE_CLIENT_RETRIES_NUMBER = "hbase.client.retries.number";
643 
644   /**
645    * Default value of {@link #HBASE_CLIENT_RETRIES_NUMBER}.
646    */
647   public static final int DEFAULT_HBASE_CLIENT_RETRIES_NUMBER = 31;
648 
649   /**
650    * Parameter name for client region location prefetch toggle.
651    */
652   public static String HBASE_CLIENT_PREFETCH = "hbase.client.prefetch";
653 
654   /**
655    * Default value of {@link #HBASE_CLIENT_PREFETCH}.
656    */
657   public static boolean DEFAULT_HBASE_CLIENT_PREFETCH = true;
658 
659   /**
660    * Parameter name for client prefetch limit, used as the maximum number of regions
661    * info that will be prefetched.
662    */
663   public static String HBASE_CLIENT_PREFETCH_LIMIT = "hbase.client.prefetch.limit";
664 
665   /**
666    * Default value of {@link #HBASE_CLIENT_PREFETCH_LIMIT}.
667    */
668   public static int DEFAULT_HBASE_CLIENT_PREFETCH_LIMIT = 10;
669 
670   /**
671    * Parameter name to set the default scanner caching for all clients.
672    */
673   public static final String HBASE_CLIENT_SCANNER_CACHING = "hbase.client.scanner.caching";
674 
675   /**
676    * Default value for {@link #HBASE_CLIENT_SCANNER_CACHING}
677    */
678   public static final int DEFAULT_HBASE_CLIENT_SCANNER_CACHING = 100;
679 
680   /**
681    * Parameter name for number of versions, kept by meta table.
682    */
683   public static String HBASE_META_VERSIONS = "hbase.meta.versions";
684 
685   /**
686    * Default value of {@link #HBASE_META_VERSIONS}.
687    */
688   public static int DEFAULT_HBASE_META_VERSIONS = 10;
689 
690   /**
691    * Parameter name for number of versions, kept by meta table.
692    */
693   public static String HBASE_META_BLOCK_SIZE = "hbase.meta.blocksize";
694 
695   /**
696    * Default value of {@link #HBASE_META_BLOCK_SIZE}.
697    */
698   public static int DEFAULT_HBASE_META_BLOCK_SIZE = 8 * 1024;
699 
700   /**
701    * Parameter name for number of rows that will be fetched when calling next on
702    * a scanner if it is not served from memory. Higher caching values will
703    * enable faster scanners but will eat up more memory and some calls of next
704    * may take longer and longer times when the cache is empty.
705    */
706   public static final String HBASE_META_SCANNER_CACHING = "hbase.meta.scanner.caching";
707 
708   /**
709    * Default value of {@link #HBASE_META_SCANNER_CACHING}.
710    */
711   public static final int DEFAULT_HBASE_META_SCANNER_CACHING = 100;
712 
713   /**
714    * Parameter name for unique identifier for this {@link org.apache.hadoop.conf.Configuration}
715    * instance. If there are two or more {@link org.apache.hadoop.conf.Configuration} instances that,
716    * for all intents and purposes, are the same except for their instance ids, then they will not be
717    * able to share the same org.apache.hadoop.hbase.client.HConnection instance. On the other hand,
718    * even if the instance ids are the same, it could result in non-shared
719    * org.apache.hadoop.hbase.client.HConnection instances if some of the other connection parameters
720    * differ.
721    */
722   public static final String HBASE_CLIENT_INSTANCE_ID = "hbase.client.instance.id";
723 
724   /**
725    * The client scanner timeout period in milliseconds.
726    */
727   public static final String HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD = "hbase.client.scanner.timeout.period";
728 
729   /**
730    * Use {@link #HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD} instead.
731    * @deprecated This config option is deprecated. Will be removed at later releases after 0.96.
732    */
733   @Deprecated
734   public static final String HBASE_REGIONSERVER_LEASE_PERIOD_KEY =
735       "hbase.regionserver.lease.period";
736 
737   /**
738    * Default value of {@link #HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD}.
739    */
740   public static final int DEFAULT_HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD = 60000;
741 
742   /**
743    * timeout for each RPC
744    */
745   public static final String HBASE_RPC_TIMEOUT_KEY = "hbase.rpc.timeout";
746 
747   /**
748    * Default value of {@link #HBASE_RPC_TIMEOUT_KEY}
749    */
750   public static final int DEFAULT_HBASE_RPC_TIMEOUT = 60000;
751 
752   /**
753    * timeout for short operation RPC
754    */
755   public static final String HBASE_RPC_SHORTOPERATION_TIMEOUT_KEY = "hbase.rpc.shortoperation.timeout";
756 
757   /**
758    * Default value of {@link #HBASE_RPC_SHORTOPERATION_TIMEOUT_KEY}
759    */
760   public static final int DEFAULT_HBASE_RPC_SHORTOPERATION_TIMEOUT = 10000;
761 
762   /**
763    * Value indicating the server name was saved with no sequence number.
764    */
765   public static final long NO_SEQNUM = -1;
766 
767 
768   /*
769    * cluster replication constants.
770    */
771   public static final String
772       REPLICATION_ENABLE_KEY = "hbase.replication";
773   public static final boolean
774       REPLICATION_ENABLE_DEFAULT = true;
775   public static final String
776       REPLICATION_SOURCE_SERVICE_CLASSNAME = "hbase.replication.source.service";
777   public static final String
778       REPLICATION_SINK_SERVICE_CLASSNAME = "hbase.replication.sink.service";
779   public static final String REPLICATION_SERVICE_CLASSNAME_DEFAULT =
780     "org.apache.hadoop.hbase.replication.regionserver.Replication";
781 
782   /** HBCK special code name used as server name when manipulating ZK nodes */
783   public static final String HBCK_CODE_NAME = "HBCKServerName";
784 
785   public static final String KEY_FOR_HOSTNAME_SEEN_BY_MASTER =
786     "hbase.regionserver.hostname.seen.by.master";
787 
788   public static final String HBASE_MASTER_LOGCLEANER_PLUGINS =
789       "hbase.master.logcleaner.plugins";
790 
791   public static final String HBASE_REGION_SPLIT_POLICY_KEY =
792     "hbase.regionserver.region.split.policy";
793 
794   /** Whether nonces are enabled; default is true. */
795   public static final String HBASE_RS_NONCES_ENABLED = "hbase.regionserver.nonces.enabled";
796 
797   /**
798    * Configuration key for the size of the block cache
799    */
800   public static final String HFILE_BLOCK_CACHE_SIZE_KEY =
801     "hfile.block.cache.size";
802 
803   public static final float HFILE_BLOCK_CACHE_SIZE_DEFAULT = 0.25f;
804 
805   /*
806     * Minimum percentage of free heap necessary for a successful cluster startup.
807     */
808   public static final float HBASE_CLUSTER_MINIMUM_MEMORY_THRESHOLD = 0.2f;
809 
810   public static final Pattern CP_HTD_ATTR_KEY_PATTERN = Pattern.compile
811       ("^coprocessor\\$([0-9]+)$", Pattern.CASE_INSENSITIVE);
812   public static final Pattern CP_HTD_ATTR_VALUE_PATTERN =
813       Pattern.compile("(^[^\\|]*)\\|([^\\|]+)\\|[\\s]*([\\d]*)[\\s]*(\\|.*)?$");
814 
815   public static final String CP_HTD_ATTR_VALUE_PARAM_KEY_PATTERN = "[^=,]+";
816   public static final String CP_HTD_ATTR_VALUE_PARAM_VALUE_PATTERN = "[^,]+";
817   public static final Pattern CP_HTD_ATTR_VALUE_PARAM_PATTERN = Pattern.compile(
818       "(" + CP_HTD_ATTR_VALUE_PARAM_KEY_PATTERN + ")=(" +
819       CP_HTD_ATTR_VALUE_PARAM_VALUE_PATTERN + "),?");
820 
821   /** The delay when re-trying a socket operation in a loop (HBASE-4712) */
822   public static final int SOCKET_RETRY_WAIT_MS = 200;
823 
824   /** Host name of the local machine */
825   public static final String LOCALHOST = "localhost";
826 
827   /**
828    * If this parameter is set to true, then hbase will read
829    * data and then verify checksums. Checksum verification
830    * inside hdfs will be switched off.  However, if the hbase-checksum
831    * verification fails, then it will switch back to using
832    * hdfs checksums for verifiying data that is being read from storage.
833    *
834    * If this parameter is set to false, then hbase will not
835    * verify any checksums, instead it will depend on checksum verification
836    * being done in the hdfs client.
837    */
838   public static final String HBASE_CHECKSUM_VERIFICATION =
839       "hbase.regionserver.checksum.verify";
840 
841   public static final String LOCALHOST_IP = "127.0.0.1";
842 
843   /** Conf key that enables unflushed WAL edits directly being replayed to region servers */
844   public static final String DISTRIBUTED_LOG_REPLAY_KEY = "hbase.master.distributed.log.replay";
845   public static final boolean DEFAULT_DISTRIBUTED_LOG_REPLAY_CONFIG = false;
846   public static final String DISALLOW_WRITES_IN_RECOVERING =
847       "hbase.regionserver.disallow.writes.when.recovering";
848   public static final boolean DEFAULT_DISALLOW_WRITES_IN_RECOVERING_CONFIG = false;
849 
850   public static final String REGION_SERVER_HANDLER_COUNT = "hbase.regionserver.handler.count";
851   public static final int DEFAULT_REGION_SERVER_HANDLER_COUNT = 30;
852 
853   /*
854    * REGION_SERVER_HANDLER_ABORT_ON_ERROR_PERCENT:
855    * -1  => Disable aborting
856    * 0   => Abort if even a single handler has died
857    * 0.x => Abort only when this percent of handlers have died
858    * 1   => Abort only all of the handers have died
859    */
860   public static final String REGION_SERVER_HANDLER_ABORT_ON_ERROR_PERCENT =
861       "hbase.regionserver.handler.abort.on.error.percent";
862   public static final float DEFAULT_REGION_SERVER_HANDLER_ABORT_ON_ERROR_PERCENT = -1;
863   
864   public static final String REGION_SERVER_META_HANDLER_COUNT =
865       "hbase.regionserver.metahandler.count";
866   public static final int DEFAULT_REGION_SERVER_META_HANDLER_COUNT = 10;
867 
868   public static final String REGION_SERVER_REPLICATION_HANDLER_COUNT =
869       "hbase.regionserver.replication.handler.count";
870   public static final int DEFAULT_REGION_SERVER_REPLICATION_HANDLER_COUNT = 3;
871 
872   public static final String MASTER_HANDLER_COUNT = "hbase.master.handler.count";
873   public static final int DEFAULT_MASTER_HANLDER_COUNT = 25;
874 
875   /** Conf key that specifies timeout value to wait for a region ready */
876   public static final String LOG_REPLAY_WAIT_REGION_TIMEOUT =
877       "hbase.master.log.replay.wait.region.timeout";
878 
879   /**
880    * The name of the configuration parameter that specifies
881    * the number of bytes in a newly created checksum chunk.
882    */
883   public static final String BYTES_PER_CHECKSUM =
884       "hbase.hstore.bytes.per.checksum";
885 
886   /**
887    * The name of the configuration parameter that specifies
888    * the name of an algorithm that is used to compute checksums
889    * for newly created blocks.
890    */
891   public static final String CHECKSUM_TYPE_NAME =
892       "hbase.hstore.checksum.algorithm";
893 
894   /** Enable file permission modification from standard hbase */
895   public static final String ENABLE_DATA_FILE_UMASK = "hbase.data.umask.enable";
896   /** File permission umask to use when creating hbase data files */
897   public static final String DATA_FILE_UMASK_KEY = "hbase.data.umask";
898 
899   /** Configuration name of HLog Compression */
900   public static final String ENABLE_WAL_COMPRESSION =
901     "hbase.regionserver.wal.enablecompression";
902 
903   /** Region in Transition metrics threshold time */
904   public static final String METRICS_RIT_STUCK_WARNING_THRESHOLD="hbase.metrics.rit.stuck.warning.threshold";
905 
906   public static final String LOAD_BALANCER_SLOP_KEY = "hbase.regions.slop";
907 
908   /**
909    * The byte array represents for NO_NEXT_INDEXED_KEY;
910    * The actual value is irrelevant because this is always compared by reference.
911    */
912   public static final byte [] NO_NEXT_INDEXED_KEY = Bytes.toBytes("NO_NEXT_INDEXED_KEY");
913   /** delimiter used between portions of a region name */
914   public static final int DELIMITER = ',';
915   public static final String HBASE_CONFIG_READ_ZOOKEEPER_CONFIG =
916       "hbase.config.read.zookeeper.config";
917   public static final boolean DEFAULT_HBASE_CONFIG_READ_ZOOKEEPER_CONFIG =
918       false;
919 
920   /**
921    * QOS attributes: these attributes are used to demarcate RPC call processing
922    * by different set of handlers. For example, HIGH_QOS tagged methods are
923    * handled by high priority handlers.
924    */
925   public static final int NORMAL_QOS = 0;
926   public static final int QOS_THRESHOLD = 10;
927   public static final int HIGH_QOS = 100;
928   public static final int REPLICATION_QOS = 5; // normal_QOS < replication_QOS < high_QOS
929   public static final int REPLAY_QOS = 6; // REPLICATION_QOS < REPLAY_QOS < high_QOS
930 
931   /** Directory under /hbase where archived hfiles are stored */
932   public static final String HFILE_ARCHIVE_DIRECTORY = "archive";
933 
934   /**
935    * Name of the directory to store all snapshots. See SnapshotDescriptionUtils for
936    * remaining snapshot constants; this is here to keep HConstants dependencies at a minimum and
937    * uni-directional.
938    */
939   public static final String SNAPSHOT_DIR_NAME = ".hbase-snapshot";
940 
941   /* Name of old snapshot directory. See HBASE-8352 for details on why it needs to be renamed */
942   public static final String OLD_SNAPSHOT_DIR_NAME = ".snapshot";
943 
944   /** Temporary directory used for table creation and deletion */
945   public static final String HBASE_TEMP_DIRECTORY = ".tmp";
946   /**
947    * The period (in milliseconds) between computing region server point in time metrics
948    */
949   public static final String REGIONSERVER_METRICS_PERIOD = "hbase.regionserver.metrics.period";
950   public static final long DEFAULT_REGIONSERVER_METRICS_PERIOD = 5000;
951   /** Directories that are not HBase table directories */
952   public static final List<String> HBASE_NON_TABLE_DIRS =
953     Collections.unmodifiableList(Arrays.asList(new String[] {
954       HBCK_SIDELINEDIR_NAME, HBASE_TEMP_DIRECTORY, MIGRATION_NAME
955     }));
956 
957   /** Directories that are not HBase user table directories */
958   public static final List<String> HBASE_NON_USER_TABLE_DIRS =
959     Collections.unmodifiableList(Arrays.asList((String[])ArrayUtils.addAll(
960       new String[] { TableName.META_TABLE_NAME.getNameAsString() },
961       HBASE_NON_TABLE_DIRS.toArray())));
962 
963   /** Health script related settings. */
964   public static final String HEALTH_SCRIPT_LOC = "hbase.node.health.script.location";
965   public static final String HEALTH_SCRIPT_TIMEOUT = "hbase.node.health.script.timeout";
966   public static final String HEALTH_CHORE_WAKE_FREQ =
967       "hbase.node.health.script.frequency";
968   public static final long DEFAULT_HEALTH_SCRIPT_TIMEOUT = 60000;
969   /**
970    * The maximum number of health check failures a server can encounter consecutively.
971    */
972   public static final String HEALTH_FAILURE_THRESHOLD =
973       "hbase.node.health.failure.threshold";
974   public static final int DEFAULT_HEALTH_FAILURE_THRESHOLD = 3;
975 
976 
977   /**
978    * Setting to activate, or not, the publication of the status by the master. Default
979    *  notification is by a multicast message.
980    */
981   public static final String STATUS_PUBLISHED = "hbase.status.published";
982   public static final boolean STATUS_PUBLISHED_DEFAULT = false;
983 
984   /**
985    * IP to use for the multicast status messages between the master and the clients.
986    * The default address is chosen as one among others within the ones suitable for multicast
987    * messages.
988    */
989   public static final String STATUS_MULTICAST_ADDRESS = "hbase.status.multicast.address.ip";
990   public static final String DEFAULT_STATUS_MULTICAST_ADDRESS = "226.1.1.3";
991 
992   /**
993    * The address to use for binding the local socket for receiving multicast. Defaults to
994    * 0.0.0.0.
995    * @see <a href="https://issues.apache.org/jira/browse/HBASE-9961">HBASE-9961</a>
996    */
997   public static final String STATUS_MULTICAST_BIND_ADDRESS = "hbase.status.multicast.bind.address.ip";
998   public static final String DEFAULT_STATUS_MULTICAST_BIND_ADDRESS = "0.0.0.0";
999 
1000   /**
1001    * The port to use for the multicast messages.
1002    */
1003   public static final String STATUS_MULTICAST_PORT = "hbase.status.multicast.address.port";
1004   public static final int DEFAULT_STATUS_MULTICAST_PORT = 60100;
1005 
1006   public static final long NO_NONCE = 0;
1007 
1008   /** Default cipher for encryption */
1009   public static final String CIPHER_AES = "AES";
1010 
1011   /** Configuration key for the crypto algorithm provider, a class name */
1012   @InterfaceStability.Unstable
1013   public static final String CRYPTO_CIPHERPROVIDER_CONF_KEY = "hbase.crypto.cipherprovider";
1014 
1015   /** Configuration key for the crypto key provider, a class name */
1016   @InterfaceStability.Unstable
1017   public static final String CRYPTO_KEYPROVIDER_CONF_KEY = "hbase.crypto.keyprovider";
1018 
1019   /** Configuration key for the crypto key provider parameters */
1020   @InterfaceStability.Unstable
1021   public static final String CRYPTO_KEYPROVIDER_PARAMETERS_KEY =
1022       "hbase.crypto.keyprovider.parameters";
1023 
1024   /** Configuration key for the name of the master key for the cluster, a string */
1025   @InterfaceStability.Unstable
1026   public static final String CRYPTO_MASTERKEY_NAME_CONF_KEY = "hbase.crypto.master.key.name";
1027 
1028   /** Configuration key for the name of the alternate master key for the cluster, a string */
1029   @InterfaceStability.Unstable
1030   public static final String CRYPTO_MASTERKEY_ALTERNATE_NAME_CONF_KEY =
1031     "hbase.crypto.master.alternate.key.name";
1032 
1033   /** Configuration key for the algorithm to use when encrypting the WAL, a string */
1034   @InterfaceStability.Unstable
1035   public static final String CRYPTO_WAL_ALGORITHM_CONF_KEY = "hbase.crypto.wal.algorithm";
1036 
1037   /** Configuration key for the name of the master WAL encryption key for the cluster, a string */
1038   @InterfaceStability.Unstable
1039   public static final String CRYPTO_WAL_KEY_NAME_CONF_KEY = "hbase.crypto.wal.key.name";
1040 
1041   /** Configuration key for the algorithm used for creating jks key, a string */
1042   public static final String CRYPTO_KEY_ALGORITHM_CONF_KEY = "hbase.crypto.key.algorithm";
1043 
1044   /** Configuration key for the name of the alternate cipher algorithm for the cluster, a string */
1045   public static final String CRYPTO_ALTERNATE_KEY_ALGORITHM_CONF_KEY =
1046       "hbase.crypto.alternate.key.algorithm";
1047 
1048   /** Configuration key for enabling WAL encryption, a boolean */
1049   public static final String ENABLE_WAL_ENCRYPTION = "hbase.regionserver.wal.encryption";
1050 
1051   /** Configuration key for setting RPC codec class name */
1052   public static final String RPC_CODEC_CONF_KEY = "hbase.client.rpc.codec";
1053 
1054   /** Configuration key for setting replication codec class name */
1055   public static final String REPLICATION_CODEC_CONF_KEY = "hbase.replication.rpc.codec";
1056 
1057   /** Config key for if the server should send backpressure and if the client should listen to
1058    * that backpressure from the server */
1059   public static final String ENABLE_CLIENT_BACKPRESSURE = "hbase.client.backpressure.enabled";
1060   public static final boolean DEFAULT_ENABLE_CLIENT_BACKPRESSURE = false;
1061 
1062   public static final String HEAP_OCCUPANCY_LOW_WATERMARK_KEY =
1063       "hbase.heap.occupancy.low_water_mark";
1064   public static final float DEFAULT_HEAP_OCCUPANCY_LOW_WATERMARK = 0.95f;
1065   public static final String HEAP_OCCUPANCY_HIGH_WATERMARK_KEY =
1066       "hbase.heap.occupancy.high_water_mark";
1067   public static final float DEFAULT_HEAP_OCCUPANCY_HIGH_WATERMARK = 0.98f;
1068 
1069   private HConstants() {
1070     // Can't be instantiated with this ctor.
1071   }
1072 }