NAME

Gearman MapReduce Demonstration

OVERVIEW

This application demonstrates how the MapReduce framework can be used with the Gearman system to identify and count subjects in a corpus of documents. While MapReduce is used with many servers across a network, this application is run on one computer using three perl processes (Master, Mapper, and Reducer) and two gearman server processes.

The input is a corpus of financial filings text. The intermediate output is a text file for each company containing counts and subjects. The final output is a single text file containing counts and subjects.

The original presentation:

http://www.slideshare.net/jamespitts/gearman

REQUIREMENTS

Gearman Job Server (gearmand 0.14):

http://gearman.org/

http://launchpad.net/gearmand/trunk/0.14/+download/gearmand-0.14.tar.gz

Required CPAN modules:

Gearman::XS

FreezeThaw

Data::Dumper

SYNOPSIS

1. Run the gearmand servers:

cd $YOUR_GEARMAN_INSTALL_DIR

sbin/gearmand -v --port=4730 --log-file=logs/4730.log &

sbin/gearmand -v --port=4731 --log-file=logs/4731.log &

2. Run the Mapper Worker in shell 1:

./mapper.pl

3. Run the Reducer Worker in shell 2:

./reducer.pl

4. Run the Master in shell 3:

./master.pl

5. Great Success:

ls output/

CONTENTS

master.pl

Controls the entire map/reduce process. Generates and submits jobs to mapper and reducer gearman servers. Monitors the work.

/corpus

Contains financial filings for two companies.

mapper.pl

Performs the map work, producing an intermediate output that is processed by a reducer.

/intermediate

Temporarily contains files of each company's subjects and counts.

reducer.pl

Performs the reduce work, updating the final output.

/output

Contains files of all company's subjects and counts.

/presentation

Slides from the original Ann Arbor Perl Mongers presentation.

AUTHOR

Jamie Pitts <james.pitts at gmail.com>

LICENSE

The MIT License

Copyright (c) 2010 Jamie Pitts

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.