API-Eulerian
view release on metacpan or search on metacpan
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
examples/edw/Rest.pl view on Meta::CPAN
my $status = $peer->request( $cmd );
if ( $status->error() ) {
$status->dump();
exit(1);
}
# Dump stages durations
$status->{ bench }->dump();
# Cancel the command
$peer->cancel();
1;
__END__
=head1 NAME
Rest.pl - Sample EDW script for querying through REST
examples/edw/Thin.pl view on Meta::CPAN
use strict; use warnings;
#
# Import API::Eulerian::EDW::Peer instance factory
#
use API::Eulerian::EDW::Peer;
#
# Import API::Eulerian::EDW::Hook::Print
#
use API::Eulerian::EDW::Hook::Print;
#
# Sanity check mandatory command file
#
unless( defined( $ARGV[ 0 ] ) ) {
die "Mandatory argument command file path is missing";
}
#
# Create a user specific Hook used to handle Analysis replies.
#
my $hook = new API::Eulerian::EDW::Hook::Print();
#
# Setup Peer options
#
my $path = $ARGV[ 0 ];
my %setup = (
class => 'API::Eulerian::EDW::Peer::Thin',
hook => $hook,
grid => '', # TODO
ip => '', # TODO
token => '', # TODO
);
my $status;
my $peer;
my $cmd;
# Read command from File
$status = Eulerian::File->read( $path );
if( $status->error() ) {
$status->dump();
} else {
# Get command from file
$cmd = $status->{ data };
# Create Peer instance
$peer = new API::Eulerian::EDW::Peer( \%setup );
# Send Command, call hook
$status = $peer->request( $cmd );
if( $status->error() ) {
$status->dump();
} else {
# Dump stages durations
$status->{ bench }->dump();
# Cancel the command
$peer->cancel();
}
}
lib/API/Eulerian/EDW/Peer.pm view on Meta::CPAN
=head3 output
=over 4
=item * Eulerian Data Warehouse Peer instance.
=back
=head2 request()
I<Send command to Eulerian Data Warehouse Platform>
=head3 input
=over 4
=item * command. Eulerian Data Warehouse command.
=back
=head3 output
=over 4
=item * API::Eulerian::EDW::Status.
=back
lib/API/Eulerian/EDW/Peer/Rest.pm view on Meta::CPAN
$url .= 'edw.ea.eulerian.com';
} elsif( $platform eq 'ca' ) {
$url .= 'edw.ea.eulerian.ca';
} else {
$url = undef;
}
return $url;
}
#
# @brief Get HTTP Request Body used to send command to Eulerian Data Warehouse
# Platform.
#
# @param $self - Eulerian Data Warehouse Rest Peer.
# @param $command - Eulerian Data Warehouse Command.
#
# @return HTTP Request Body.
#
sub body
{
my ( $self, $command ) = @_;
$command =~ s/\n//gm;
return JSON::encode_json({
kind => 'edw#request',
query => $command,
creationTime => POSIX::strftime( '%d/%m/%Y %H:%M:%S', gmtime() ),
location => Sys::Hostname::hostname(),
expiration => undef,
});
};
#
# @brief Setup HTTP Request Headers.
#
# @param $self - Eulerian Data Warehouse Peer.
#
lib/API/Eulerian/EDW/Peer/Rest.pm view on Meta::CPAN
$headers->push_header( 'Accept', $self->accept() );
$headers->push_header( 'Accept-Encoding', $self->encoding() );
}
return $status;
}
#
# @brief Create a new JOB on Eulerian Data Warehouse Rest Platform.
#
# @param $self - Eulerian Data Warehouse Peer.
# @param $command - Eulerian Data Warehouse Command.
#
# @return Reply content.
#
sub create
{
my ( $self, $command ) = @_;
my $response;
my $status;
# Create headers
$status = $self->headers();
if( ! $status->error() ) {
my $url = $self->url() . '/edw/jobs';
# Post Job create request to remote host
$status = API::Eulerian::EDW::Request->post(
$url, $status->{ headers }, $self->body( $command )
);
if( ! $status->error() ) {
$self->uuid(
API::Eulerian::EDW::Request->json(
$status->{ response }
)->{ data }->[ 0 ]
);
}
}
lib/API/Eulerian/EDW/Peer/Rest.pm view on Meta::CPAN
$status->msg( "Unknown file format" );
$status->code( 401 );
}
return $status;
}
#
# @brief Do Request on Eulerian Data Warehouse Platform.
#
# @param $self - Eulerian Data Warehouse Peer.
# @param $command - Eulerian Data Warehouse Command.
#
use Data::Dumper;
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' );
lib/API/Eulerian/EDW/Peer/Thin.pm view on Meta::CPAN
$url .= $self->host() . ':';
$url .= $ports->[ $secure ] . '/edwreader/';
$url .= $aes if( defined( $aes ) );
return $url;
}
#
# @brief Create a new JOB on Eulerian Data Warehouse Rest Platform.
#
# @param $self - Eulerian Data Warehouse Peer.
# @param $command - Eulerian Data Warehouse Command.
#
# @return Reply context.
#
use Data::Dumper;
sub create
{
my ( $self, $command ) = @_;
my $response;
my $status;
# Get Valid Headers
$status = $self->headers();
if( ! $status->error() ) {
# Post new JOB to Eulerian Data Warehouse Platform
$status = API::Eulerian::EDW::Request->post(
$self->url(), $status->{ headers }, $command, 'text/plain'
);
if( ! $status->error() ) {
my $json = API::Eulerian::EDW::Request->json( $status->{ response } );
if( defined( $json ) && $json->{ status }->[ 1 ] != 0 ) {
$status = API::Eulerian::EDW::Status->new();
$status->error( 1 );
$status->msg( $json->{ status }->[ 0 ] );
$status->code( $json->{ status }->[ 1 ] );
}
}
lib/API/Eulerian/EDW/Peer/Thin.pm view on Meta::CPAN
$self->host(), $self->ports()->[ $self->secure() ]
);
my $url = $self->url( $json->{ aes } );
$ws->{ _THIN } = $self;
return $ws->join( $url, \&dispatcher );
}
#
# @brief Do Request on Eulerian Data Warehouse Platform.
#
# @param $self - Eulerian Data Warehouse Peer.
# @param $command - Eulerian Data Warehouse Command.
#
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' );
if( ! $status->error() ) {
# Join Websocket call user specific callback hook
$bench->start();
$status = $self->join( $status );
$bench->stage( 'join' );
$status->{ bench } = $bench;
}
lib/API/Eulerian/EDW/Peer/Thin.pm view on Meta::CPAN
#
sub cancel
{
my ( $self ) = @_;
my $status;
# Get Valid Headers
$status = $self->headers();
if( ! $status->error() && exists( $self->{ uuid } ) ) {
my $uuid = $self->{ uuid };
my $command = "KILL $uuid;";
# Post new JOB to Eulerian Data Warehouse Platform
$status = API::Eulerian::EDW::Request->post(
$self->url(), $status->{ headers }, $command, 'text/plain'
);
}
return $status;
}
#
# End Up module properly
#
1;
( run in 1.019 second using v1.01-cache-2.11-cpan-2e0ccfb7a10 )