Distributed::Process::Client - a class to run a client in a Distributed::Process cluster.
use Distributed::Process; use Distributed::Process::Client; use MyTest; $c = new Distributed::Process::Client -id => 'client1', -worker_class => 'MyTest', -port => 8147, -host => 'localhost', ; $c->run();
This class handles the client part of the cluster. It derives its handling of the network connection from Distributed::Process::Interface.
Distributed::Process::Interface
A D::P::Worker object must be associated to the Client, by means of the worker() or worker_class() methods, so that the client can run methods from it when requested to do so by the server.
D::P::Worker
A D::P::Client object will react on the following commands received on its in_handle().
D::P::Client
Calls the worker's run() method. This is method should be overloaded by subclasses of D::P::Worker to perform the real job that is to be distributed on the cluster.
Calls the worker's reset_result() method to flush its list of results.
Exits the program.
Returns the results from the worker. The results are preceeded with the line /begin_results and followed by the word ok. Each result line gets prefixed with the client's id() and a tab character ("\t", ASCII 0x09).
/begin_results
ok
\t
The worker itself returns its result line prefixed with a timestamp. An example of output could thus be:
/begin_results client1 20050316-152519 Running method test1 client1 20050316-152522 Time for running test1: 2.1234 seconds ok
Reads line coming in from handle() and processes them.
Each line is first chomped and split on whitespace, and an action is performed depending on the first word on the line. See the list of known commands above.
chomp
split
These three are synonyms for the handle() method that returns the IO::Socket::INET object implementing the connection to the server.
IO::Socket::INET
The first call to handle() creates this object, effectively establishing the connection to port port() on host host().
Sets or returns the current worker object. OBJECT should be an instance of Distributed::Process::Worker or, most probably, of a subclass of it. If OBJECT is not provided, the fist call to worker() will instanciate an object of the class returned by worker_class(), passing to its constructor the arguments returned by worker_args().
Distributed::Process::Worker
The list of arguments to pass to the worker_class() constructor. If the first argument is an array ref, it will be dereferenced.
Returns the former list of arguments or the current list when invoked without arguments.
The following list describes the attributes of this class. They must only be accessed through their accessors. When called with an argument, the accessor methods set their attribute's value to that argument and return its former value. When called without arguments, they return the current value.
A unique identifier for the client. This will be prepended to the lines sent back to the server as a response to the /get_result command. The process id ($$) is returned if id() is not set.
/get_result
$$
The name of the class to use when instanciating a D::P::Worker object.
The host and port where to connect to the server.
Distributed::Process::Interface, Distributed::Process::Worker,
Cédric Bouvier, <cbouvi@cpan.org>
<cbouvi@cpan.org>
Please report any bugs or feature requests to bug-distributed-process@rt.cpan.org, or through the web interface at http://rt.cpan.org. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-distributed-process@rt.cpan.org
Copyright 2005 Cédric Bouvier, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Cédric'. Assuming CP1252
To install Distributed::Process, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Distributed::Process
CPAN shell
perl -MCPAN -e shell install Distributed::Process
For more information on module installation, please visit the detailed CPAN module installation guide.