Apache-Hadoop-WebHDFS

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Apache-Hadoop-WebHDFS

0.04    Aug 6, 2013 - 
        . Bumping version number so cpan will correctly index the latest version

0.03.1  Aug 5, 2013 - 
        . Bug Fix - Fixed transposed variables in rename method
        

0.03    July 15, 2013 - 
        . NOTE THIS UPDATE BREAKS BACKWARD COMPATIBLITY WITH v0.01 and v.02 
        . Adding 'contentsummary' method
        . Adding 'gethomedirectory' method
        . Adding 'setreplication' method
        . Adding 'settimes' method
        . Adding 'setpermssion' method
        . Adding 'offset', 'length', 'buffersize' to Open.  

lib/Apache/Hadoop/WebHDFS.pm  view on Meta::CPAN

       $url = 'http://' . $self->{'namenode'} . ':' . $self->{'namenodeport'} . '/webhdfs/v1' . $path . '?op=LISTSTATUS' . '&user.name=' . $self->{'user'} . '&doas=' . $self->{'doas_user'};
	}

    if ( $self->{'webhdfstoken'} ) {
        $url = $url . "&delegation=" . $self->{'webhdfstoken'};
    }
    $self->get( $url );
    return $self;
}

sub rename {
	# curl -i -X PUT "<HOST>:<PORT>/webhdfs/v1/<PATH>?op=RENAME&destination=<PATH>"
	#my $url = 'http://' . $self->{'namenode'} . ':' . $self->{'namenodeport'} . '/webhdfs/v1' . $src . '?op=RENAME&destination=' . $dst;

    my ( $self, $src, $dst ) = undef;
    $self = shift; 
    if ($_[0]->{'srcfile'})     { $src  = $_[0]->{'srcfile'}; } else { croak ("Need HDFS source before rename can happen") ;}
    if ($_[0]->{'dstfile'})     { $dst = $_[0]->{'dstfile'}; } else { croak ("Need HDFS destination before rename can happen") ;}
	
    my $url;
	if ($self->{'authmethod'} eq 'gssapi') { 
       $url = 'http://' . $self->{'namenode'} . ':' . $self->{'namenodeport'} . '/webhdfs/v1' . $src . '?op=RENAME&destination=' . $dst ;
	} elsif ( $self->{'authmethod'} eq 'unsecure' ) {
       croak ("I need a 'user' value if authmethod is 'none'") if ( !$self->{'user'} ) ;
       $url = 'http://' . $self->{'namenode'} . ':' . $self->{'namenodeport'} . '/webhdfs/v1' . $src . '?op=RENAME&destination=' . $dst . '&user.name=' . $self->{'user'};	
	} elsif ( $self->{'authmethod'} eq 'doas' ) {
       croak ("I need a 'user' value if authmethod is 'doas'") if ( !$self->{'user'} ) ;
       croak ("I need a 'doas_user' value if authmethod is 'doas'") if ( !$self->{'doas_user'} ) ;

lib/Apache/Hadoop/WebHDFS.pm  view on Meta::CPAN


         $hdfsclient->create({ srcfile=>'/my/local/file.txt',
                               dstfile=>'/my/hdfs/location/file.txt',
                               blocksize=>'524288',
                               replication=>'3',
                               buffersize=>'1024',
                               overwrite=>'true|false',
                               permission=>'644',
                              });

=item * rename()  - renames a file on HDFS.  Required values for rename are 'srcfile' and 'dstfile', both of which represent HDFS filenames.
  
         $hdfsclient->rename({ srcfile=>'/my/old/hdfs/file.txt',
                               dstfile=>'my/new/hdfs/file.txt',
                             });

=item * getfilestatus() - returns a json structure containing status of file or directory.  Required input is a HDFS path.
   
         $hdfsclient->getfilestatus({ file=>'/path/to/my/hdfs/file.txt' });

=item * liststatus() - returns a json structure of contents inside a directory.  Note the timestamps are java timestamps so divide by 1000 to convert to ctime before attempting to format time value.
   
         $hdfsclient->liststatus({ path=>'/path/to/my/hdfs/directory' });



( run in 1.020 second using v1.01-cache-2.11-cpan-131fc08a04b )