Question

I have a set of mapreduce jobs which I need to execute from my Java program. Right now I am executing them via a Java Process calling

$MONGO_HOME/bin/mongo host:port/database jsFiles

Is there a way I could execute these mapreduce taks on a machine which does not have Mongo. Does the mongo Java driver support such functionality ?

Thanks!

Was it helpful?

Solution

MongoDB MapReduce jobs are always run on the Mongo server, never in the client, and any client can send a job to the server.

@Chris Shain pointed you to the docs (http://api.mongodb.org/java/current/com/mongodb/MapReduceCommand.html), and I recommend you read them, but also understand that most MapReduce operations will be all about reducing the huge volumes of data stored into your database down to smaller result sets. The closer this is done to where the data is actually stored, the better, and most people do not execute commands directly on the server. In order for the MapReduce operation to be useful, Mongo would have to (and did!) provide a way to use it from the client. For general strategies, see here: http://www.mongodb.org/display/DOCS/MapReduce

Note that because the operation runs on the server, you may notice increased lock percentage. Consider running the MapReduce job on a slave or secondary Mongo instance if this is a problem for you.

OTHER TIPS

The Java client driver for Mongo has the MapReduceCommand, documented here: http://api.mongodb.org/java/current/com/mongodb/MapReduceCommand.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top