NAME

GRID::Machine::REMOTE - The server that runs on the other side of the SSH link

DESCRIPTION

The Structure of the Remote Server

As with most servers, the server side of the GRID::Machine object consists of an infinite loop waiting for requests:

while( 1 ) {
   my ( $operation, @args ) = $server->read_operation();

   if ($server->can($operation)) {
     $server->$operation(@args);
     next;
   }

   $server->send_error( "Unknown operation $operation\nARGS: @args\n" );
}

The Protocol

The protocol simply consists of the name of the method to execute and the arguments for such method. The programmer - using inheritance - can extend the protocol with new methods (see the section "EXTENDING THE PROTOCOL"). The following operations are currently supported:

  • GRID::Machine::EVAL

    Used by the local method eval

  • GRID::Machine::STORE

    Used by the local methods compile and sub to install code on the remote side.

  • GRID::Machine::EXISTS

    Used by the local method exists

  • GRID::Machine::CALL

    Used by the local method call

  • GRID::Machine::MODPUT

    Used by the modput method. A list of pairs (Module::Name, code for Module::Name) is sent to the remote machine. For each pair, the remote side writes to disk a file Module/Name.pm with the contents of the string code for Module::Name. The file is stored in the directory referenced by the prefix attribute of the GRID::Machine object.

  • GRID::Machine::OPEN

    Used by the open method. As arguments receives a string defining the way the file will be accessed.

  • GRID::Machine::QUIT

    Usually is automatically called when the GRID::Machine object goes out of scope

The SERVER function

The SERVER function is available on the remote machine. Returns the object representing the remote side of the GRID::Machine object. This way code on the remote side can gain access to the GRID::Machine object. See an example:

my $m = GRID::Machine->new( host => 'beowulf');

$m->sub(installed => q { return  keys %{SERVER->stored_procedures}; });
my @functions = $m->installed()->Results;
local $" = "\n";
print "@functions\n";

The stored_procedures method returns a reference to the hash containing the subroutines installed via the sub and compile methods. The keys are the names of the subroutines, the values are the CODE references implementing them. When executed the former program produces the list of installed subroutines:

$ accessobject.pl
tar
system
installed
getcwd
etc.

The read_operation Method

Syntax:

my ( $operation, @args ) = $server->read_operation( );

Reads from the link. Returns the type of operation/tag and the results of the operation.

The send_error Method

Syntax:

$server->send_error( "Error message" );

Inside code to be executed on the remote machine we can use the function send_error to send error messages to the client

The send_result Method

Syntax:

    $server->send_result( 
	stdout  => $stdout,
	stderr  => $stderr,
        errmsg  => $errmsg,
        results => [ @results ],
    );

Inside code to be executed on the remote machine we can use the function send_result to send results to the client

SEE ALSO

AUTHOR

Casiano Rodriguez Leon <casiano@ull.es>

ACKNOWLEDGMENTS

This work has been supported by CEE (FEDER) and the Spanish Ministry of Educación y Ciencia through Plan Nacional I+D+I number TIN2005-08818-C04-04 (ULL::OPLINK project http://www.oplink.ull.es/). Support from Gobierno de Canarias was through GC02210601 (Grupos Consolidados). The University of La Laguna has also supported my work in many ways and for many years.

I wish to thank Paul Evans for his IPC::PerlSSH module: it was the source of inspiration for this module. To Dmitri Kargapolov for his contributions. Thanks also to Juana, Coro, my students at La Laguna and to the Perl Community.

LICENCE AND COPYRIGHT

Copyright (c) 2007 Casiano Rodriguez-Leon (casiano@ull.es). All rights reserved.

These modules are free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 150:

=back without =over

Around line 159:

Non-ASCII character seen before =encoding in 'I<Educación'. Assuming CP1252