API-Eulerian
view release on metacpan or search on metacpan
lib/API/Eulerian/EDW/Peer/Rest.pm view on Meta::CPAN
sub request
{
my ( $self, $command ) = @_;
my $bench = new API::Eulerian::EDW::Bench();
my $response;
my $status;
my $json;
# Create Job on Eulerian Data Warehouse Platform
$bench->start();
$status = $self->create( $command );
$bench->stage( 'create' );
# Wait end of Job
$bench->start();
while( ! $status->error() && $self->running( $status ) ) {
$status = $self->status( $status );
sleep( 2 );
}
$bench->stage( 'running' );
# If Done, download reply file
if( ! $status->error() && $self->done( $status ) ) {
$bench->start();
$status = $self->download( $status );
$bench->stage( 'download' );
if( ! $status->error() ) {
# Parse reply file, call hooks
$bench->start();
$status = $self->parse( $status );
$bench->stage( 'parse' );
}
$status->{ bench } = $bench;
} else {
print "ERROR : " . Dumper( $status ) . "\n";
}
return $status;
}
#
# @brief Cancel Job on Eulerian Data Warehouse Platform.
#
# @param $self - API::Eulerian::EDW::Rest instance.
# @param $rc - Reply context.
#
sub cancel
{
my ( $self ) = @_;
my $status;
# Get HTTP request headers
$status = $self->headers();
if( ! $status->error() ) {
my $headers = $status->{ headers };
delete $status->{ headers };
# Create cancel job url
if( ! $self->uuid() ) {
$status->error( 1 );
$status->msg( "Failed to cancel Job. Unknown UUID" );
$status->code( 404 );
} else {
my $url = $self->url() . '/edw/jobs/';
$url .= $self->uuid() . '/cancel';
# Send Cancel request to remote host
$status = API::Eulerian::EDW::Request->get( $url, $headers );
}
}
return $status;
}
#
# @brief Drop Eulerian Data Warehouse Object Events.
#
# @param $self - Peer.
# @param $what - Object Path.
# @param $site - Site.
# @param $from - Day begin.
# @param $end - Day end.
#
sub drop
{
my ( $self, $what, $site, $from, $to ) = @_;
my $status;
# Get HTTP request headers
$status = $self->headers();
if( ! $status->error() ) {
my $headers = $status->{ headers };
my $url = $self->url() . '/edw/store';
my $cmd = "DROP $what\@$site FROM $from TO $to;";
delete $status->{ headers };
# Send Cancel request to remote host
$status = API::Eulerian::EDW::Request->post(
$url, $headers, $self->body( $cmd )
);
}
return $status;
}
#
# End Up module properly
#
1;
( run in 1.015 second using v1.01-cache-2.11-cpan-39bf76dae61 )