/** * Constructor FSDigestInputStream creates a new FSDigestInputStream instance. * * @param inputStream of type InputStream * @param digestHex of type String * @throws IOException if unable to get md5 digest */ public FSDigestInputStream( InputStream inputStream, String digestHex ) throws IOException { this( inputStream, getMD5Digest(), digestHex ); }
@Override public void seek( long pos ) throws IOException { if( getPos() == pos ) return; if( getPos() > pos ) throw new IOException( "cannot seek to " + pos + ", currently at" + getPos() ); int len = (int) ( pos - getPos() ); byte[] bytes = new byte[ 50 * 1024 ]; while( len > 0 ) len -= read( bytes, 0, Math.min( len, bytes.length ) ); }
@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 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 void seek( long pos ) throws IOException { if( getPos() == pos ) return; if( getPos() > pos ) throw new IOException( "cannot seek to " + pos + ", currently at" + getPos() ); int len = (int) ( pos - getPos() ); byte[] bytes = new byte[ 50 * 1024 ]; while( len > 0 ) len -= read( bytes, 0, Math.min( len, bytes.length ) ); }
/** * Constructor FSDigestInputStream creates a new FSDigestInputStream instance. * * @param inputStream of type InputStream * @param digestHex of type String * @throws IOException if unable to get md5 digest */ public FSDigestInputStream( InputStream inputStream, String digestHex ) throws IOException { this( inputStream, getMD5Digest(), digestHex ); }