Debug MongoDB Map Reduce with the Mongo MapReduce Web browser

I got wind of a very nice new tool out there recently.

It is called the Mongo MapReduce WebBrowser and can its Github repository can be found here: https://github.com/angelozerr/mongo-mapreduce-webbrowser.

Why is this tool so great? It actually allows you to debug your custom-made map reduces within a JQuery environment in your own browser.

Now I have only been playing with this tool for a while now I have only made some basic tests with all of them being done on Firefox. Even though this program looks like it is a bit bare with documentation in the readme it in fact isn’t. This program is so simple that the couple of screenshots provided was all I needed to start debugging my map reduce. So already this program is simple and easy to learn.

Compatibility

I have tested this program with:

  • Opera
  • Safari
  • Firefox
  • Internet Explorer

I have found that in versions of Opera just before the latest (maybe 6 months ago) you just get a white screen saying “ACTIVATING…” and nothing else, updating Opera solved this problem.

On Internet Explorer I cannot seem to find the dynamic script entry within the scripts tab for the script but it wasn’t there. I believe this is because IE does not reload this tab for dynamically added scripts, so I would stay away from using IE with this program for the time being; things may have changed on IE 10 and it may be up to scratch with the other browsers but I wouldn’t bet on it (IE, the most popular browser to get another browser).

On Safari, a note about it on Windows, it contains no developer tools by default! This means that actually this program, to no fault of its own, it useless on this browser unless you download a Firebug type program. I did not do this since I don’t like Apple made products so I just quickly tested and left it alone.

Apart from these few problems the program works a treat in all other conditions, however, my recommendation of browsers to use for this program are:

  • Chrome (latest)
  • Firefox (latest)

So with the compatibility aside lets look at actually using this, shall we?

Usage

I have found out the online version is not great for testing this program. It does not seem to refresh the input document of the Map Reduce on each run.

When downloading this program yourself there is no documentation or pointer for non-Java individuals on how to get this running. This means that you will need to understand something about how to get this running for the time being.

Unfortunately if you intend to get this program running on the small knowledge you have of Java by installing a JRE and then accessing the StartServer.java file (which starts a jetty server) you will be hit with:

$ java StartServer.java   Exception in thread "main" java.lang.NoClassDefFoundError: StartServer/java
Caused by: java.lang.ClassNotFoundException: StartServer.java
        at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: StartServer.java. Program will exit.

I tried to be a sneaky little bastard about this and actually access the webapp directly from a browser. It kind of worked however without the jetty server running it gave a 404 error about the jaxrs folder.

My verdict on this is that it is new. However, I do see the need for a Java jetty server as a downside. The program really needs to be independent and instantly integratable with almost any server, technically it runs its entirety in JavaScript (JQuery to be more precise) so it should be relatively easily to port this program to work without the need for starting a Java server.

That being said the author of this program has intentions of making the program bieng able to dynamically save map reduces to MongoDB and other such integrations which means that in time the web server will undoubtly be required. I am personally used to using programs such as Solr so this is no biggy for me :) .

So I have only used the online edition of this program since my knowledge of Java (now-a-days) is a little too rusty to work through the Java scripts, debugging them.

So, with that aside, first off this program, being brand new, does output a lot of debug info to the console:

Firebug output of MApReduce debug

In fact enough to fill you screen a couple of times, not only that but it does have a deprecation error: JQMIGRATE: jQuery.browser is deprecated, however this does not seem to effect the overall running of the program and I can still easily debug with it.

However, once you have got past this and onto the Map Reduce script, adding break points, it easily debugs the three functions with whatever stepping tools your browser console has.

My end verdict is that this program has undeniable potential but at the moment there is just too many teething problems to really test any Map Reduces correctly.

You should try the online version for yourself here: http://mongo-mapreduce-webbrowser.opensagres.cloudbees.net/ and if you know Java and are willing to contribute it would be so good to have a program like this running and maintained.

7 Comments

  1. Posted February 14, 2013 at 9:36 am | Permalink | Reply

    Hi Sammayes,

    Many thank’s for your article. I have just started this project and you blog it yet. Wow , that’s cool:) As you have written, there are a lot of (little) problems to resolve. This project is not finished and you will have new features soon like syntax error, completion.

    Here some answer of your comments :

    1) document should be done once the development is finished.
    2) I have tested with FF and Chrome which have a great debugger. I don’t want loose my time with IE even if I test it quicly with it.
    3) you need a WEB Server because the webapp uses Ajax to display js files coming from a Folder and load dynamic scripts (when you wish to debug your MapReduce, you should before save (it saves the script and reload it) it to debug it). I use Embedding Jetty as WEB Server in my local machine, but in the live demo, Tomcat is used. You could implement the server with Node.js or other.
    4) there are a lot of debug, because I discover jQuery and it seems that jQuery 1.9 has removed several methods (like browser). The dynatree that I use works with jQuery 1.8, so I use jQuery migrate to support dynatree.
    5) to debug your MapReduce with Chrome for instance you open the Source scripts tab of Chrome, you do “Ctrl+0″ and you type your MapReduce name to open the script and set a breakpoint. If you change the script in the textarea of the MapReduce, it’s important to save the script, close the Chrome Developper (F12), and reopen it (F12) in order to Chrome refresh the script in the Source panel.

    > My end verdict is that this program has undeniable potential but at the moment there is just too many teething problems to really test any Map Reduces correctly.

    I think the problem is the documentation too, but before doing that, I would like finish my development.

    Don’t hesitate to create issue with your problem at https://github.com/angelozerr/mongo-mapreduce-webbrowser/issues

    Regards Angelo

    • sammaye
      Posted February 14, 2013 at 9:45 am | Permalink | Reply

      Yes don’t waste your time with IE, if they ever even get a debugger that works properly.

      Awesome yeah, though if the documentation just added how to set up maybe a test envo for non-java people it could be really awesome for those who wanna break it :P . I do understand you wanna finish your development so I will wait in anticipation, I think this will be a good tool.

      Yea JQuery has removed a lot of functionality which they saw as useless, browser being one, since it was so unreliable.

      Ah ok; about point 5, does that go for input documents too? I wanted to test some of the examples with real world test set sizes to test the logic moves within the functions correctly, if I save the MR and reload firebug will it refresh the input?

      I think I will wait until initial development is done until I file issues :) , I want to make sure you can focus on the important stuff to get this out.

      Overall, despite being new, it does have the a demo that shows its potential to be awesome so I am really looking forward to it.

    • sammaye
      Posted February 14, 2013 at 10:08 am | Permalink | Reply

      Yea requiring a server isn’t the end of the world and I have seen that actually you wanna add database handling to this program, so it seems like a good direction.

      Edited my article around it :)

      • Posted February 14, 2013 at 10:54 am | Permalink

        > just added how to set up maybe a test envo for non-java people
        I think the distribution should provide 2 products :

        1) a war to deploy teh webapp on any Java WEB Server.
        2) a jar + bin/sh to start the webapp with embedding jetty (no need to install somme Java Server)

        Once the webapp is stable, I think it should be cool if there are other server like Node.js. If you are interested, you are welcome!

        When I started this project, I had not a server, but it was very simply (you could jiust execute your (one) MapReduce but don’t save it and no debug). I have studied several means to manage files with WebBrowser (like File API, but you need to start your WebBrowser with some parameter to give write access), but server mode was the most powerfull.

        My idea is too share MapReduce between people. In a forum, you post “I have a problem with MapReduce, please see my MapReduce and you post a link to the online webapp, like http://jsfiddle.net/ for Javascript).

        Do you think None server mode is important?

    • sammaye
      Posted February 14, 2013 at 11:55 am | Permalink | Reply

      I would definitely be interested in making a PHP plugin for it (that’s my main language atm).

      None server mode isn’t important if those are your plans. A lite version later on when the full version is up can be made for that.

      A JSFiddle edition would be a killer and not just for MongoDB, people could make plugins for stuff like Hadoop and that.

      Yea, this definitely sounds good :) .

      • Posted February 14, 2013 at 12:07 pm | Permalink

        > A JSFiddle edition would be a killer and not just for MongoDB, people could make plugins for stuff like Hadoop and that.
        Cool, I’m happy my idea please you.

        To manage that, DB should be managed to persist the MapReduce on the DB (and not on the FileSystem like today).

        > A lite version later on when the full version is up can be made for that.
        Yes sI thought that too. For the moment I decide to manage only server mode.

        PHP plugin should be very cool, but I think you should wait that code become stable because the server side should change a little, but if you want you can start something and I will give you right if you wish on my GitHub.

    • sammaye
      Posted February 14, 2013 at 2:20 pm | Permalink | Reply

      I’ll do as you say and wait for the code to soldify :) the API will probably change a lot over the coming weeks/months.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: