@Override public boolean exists( Path path ) throws IOException { URL url = makeUrl( path ); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod( "HEAD" ); connection.connect(); debugConnection( connection ); return connection.getResponseCode() == 200; }
@Override public FileStatus[] globStatus( Path path, PathFilter pathFilter ) throws IOException { FileStatus fileStatus = getFileStatus( path ); if( fileStatus == null ) return null; return new FileStatus[]{fileStatus}; }
@Override public FSDataInputStream open( Path path, int i ) throws IOException { URL url = makeUrl( path ); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod( "GET" ); connection.connect(); debugConnection( connection ); return new FSDataInputStream( new FSDigestInputStream( connection.getInputStream(), getMD5SumFor( getConf(), path ) ) ); }
@Override public FileStatus getFileStatus( Path path ) throws IOException { URL url = makeUrl( path ); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod( "HEAD" ); connection.connect(); debugConnection( connection ); if( connection.getResponseCode() != 200 ) throw new FileNotFoundException( "could not find file: " + path ); long length = connection.getHeaderFieldInt( "Content-Length", 0 ); length = length < 0 ? 0 : length; // queries may return -1 long modified = connection.getHeaderFieldDate( "Last-Modified", System.currentTimeMillis() ); return new FileStatus( length, false, 1, getDefaultBlockSize(), modified, path ); }
@Override public void initialize( URI uri, Configuration configuration ) throws IOException { setConf( configuration ); scheme = uri.getScheme(); authority = uri.getAuthority(); }
@Override public FSDataInputStream open( Path path, int i ) throws IOException { URL url = makeUrl( path ); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod( "GET" ); connection.connect(); debugConnection( connection ); return new FSDataInputStream( new FSDigestInputStream( connection.getInputStream(), getMD5SumFor( getConf(), path ) ) ); }
@Override public FileStatus getFileStatus( Path path ) throws IOException { URL url = makeUrl( path ); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod( "HEAD" ); connection.connect(); debugConnection( connection ); if( connection.getResponseCode() != 200 ) throw new FileNotFoundException( "could not find file: " + path ); long length = connection.getHeaderFieldInt( "Content-Length", 0 ); length = length < 0 ? 0 : length; // queries may return -1 long modified = connection.getHeaderFieldDate( "Last-Modified", System.currentTimeMillis() ); return new FileStatus( length, false, 1, getDefaultBlockSize(), modified, path ); }
@Override public void initialize( URI uri, Configuration configuration ) throws IOException { setConf( configuration ); scheme = uri.getScheme(); authority = uri.getAuthority(); }
@Override public boolean exists( Path path ) throws IOException { URL url = makeUrl( path ); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod( "HEAD" ); connection.connect(); debugConnection( connection ); return connection.getResponseCode() == 200; }
@Override public FileStatus[] globStatus( Path path, PathFilter pathFilter ) throws IOException { FileStatus fileStatus = getFileStatus( path ); if( fileStatus == null ) return null; return new FileStatus[]{fileStatus}; }