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.hdfs.protocol; 19 20 import java.io.DataInputStream; 21 import java.io.DataOutputStream; 22 import java.io.IOException; 23 24 import org.apache.hadoop.classification.InterfaceAudience; 25 26 import com.google.common.base.Joiner; 27 import com.google.common.base.Preconditions; 28 import com.google.common.collect.ImmutableSet; 29 import com.google.common.collect.Sets; 30 31 /** 32 * LayoutFlags represent features which the FSImage and edit logs can either 33 * support or not, independently of layout version. 34 * 35 * Note: all flags starting with 'test' are reserved for unit test purposes. 36 */ 37 @InterfaceAudience.Private 38 public class LayoutFlags { 39 /** 40 * Load a LayoutFlags object from a stream. 41 * 42 * @param in The stream to read from. 43 * @throws IOException 44 */ read(DataInputStream in)45 public static LayoutFlags read(DataInputStream in) 46 throws IOException { 47 int length = in.readInt(); 48 if (length < 0) { 49 throw new IOException("The length of the feature flag section " + 50 "was negative at " + length + " bytes."); 51 } else if (length > 0) { 52 throw new IOException("Found feature flags which we can't handle. " + 53 "Please upgrade your software."); 54 } 55 return new LayoutFlags(); 56 } 57 LayoutFlags()58 private LayoutFlags() { 59 } 60 write(DataOutputStream out)61 public static void write(DataOutputStream out) throws IOException { 62 out.writeInt(0); 63 } 64 } 65