    001/*
    002 * Copyright (c) 2007-2017 Xplenty, Inc. All Rights Reserved.
    003 *
    004 * Project and contact information: http://www.cascading.org/
    005 *
    006 * This file is part of the Cascading project.
    007 *
    008 * Licensed under the Apache License, Version 2.0 (the "License");
    009 * you may not use this file except in compliance with the License.
    010 * You may obtain a copy of the License at
    011 *
    012 *     http://www.apache.org/licenses/LICENSE-2.0
    013 *
    014 * Unless required by applicable law or agreed to in writing, software
    015 * distributed under the License is distributed on an "AS IS" BASIS,
    016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    017 * See the License for the specific language governing permissions and
    018 * limitations under the License.
    019 */
    020
    021package cascading.tap.hadoop.io;
    022
    023import java.io.IOException;
    024
    025import org.apache.hadoop.conf.Configuration;
    026import org.apache.hadoop.fs.FSDataOutputStream;
    027import org.apache.hadoop.fs.FileStatus;
    028import org.apache.hadoop.fs.FileSystem;
    029import org.apache.hadoop.fs.Path;
    030import org.apache.hadoop.fs.permission.FsPermission;
    031import org.apache.hadoop.util.Progressable;
    032
    033/** Class StreamedFileSystem is a base class for {@link FileSystem} implementations that manage remote resources. */
    034public abstract class StreamedFileSystem extends FileSystem
    035  {
    036  @Override
    037  public FSDataOutputStream create( Path path, FsPermission permission, boolean overwrite, int bufferSize, short replication, long blockSize, Progressable progress ) throws IOException
    038    {
    039    throw new UnsupportedOperationException( "not supported" );
    040    }
    041
    042  @Override
    043  public boolean rename( Path path, Path path1 ) throws IOException
    044    {
    045    throw new UnsupportedOperationException( "not supported" );
    046    }
    047
    048  @Deprecated
    049  @Override
    050  public boolean delete( Path path ) throws IOException
    051    {
    052    throw new UnsupportedOperationException( "not supported" );
    053    }
    054
    055  @Override
    056  public boolean delete( Path path, boolean b ) throws IOException
    057    {
    058    throw new UnsupportedOperationException( "not supported" );
    059    }
    060
    061  @Override
    062  public Path getWorkingDirectory()
    063    {
    064    return new Path( "/" ).makeQualified( this );
    065    }
    066
    067  @Override
    068  public void setWorkingDirectory( Path f )
    069    {
    070    }
    071
    072  @Override
    073  public boolean mkdirs( Path path, FsPermission fsPermission ) throws IOException
    074    {
    075    throw new UnsupportedOperationException( "not supported" );
    076    }
    077
    078  @Override
    079  public FileStatus[] listStatus( Path path ) throws IOException
    080    {
    081    return new FileStatus[]{getFileStatus( path )};
    082    }
    083
    084  public FSDataOutputStream append( Path f, int bufferSize, Progressable progress ) throws IOException
    085    {
    086    throw new UnsupportedOperationException( "not supported" );
    087    }
    088
    089  public static String getMD5SumFor( Configuration conf, Path path )
    090    {
    091    return getMD5SumFor( conf, path.toString() );
    092    }
    093
    094  public static String getMD5SumFor( Configuration conf, String path )
    095    {
    096    return conf.get( path + ".md5" );
    097    }
    098
    099  public static void setMD5SumFor( Configuration conf, Path path, String md5Hex )
    100    {
    101    setMD5SumFor( conf, path.toString(), md5Hex );
    102    }
    103
    104  public static void setMD5SumFor( Configuration conf, String path, String md5Hex )
    105    {
    106    if( md5Hex == null || md5Hex.length() == 0 )
    107      return;
    108
    109    conf.set( path + ".md5", md5Hex );
    110    }
    111  }