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 import org.apache.hadoop.io.WritableUtils; 030 import org.apache.hadoop.util.DataChecksum; 031 032 /**************************************************** 033 * Provides server default configuration values to clients. 034 * 035 ****************************************************/ 036 @InterfaceAudience.Public 037 @InterfaceStability.Evolving 038 public class FsServerDefaults implements Writable { 039 040 static { // register a ctor 041 WritableFactories.setFactory(FsServerDefaults.class, new WritableFactory() { 042 public Writable newInstance() { 043 return new FsServerDefaults(); 044 } 045 }); 046 } 047 048 private long blockSize; 049 private int bytesPerChecksum; 050 private int writePacketSize; 051 private short replication; 052 private int fileBufferSize; 053 private boolean encryptDataTransfer; 054 private long trashInterval; 055 private int checksumType; 056 057 public FsServerDefaults() { 058 } 059 060 public FsServerDefaults(long blockSize, int bytesPerChecksum, 061 int writePacketSize, short replication, int fileBufferSize, 062 boolean encryptDataTransfer, long trashInterval, 063 int checksumType) { 064 this.blockSize = blockSize; 065 this.bytesPerChecksum = bytesPerChecksum; 066 this.writePacketSize = writePacketSize; 067 this.replication = replication; 068 this.fileBufferSize = fileBufferSize; 069 this.encryptDataTransfer = encryptDataTransfer; 070 this.trashInterval = trashInterval; 071 this.checksumType = checksumType; 072 } 073 074 public long getBlockSize() { 075 return blockSize; 076 } 077 078 public int getBytesPerChecksum() { 079 return bytesPerChecksum; 080 } 081 082 public int getWritePacketSize() { 083 return writePacketSize; 084 } 085 086 public short getReplication() { 087 return replication; 088 } 089 090 public int getFileBufferSize() { 091 return fileBufferSize; 092 } 093 094 public boolean getEncryptDataTransfer() { 095 return encryptDataTransfer; 096 } 097 098 public long getTrashInterval() { 099 return trashInterval; 100 } 101 102 public int getChecksumType() { 103 return checksumType; 104 } 105 106 // ///////////////////////////////////////// 107 // Writable 108 // ///////////////////////////////////////// 109 @InterfaceAudience.Private 110 public void write(DataOutput out) throws IOException { 111 out.writeLong(blockSize); 112 out.writeInt(bytesPerChecksum); 113 out.writeInt(writePacketSize); 114 out.writeShort(replication); 115 out.writeInt(fileBufferSize); 116 out.writeInt(checksumType); 117 } 118 119 @InterfaceAudience.Private 120 public void readFields(DataInput in) throws IOException { 121 blockSize = in.readLong(); 122 bytesPerChecksum = in.readInt(); 123 writePacketSize = in.readInt(); 124 replication = in.readShort(); 125 fileBufferSize = in.readInt(); 126 checksumType = in.readInt(); 127 } 128 }