drmap 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -11,4 +11,6 @@ end
11
11
 
12
12
  Dir['tasks/**/*.rake'].each { |rake| load rake }
13
13
 
14
+ # I CAN EDIT CODE FROM GITHUB?
15
+
14
16
  # vim: syntax=Ruby
data/bin/drirb CHANGED
@@ -3,8 +3,42 @@
3
3
  require 'rubygems'
4
4
  require 'drmap'
5
5
  require 'irb'
6
+ require 'open3'
7
+
8
+ class Beanstalkd
9
+
10
+ def start_daemon
11
+ puts "Starting beanstalkd"
12
+ try_journeta
13
+ fork do
14
+ Open3::popen3("beanstalkd")
15
+ end
16
+ end
17
+
18
+ def try_journeta
19
+ begin
20
+ require 'journeta'
21
+ Journeta::Engine.new(:peer_port => (2048+rand(2**8)), :groups => ["drserver"]).start
22
+ rescue
23
+ end
24
+ end
25
+
26
+ def stop_daemon
27
+ puts "\nKilling beanstalkd"
28
+ fork do
29
+ Open3::popen3("killall -9 beanstalkd")
30
+ end
31
+ end
32
+ end
6
33
 
7
34
  if __FILE__ == $0
8
- Drmap::BeanstalkPool.hosts = ['localhost:11300'] # TODO Should probably make this a command line variable
9
- IRB.start(__FILE__)
35
+ begin
36
+ bs = Beanstalkd.new
37
+ bs.start_daemon
38
+ # TODO Should probably make this a command line variable
39
+ Drmap::BeanstalkPool.hosts = ['localhost:11300']
40
+ IRB.start(__FILE__)
41
+ ensure
42
+ bs.stop_daemon
43
+ end
10
44
  end
@@ -3,14 +3,42 @@
3
3
  require 'rubygems'
4
4
  require 'drmap'
5
5
 
6
+ def start_journeta
7
+ begin
8
+ require 'journeta'
9
+ journeta = Journeta::Engine.new(:peer_port => (2048+rand(2**8)), :groups => ["drclient"])
10
+ journeta.start
11
+ puts "Discovering server..."
12
+ sleep(5)
13
+ @peers = journeta.known_peers_in_group("drserver")
14
+ rescue LoadError => e
15
+ puts "Caught exception: #{e.message}"
16
+ @peers = {}
17
+ end
18
+ end
19
+
20
+ def discover_server
21
+ bserver = "localhost:11300"
22
+ start_journeta
23
+ if !@peers.empty?
24
+ peer = @peers[@peers.keys.first]
25
+ bserver = "#{peer.ip_address}:11300"
26
+ end
27
+ bserver
28
+ end
29
+
6
30
  if __FILE__ == $0
7
- host = "localhost:11300"
31
+ host =
8
32
  if ARGV[0]
9
33
  host = ARGV[0]
34
+ else
35
+ host = discover_server
10
36
  end
11
- puts "Connecting to #{host}" # TODO Should probably test connection!
37
+
38
+ puts "Connecting to #{host}"
39
+ # TODO Should probably test connection!
12
40
  Drmap::BeanstalkPool.hosts = [host]
13
41
  pool = Drmap::BeanstalkPool.new
14
42
  worker = Drmap::BeanstalkWorker.new(pool)
15
43
  worker.process
16
- end
44
+ end
@@ -5,6 +5,8 @@ require 'pp'
5
5
 
6
6
  require 'beanstalk-client'
7
7
  require 'ruby2ruby'
8
+ require 'parse_tree'
9
+ require 'parse_tree_extensions'
8
10
 
9
11
  require 'drmap/drmap_enumerable'
10
12
  require 'drmap/beanstalk_worker'
@@ -13,4 +15,4 @@ require 'drmap/version'
13
15
 
14
16
  module Drmap
15
17
  VERSION = Drmap::Version::STRING
16
- end
18
+ end
@@ -1,10 +1,12 @@
1
1
  module Enumerable
2
2
 
3
3
  def drmap(&block)
4
+ raise "No data" if self.size == 0
4
5
  pool = Drmap::BeanstalkPool.new
5
6
 
6
- jid = rand(100)
7
+ jid = Kernel.rand(100)
7
8
  each_with_index do |element, idx|
9
+ # puts "Adding #{jid}, #{element}, #{block.to_ruby}"
8
10
  pool.put_job(jid, block.to_ruby, element)
9
11
  end
10
12
 
@@ -2,7 +2,7 @@ module Drmap
2
2
  module Version #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 1
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drmap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Chung
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-27 00:00:00 -07:00
12
+ date: 2008-11-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.7.0
23
+ version: 1.8.2
24
24
  version:
25
25
  description: drmap distributed Ruby blocks across processes
26
26
  email: