001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hdfs.protocol;
019
020import org.apache.hadoop.classification.InterfaceAudience;
021import org.apache.hadoop.fs.Path;
022import org.apache.hadoop.hdfs.DFSConfigKeys;
023import org.apache.hadoop.hdfs.DFSUtil;
024import org.apache.hadoop.hdfs.HdfsConfiguration;
025
026/************************************
027 * Some handy constants
028 * 
029 ************************************/
030@InterfaceAudience.Private
031public class HdfsConstants {
032  /* Hidden constructor */
033  protected HdfsConstants() {
034  }
035  
036  /**
037   * HDFS Protocol Names:  
038   */
039  public static final String CLIENT_NAMENODE_PROTOCOL_NAME = 
040      "org.apache.hadoop.hdfs.protocol.ClientProtocol";
041  public static final String CLIENT_DATANODE_PROTOCOL_NAME = 
042      "org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol";
043  
044  
045  public static int MIN_BLOCKS_FOR_WRITE = 5;
046
047  // Long that indicates "leave current quota unchanged"
048  public static final long QUOTA_DONT_SET = Long.MAX_VALUE;
049  public static final long QUOTA_RESET = -1L;
050
051  //
052  // Timeouts, constants
053  //
054  public static final long LEASE_SOFTLIMIT_PERIOD = 60 * 1000;
055  public static final long LEASE_HARDLIMIT_PERIOD = 60 * LEASE_SOFTLIMIT_PERIOD;
056  public static final long LEASE_RECOVER_PERIOD = 10 * 1000; // in ms
057
058  // We need to limit the length and depth of a path in the filesystem.
059  // HADOOP-438
060  // Currently we set the maximum length to 8k characters and the maximum depth
061  // to 1k.
062  public static int MAX_PATH_LENGTH = 8000;
063  public static int MAX_PATH_DEPTH = 1000;
064
065  // TODO should be conf injected?
066  public static final int DEFAULT_DATA_SOCKET_SIZE = 128 * 1024;
067  public static final int IO_FILE_BUFFER_SIZE = new HdfsConfiguration().getInt(
068      DFSConfigKeys.IO_FILE_BUFFER_SIZE_KEY,
069      DFSConfigKeys.IO_FILE_BUFFER_SIZE_DEFAULT);
070  // Used for writing header etc.
071  public static final int SMALL_BUFFER_SIZE = Math.min(IO_FILE_BUFFER_SIZE / 2,
072      512);
073
074  public static final int BYTES_IN_INTEGER = Integer.SIZE / Byte.SIZE;
075
076  // SafeMode actions
077  public static enum SafeModeAction {
078    SAFEMODE_LEAVE, SAFEMODE_ENTER, SAFEMODE_GET;
079  }
080
081  // type of the datanode report
082  public static enum DatanodeReportType {
083    ALL, LIVE, DEAD
084  }
085
086  // An invalid transaction ID that will never be seen in a real namesystem.
087  public static final long INVALID_TXID = -12345;
088
089  // Number of generation stamps reserved for legacy blocks.
090  public static final long RESERVED_GENERATION_STAMPS_V1 =
091      1024L * 1024 * 1024 * 1024;
092
093  /**
094   * URI Scheme for hdfs://namenode/ URIs.
095   */
096  public static final String HDFS_URI_SCHEME = "hdfs";
097
098  /**
099   * A prefix put before the namenode URI inside the "service" field
100   * of a delgation token, indicating that the URI is a logical (HA)
101   * URI.
102   */
103  public static final String HA_DT_SERVICE_PREFIX = "ha-hdfs:";
104
105
106  /**
107   * Please see {@link LayoutVersion} on adding new layout version.
108   */
109  public static final int LAYOUT_VERSION = LayoutVersion
110      .getCurrentLayoutVersion();
111  
112  /**
113   * A special path component contained in the path for a snapshot file/dir
114   */
115  public static final String DOT_SNAPSHOT_DIR = ".snapshot";
116
117  public static final byte[] DOT_SNAPSHOT_DIR_BYTES
118      = DFSUtil.string2Bytes(DOT_SNAPSHOT_DIR);
119  
120  public static final String SEPARATOR_DOT_SNAPSHOT_DIR
121      = Path.SEPARATOR + DOT_SNAPSHOT_DIR; 
122}