@@ -0,0 +1,2751 @@
+/**%0A * Licensed to the Apache Software Foundation (ASF) under one%0A * or more contributor license agreements.  See the NOTICE file%0A * distributed with this work for additional information%0A * regarding copyright ownership.  The ASF licenses this file%0A * to you under the Apache License, Version 2.0 (the%0A * %22License%22); you may not use this file except in compliance%0A * with the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage org.apache.hadoop.io;%0A%0Aimport org.apache.commons.logging.Log;%0Aimport org.apache.commons.logging.LogFactory;%0Aimport org.apache.hadoop.util.Shell;%0A%0Aimport java.io.*;%0Aimport java.nio.channels.Channels;%0Aimport java.nio.channels.FileChannel;%0A%0A/**%0A * This class is substitute for FileInputStream.Cause FileInputStream cause GC%0A * pause for a long time.%0A */%0Apublic class AltFileInputStream extends InputStream %7B%0A  public static final Log LOG = LogFactory.getLog(AltFileInputStream.class);%0A%0A  // For non-Windows%0A  private final InputStream inputStream;%0A  private final FileDescriptor fd;%0A  private final FileChannel fileChannel;%0A%0A  // For Windows%0A  private FileInputStream fileInputStream;%0A%0A  public AltFileInputStream(File file) throws IOException %7B%0A    if (!Shell.WINDOWS) %7B%0A      RandomAccessFile rf = new RandomAccessFile(file, %22r%22);%0A      this.fd = rf.getFD();%0A      this.fileChannel = rf.getChannel();%0A      this.inputStream = Channels.newInputStream(fileChannel);%0A    %7D else %7B%0A      FileInputStream fis = new FileInputStream(file);%0A      this.fileInputStream = fis;%0A      this.inputStream = fileInputStream;%0A      this.fd = fis.getFD();%0A      this.fileChannel = fis.getChannel();%0A    %7D%0A  %7D%0A%0A  public AltFileInputStream(FileDescriptor fd, FileChannel fileChannel) %7B%0A    this.fd = fd;%0A    this.fileChannel = fileChannel;%0A    this.inputStream = Channels.newInputStream(fileChannel);%0A  %7D%0A%0A  public AltFileInputStream(FileInputStream fis) throws IOException %7B%0A    this.fileInputStream = fis;%0A    this.inputStream = fileInputStream;%0A    this.fd = fis.getFD();%0A    this.fileChannel = fis.getChannel();%0A  %7D%0A%0A  public FileDescriptor getFD() throws IOException %7B%0A    return fd;%0A  %7D%0A%0A  public FileChannel getChannel() %7B%0A    return fileChannel;%0A  %7D%0A%0A  @Override%0A  public int read() throws IOException%7B%0A    return inputStream.read();%0A  %7D%0A%0A  @Override%0A  public void close() throws IOException %7B%0A    fileChannel.close();%0A    inputStream.close();%0A  %7D%0A%7D

update AltFileInputStream.java