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.fs;
019    
020    import java.io.DataInput;
021    import java.io.DataOutput;
022    import java.io.IOException;
023    
024    import org.apache.hadoop.classification.InterfaceAudience;
025    import org.apache.hadoop.classification.InterfaceStability;
026    import org.apache.hadoop.io.Writable;
027    import org.apache.hadoop.io.WritableFactories;
028    import org.apache.hadoop.io.WritableFactory;
029    
030    /****************************************************
031     * Provides server default configuration values to clients.
032     * 
033     ****************************************************/
034    @InterfaceAudience.Public
035    @InterfaceStability.Evolving
036    public class FsServerDefaults implements Writable {
037    
038      static { // register a ctor
039        WritableFactories.setFactory(FsServerDefaults.class, new WritableFactory() {
040          public Writable newInstance() {
041            return new FsServerDefaults();
042          }
043        });
044      }
045    
046      private long blockSize;
047      private int bytesPerChecksum;
048      private int writePacketSize;
049      private short replication;
050      private int fileBufferSize;
051    
052      public FsServerDefaults() {
053      }
054    
055      public FsServerDefaults(long blockSize, int bytesPerChecksum,
056          int writePacketSize, short replication, int fileBufferSize) {
057        this.blockSize = blockSize;
058        this.bytesPerChecksum = bytesPerChecksum;
059        this.writePacketSize = writePacketSize;
060        this.replication = replication;
061        this.fileBufferSize = fileBufferSize;
062      }
063    
064      public long getBlockSize() {
065        return blockSize;
066      }
067    
068      public int getBytesPerChecksum() {
069        return bytesPerChecksum;
070      }
071    
072      public int getWritePacketSize() {
073        return writePacketSize;
074      }
075    
076      public short getReplication() {
077        return replication;
078      }
079    
080      public int getFileBufferSize() {
081        return fileBufferSize;
082      }
083    
084      // /////////////////////////////////////////
085      // Writable
086      // /////////////////////////////////////////
087      @InterfaceAudience.Private
088      public void write(DataOutput out) throws IOException {
089        out.writeLong(blockSize);
090        out.writeInt(bytesPerChecksum);
091        out.writeInt(writePacketSize);
092        out.writeShort(replication);
093        out.writeInt(fileBufferSize);
094      }
095    
096      @InterfaceAudience.Private
097      public void readFields(DataInput in) throws IOException {
098        blockSize = in.readLong();
099        bytesPerChecksum = in.readInt();
100        writePacketSize = in.readInt();
101        replication = in.readShort();
102        fileBufferSize = in.readInt();
103      }
104    }