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     */
018    package org.apache.hadoop.hdfs.protocol;
019    
020    import org.apache.hadoop.classification.InterfaceAudience;
021    import org.apache.hadoop.hdfs.DFSConfigKeys;
022    import org.apache.hadoop.hdfs.HdfsConfiguration;
023    
024    /************************************
025     * Some handy constants
026     * 
027     ************************************/
028    @InterfaceAudience.Private
029    public class HdfsConstants {
030      /* Hidden constructor */
031      protected HdfsConstants() {
032      }
033      
034      /**
035       * HDFS Protocol Names:  
036       */
037      public static final String CLIENT_NAMENODE_PROTOCOL_NAME = 
038          "org.apache.hadoop.hdfs.protocol.ClientProtocol";
039      public static final String CLIENT_DATANODE_PROTOCOL_NAME = 
040          "org.apache.hadoop.hdfs.protocol.ClientDatanodeProtocol";
041      
042      
043      public static int MIN_BLOCKS_FOR_WRITE = 5;
044    
045      // Long that indicates "leave current quota unchanged"
046      public static final long QUOTA_DONT_SET = Long.MAX_VALUE;
047      public static final long QUOTA_RESET = -1L;
048    
049      //
050      // Timeouts, constants
051      //
052      public static final long LEASE_SOFTLIMIT_PERIOD = 60 * 1000;
053      public static final long LEASE_HARDLIMIT_PERIOD = 60 * LEASE_SOFTLIMIT_PERIOD;
054      public static final long LEASE_RECOVER_PERIOD = 10 * 1000; // in ms
055    
056      // We need to limit the length and depth of a path in the filesystem.
057      // HADOOP-438
058      // Currently we set the maximum length to 8k characters and the maximum depth
059      // to 1k.
060      public static int MAX_PATH_LENGTH = 8000;
061      public static int MAX_PATH_DEPTH = 1000;
062    
063      // TODO should be conf injected?
064      public static final int DEFAULT_DATA_SOCKET_SIZE = 128 * 1024;
065      public static final int IO_FILE_BUFFER_SIZE = new HdfsConfiguration().getInt(
066          DFSConfigKeys.IO_FILE_BUFFER_SIZE_KEY,
067          DFSConfigKeys.IO_FILE_BUFFER_SIZE_DEFAULT);
068      // Used for writing header etc.
069      public static final int SMALL_BUFFER_SIZE = Math.min(IO_FILE_BUFFER_SIZE / 2,
070          512);
071    
072      public static final int BYTES_IN_INTEGER = Integer.SIZE / Byte.SIZE;
073    
074      // SafeMode actions
075      public static enum SafeModeAction {
076        SAFEMODE_LEAVE, SAFEMODE_ENTER, SAFEMODE_GET;
077      }
078    
079      // type of the datanode report
080      public static enum DatanodeReportType {
081        ALL, LIVE, DEAD
082      }
083    
084      // An invalid transaction ID that will never be seen in a real namesystem.
085      public static final long INVALID_TXID = -12345;
086    
087      /**
088       * URI Scheme for hdfs://namenode/ URIs.
089       */
090      public static final String HDFS_URI_SCHEME = "hdfs";
091    
092      /**
093       * A prefix put before the namenode URI inside the "service" field
094       * of a delgation token, indicating that the URI is a logical (HA)
095       * URI.
096       */
097      public static final String HA_DT_SERVICE_PREFIX = "ha-hdfs:";
098    
099    
100      /**
101       * Please see {@link LayoutVersion} on adding new layout version.
102       */
103      public static final int LAYOUT_VERSION = LayoutVersion
104          .getCurrentLayoutVersion();
105    }