Hadoop-HDFS-Command
view release on metacpan or search on metacpan
lib/Hadoop/HDFS/Command.pm view on Meta::CPAN
$options,
$self->cmd_hdfs,
qw( dfs -test ),
( map { '-' . $_ } grep { $arg->{ $_ } } @flags ),
@{ $paths },
);
return 1;
} or return 0;
}
sub _dfs_mkdir {
my $self = shift;
my $options = shift;
my @params = @_;
my @flags = qw( p );
my($arg, $paths) = $self->_parse_options(
\@params,
\@flags,
undef,
{
require_params => 1,
},
);
my @response = $self->_capture(
$options,
$self->cmd_hdfs,
qw( dfs -mkdir ),
( map { '-' . $_ } grep { $arg->{ $_ } } @flags ),
@{ $paths },
);
# just a confirmation message
return @response
}
sub _dfs_chmod {
my $self = shift;
my $options = shift;
my @params = @_;
my @flags = qw( p );
my($arg, $paths) = $self->_parse_options(
\@params,
\@flags,
undef,
{
require_params => 1,
},
);
my @response = $self->_capture(
$options,
$self->cmd_hdfs,
qw( dfs -chmod ),
( map { '-' . $_ } grep { $arg->{ $_ } } @flags ),
@{ $paths },
);
# just a confirmation message
return @response
}
sub _dfs_chown {
my $self = shift;
my $options = shift;
my @params = @_;
my @flags = qw( p );
my($arg, $paths) = $self->_parse_options(
\@params,
\@flags,
undef,
{
require_params => 1,
},
);
my @response = $self->_capture(
$options,
$self->cmd_hdfs,
qw( dfs -chown ),
( map { '-' . $_ } grep { $arg->{ $_ } } @flags ),
@{ $paths },
);
# just a confirmation message
return @response
}
sub _dfs_get {
my $self = shift;
my $options = shift;
my @params = @_;
my @flags = qw( p ignoreCrc crc );
my($arg, $paths) = $self->_parse_options(
\@params,
\@flags,
undef,
{
require_params => 1,
},
);
my @response = $self->_capture(
$options,
$self->cmd_hdfs,
qw( dfs -get ),
( map { '-' . $_ } grep { $arg->{ $_ } } @flags ),
@{ $paths },
);
# just a confirmation message
return @response
}
sub _dfs_getfacl {
my $self = shift;
my $options = shift;
my @params = @_;
my @flags = qw( R );
my($arg, $paths) = $self->_parse_options(
\@params,
\@flags,
undef,
{
require_params => 1,
},
);
my @response = $self->_capture(
$options,
$self->cmd_hdfs,
qw( dfs -getfacl ),
( map { '-' . $_ } grep { $arg->{ $_ } } @flags ),
@{ $paths },
);
my %rv;
for my $line ( @response ) {
if ( my($match) = $line =~ m{ \A [#] \s+ (.*) \z }xms ) {
my($k, $v) = split m{ [:] \s+ }xms, $match, 2;
$rv{ $k } = $v;
lib/Hadoop/HDFS/Command.pm view on Meta::CPAN
# skip this one, but continue processing
return 1 if $file->{type} ne 'file';
# do something
return if $something_really_bad_so_end_this_processor;
# continue processing
return 1;
},
# The meta-data passed to the callback will have an "epoch"
# key set when this is true.
want_epoch => 1,
);
# execute the command recursively on the path
$hdfs->dfs( \%options, ls => -R => $hdfs_path );
=head3 mv
my @rv = $hdfs->dfs( mv => $hdfs_source_path, $hdfs_dest_path );
=head3 put
The C<@subcommand_args> can have these defined: C<-f>, C<-p>, C<-l>
$hdfs->dfs( put => @subcommand_args, $local_path, $hdfs_path );
# notice the additional "-"
$hdfs->dfs( put => '-f', '-', $hdfs_path, $in_memory_data );
=head3 rm
The C<@subcommand_args> can have these defined: C<-f>, C<-r>, C<-skipTrash>
$hdfs->dfs( rm => @subcommand_args, $hdfs_path );
=head3 setfacl
The C<@subcommand_args> can have these defined: C<-b>, C<-k>, C<-m acl_spec>,
C<-x acl_spec>, C<--set acl_spec>
$hdfs->dfs( setfacl => @subcommand_args, $hdfs_path );
=head3 test
The C<@subcommand_args> can have these defined: C<-d>, C<-e>, C<-f>, C<-s>, C<-z>
$hdfs->dfs( test => @subcommand_args, $hdfs_path );
=head3 mkdir
The C<@subcommand_args> can have these defined: C<-p>
$hdfs->dfs( mkdir => @subcommand_args, $path );
=head3 chmod
The C<@subcommand_args> can have these defined: C<-R>
$hdfs->dfs( chmod => @subcommand_args, $mode, $path );
=head3 chown
The C<@subcommand_args> can have these defined: C<-R>
$hdfs->dfs( chown => @subcommand_args, $OWNERCOLONGROUP, $path );
=head3 get
The C<@subcommand_args> can have these defined: C<-p>, C<-ignoreCrc>, C<-crc>
$hdfs->dfs( get => @subcommand_args, $src, $localdst );
=head1 SEE ALSO
C<`hdfs dfs -help`>.
=head1 AUTHOR
Burak Gursoy <burak@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Burak Gursoy.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
( run in 0.698 second using v1.01-cache-2.11-cpan-71847e10f99 )