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      private boolean encryptDataTransfer;
052      private long trashInterval;
053    
054      public FsServerDefaults() {
055      }
056    
057      public FsServerDefaults(long blockSize, int bytesPerChecksum,
058          int writePacketSize, short replication, int fileBufferSize,
059          boolean encryptDataTransfer, long trashInterval) {
060        this.blockSize = blockSize;
061        this.bytesPerChecksum = bytesPerChecksum;
062        this.writePacketSize = writePacketSize;
063        this.replication = replication;
064        this.fileBufferSize = fileBufferSize;
065        this.encryptDataTransfer = encryptDataTransfer;
066        this.trashInterval = trashInterval;
067      }
068    
069      public long getBlockSize() {
070        return blockSize;
071      }
072    
073      public int getBytesPerChecksum() {
074        return bytesPerChecksum;
075      }
076    
077      public int getWritePacketSize() {
078        return writePacketSize;
079      }
080    
081      public short getReplication() {
082        return replication;
083      }
084    
085      public int getFileBufferSize() {
086        return fileBufferSize;
087      }
088      
089      public boolean getEncryptDataTransfer() {
090        return encryptDataTransfer;
091      }
092    
093      public long getTrashInterval() {
094        return trashInterval;
095      }
096    
097      // /////////////////////////////////////////
098      // Writable
099      // /////////////////////////////////////////
100      @InterfaceAudience.Private
101      public void write(DataOutput out) throws IOException {
102        out.writeLong(blockSize);
103        out.writeInt(bytesPerChecksum);
104        out.writeInt(writePacketSize);
105        out.writeShort(replication);
106        out.writeInt(fileBufferSize);
107      }
108    
109      @InterfaceAudience.Private
110      public void readFields(DataInput in) throws IOException {
111        blockSize = in.readLong();
112        bytesPerChecksum = in.readInt();
113        writePacketSize = in.readInt();
114        replication = in.readShort();
115        fileBufferSize = in.readInt();
116      }
117    }