<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>bin/localhost</filename>
    </added>
    <added>
      <filename>spec/benchmarks/bm-20081111.txt</filename>
    </added>
    <added>
      <filename>spec/benchmarks/bm-20081113.txt</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,29 +1,26 @@
-#!/usr/bin/env ruby
+#!/usr/bin/env ruby -s
 
 lib_path = File.expand_path(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;lib&quot;))
 $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
 
 require 'gisting'
 
-SERVERS = [
-  [&quot;127.0.0.1&quot;, 9081, Gisting::MapServer],
-  [&quot;127.0.0.1&quot;, 9082, Gisting::MapServer],
-  [&quot;127.0.0.1&quot;, 9083, Gisting::MapServer],
-  [&quot;127.0.0.1&quot;, 9084, Gisting::MapServer],
-  [&quot;127.0.0.1&quot;, 9085, Gisting::MapServer],
+$m ||= false
+$r ||= false
 
-  [&quot;127.0.0.1&quot;, 9091, Gisting::ReduceServer],
-  [&quot;127.0.0.1&quot;, 9092, Gisting::ReduceServer]
-]
-
-def start_servers(servers)
-  EM::run {
-    servers.each do |server_conf|
-      host, port, gistable = server_conf
-      puts &quot;Starting server #{gistable.to_s} on #{host}:#{port}&quot;
-      EM::start_server host, port, gistable
-    end
-  }  
+def fail_unless(valid)
+  if !valid
+    puts &quot;\nusage: #{__FILE__} -m[ap] or -r[educe] localhost:9081&quot;
+    exit
+  end
 end
+ 
+fail_unless(($m ^ $r) &amp;&amp; ARGV.size == 1)
+host, port = ARGV.first.split(&quot;:&quot;)
+gistable = Gisting::MapServer if $m
+gistable = Gisting::ReduceServer if $r
 
-start_servers(SERVERS)
\ No newline at end of file
+EM::run {
+  puts &quot;Starting server #{gistable.to_s} on #{host}:#{port}&quot;
+  EM::start_server host, port.to_i, gistable
+}</diff>
      <filename>bin/server</filename>
    </modified>
    <modified>
      <diff>@@ -14,8 +14,15 @@ def args
            &quot;/Volumes/gisting/datasets/aol-data/user-ct-test-collection-04.txt&quot;,
            &quot;/Volumes/gisting/datasets/aol-data/user-ct-test-collection-05.txt&quot;,
            ]
-  # args += [&quot;/Users/mchung/Public/datasets/sample1.data&quot;, &quot;/Users/mchung/Public/datasets/sample2.data&quot;]
-  # args += [&quot;/Users/mchung/Public/datasets/aoldb_dev.txt&quot;]
+  args = [
+           &quot;/Users/mchung/Public/datasets/sample1.data&quot;, 
+           &quot;/Users/mchung/Public/datasets/sample2.data&quot;
+         ]
+         
+  args = [
+            &quot;/Volumes/gisting/datasets/aoldb_dev-aa&quot;,
+            &quot;/Volumes/gisting/datasets/aoldb_dev-ab&quot;,            
+         ]
 end
 
 if __FILE__ == $0</diff>
      <filename>examples/term_count.rb</filename>
    </modified>
    <modified>
      <diff>@@ -65,7 +65,7 @@ module Gisting
 
     # This smells funny
     def stop!
-      # Stop all client connections and ends the reactor in Cluster
+      # Instructs the Cluster to stop all client connections and end the Map/Reduce reactor
       EM::stop_event_loop
     end
 </diff>
      <filename>lib/gisting/job.rb</filename>
    </modified>
    <modified>
      <diff>@@ -11,7 +11,7 @@ module Gisting
       @jobs_map_completed = 0
       @jobs_reduce_started = 0
       @jobs_reduce_completed = 0
-      @next_map_job, @next_intermediate_job, @next_reduce_job = 0, 0, 0 # Counter
+      @next_map_job, @next_intermediate_job, @next_reduce_job = 0, 0, 0 # Counters
     end
 
     def init_map_job(input)
@@ -23,12 +23,12 @@ module Gisting
     end
 
     def start_map_job(file_pattern)
-      @map_jobs[file_pattern][:started_at] = Time.now
+      @map_jobs[file_pattern][:map_started_at] = Time.now
       @jobs_map_started +=1 
     end
 
     def stop_map_job(file_pattern, intermediate_job)
-      @map_jobs[file_pattern][:ended_at] = Time.now
+      @map_jobs[file_pattern][:map_ended_at] = Time.now
       @map_jobs[file_pattern][:intermediate_job] = intermediate_job
       @jobs_map_completed += 1
     end</diff>
      <filename>lib/gisting/job_progress.rb</filename>
    </modified>
    <modified>
      <diff>@@ -13,6 +13,10 @@ module Gisting
       Result.new(job)
     rescue BusyClusterFail =&gt; e
       puts e.message
+    rescue Exception =&gt; e
+      puts &quot;Caught exception...&quot;
+      puts e.message
+      # job.stop!
     end
 
     alias :MapReduce :map_reduce</diff>
      <filename>lib/gisting/map_reduce.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,6 +9,7 @@ module Gisting
       @data_source = file_pattern
       @map_proc = proc
       setup_emit
+      pp [&quot;map_runner&quot;, @data_source, @map_proc]
     end
 
     def Emit(key, value)</diff>
      <filename>lib/gisting/map_runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,6 +7,7 @@ module Gisting
       puts &quot;MapServer Starting...&quot;
     end
 
+    # Executes a MapRunner with a file pattern
     def receive_data(job)
       begin
         puts &quot;Running MapRunner&quot;
@@ -14,12 +15,17 @@ module Gisting
         runner = MapRunner.new(file_pattern, proc)
 
         thread = Proc.new { runner.map! }
-        callback = Proc.new { send_data(runner.output) }
+        callback = Proc.new { send_reply(runner.output) }
         EM.defer(thread, callback)
       rescue =&gt; e
         pp [:map_server, e]
       end
     end
+    
+    def send_reply(output)
+      send_data(output)
+      puts &quot;Completed MapRunner&quot;
+    end
 
   end
 end</diff>
      <filename>lib/gisting/map_server.rb</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@ module Gisting
       @output_file = output
       @map_data_input = intermediate_file
       setup_emit
-      pp [&quot;red_proc&quot;, @red_proc]
+      pp [&quot;red_runner&quot;, @map_data_input, @red_proc, @output_file]
     end
 
     def Emit(count)</diff>
      <filename>lib/gisting/reduce_runner.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,8 +7,7 @@ module Gisting
       puts &quot;ReduceServer Starting...&quot;
     end
 
-    # Delegates an +map output+ task to a ReduceRunner and returns 
-    # (via +send_data+) the name of the intermediate file
+    # Executes a ReduceRunner with an intermediate file
     def receive_data(job)
       begin
         puts &quot;Running ReduceRunner&quot;
@@ -16,12 +15,17 @@ module Gisting
         runner = ReduceRunner.new(intermediate_file, proc, output)
 
         thread = Proc.new { runner.reduce! }
-        callback = Proc.new { send_data(runner.output) }
+        callback = Proc.new { send_reply(runner.output) }
         EM.defer(thread, callback)
       rescue =&gt; e
         pp [:red_server, e]
       end
     end
+    
+    def send_reply(output)
+      send_data(output)
+      puts &quot;Completed ReduceRunner&quot;
+    end
 
   end
 end</diff>
      <filename>lib/gisting/reduce_server.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a06f1ae8d77b04658ff37d2c9c6c2fdaeae67aa8</id>
    </parent>
  </parents>
  <author>
    <name>Marc Chung</name>
    <email>mchung@gmail.com</email>
  </author>
  <url>http://github.com/mchung/gisting/commit/ca26cfbf9f63a43c53ad0917d885e1cf9b052715</url>
  <id>ca26cfbf9f63a43c53ad0917d885e1cf9b052715</id>
  <committed-date>2009-01-21T23:39:13-08:00</committed-date>
  <authored-date>2009-01-21T23:39:13-08:00</authored-date>
  <message>Clean up the bin and use proper EM callbacks</message>
  <tree>184bcf2b4ade56cbdd2549a72ca86fabf38d99a7</tree>
  <committer>
    <name>Marc Chung</name>
    <email>mchung@gmail.com</email>
  </committer>
</commit>
