GRID-Cluster
view release on metacpan or search on metacpan
NAME
GRID::Cluster - Virtual clusters using SSH links
SYNOPSIS
use GRID::Cluster;
my $np = 4; # Number of processes
my $N = 1000; # Number of iterations
my $clean = 0; # The files are not removed when the execution is finished
my $machine = [ 'host1', 'host2', 'host3' ]; # Hosts
my $debug = { host1 => 0, host2 => 0, host3 => 0 }; # Debug mode in every host
my $max_num_np = { host1 => 1, host2 => 1, host3 => 1 }; # Maximum number of processes supported by every host
my $c = GRID::Cluster->new(host_names => $machine, debug => $debug, max_num_np => $max_num_np);
|| die "No machines has been initialized in the cluster";
# Transference of files to remote hosts
$c->copyandmake(
dir => 'pi',
makeargs => 'pi',
files => [ qw{pi.c Makefile} ],
cleanfiles => $clean,
cleandirs => $clean, # remove the whole directory at the end
keepdir => 1,
);
# This method changes the remote working directory of all hosts
$c->chdir("pi/") || die "Can't change to pi/\n";
# Tasks are created and executed in remote machines using the method 'qx'
my @commands = map { "./pi $_ $N $np |" } 0..$np-1
print "Pi Value: ".sum @{$c->qx(@commands)}."\n";
DESCRIPTION
This module is based on the module GRID::Machine. It provides a set of
methods to create 'virtual' clusters by the use of SSH links for
communications among different remote hosts.
Since main features of "GRID::Machine" are zero administration and
minimal installation, GRID::Cluster directly inherites these features.
Mainly, "GRID::Cluster" provides:
* An extension of the Perl "qx" method. Instead of a single command it
receives a list of commands. Commands are executed - via SSH - using
the master-worker paradigm.
* Services for the transference of files among machines.
DEPENDENCIES
This module requires these other modules and libraries:
* GRID::Machine module by Casiano Rodriguez Leon
* Term::Prompt module by Allen Smith
METHODS
The Constructor "new"
This method returns a new instance of an object.
There are two ways to call the constructor. The first one looks like:
my $cluster = GRID::Cluster->new(
debug => {machine1 => 0, machine2 => 0,...},
max_num_np => {machine1 => 1, machine2 => 1,...},
);
( run in 0.800 second using v1.01-cache-2.11-cpan-71847e10f99 )