adhd 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{adhd}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["dave.hrycyszyn@headlondon.com"]
@@ -52,11 +52,14 @@ class ContentShard
52
52
  # all nodes or the first available aside us and master
53
53
  all_good = true
54
54
  this_shard.node_list.each do |node_name|
55
+ # Do not sync with ourselves
56
+ next if (@our_node.name == node_name)
57
+
55
58
  # Push all changes to the other nodes
56
59
  remote_node = Node.by_name(:key => node_name).first
57
60
  remote_db = remote_node.get_content_db(this_shard.shard_db_name)
58
- all_good &= @our_node.replicate_to(this_shard_db, remote_node, remote_db)
59
-
61
+ bool_to = @our_node.replicate_to(this_shard_db, remote_node, remote_db)
62
+ all_good &= bool_to
60
63
  if !am_master && bool_to
61
64
  # NOTE: How to build skynet, Note 2
62
65
  # We are doing some "gonzo" replication, here. Our master is
@@ -127,6 +127,9 @@ module Adhd
127
127
  def build_node_content_databases
128
128
  # NOTE: we will have to refresh those then we are re-assigned shards
129
129
  @contentdbs = {} if !@contentdbs
130
+
131
+ # This is a fresh version of the DB, and we should use it to
132
+ # add, remove and *update* shards
130
133
  current_shards = @srdb.get_content_shards
131
134
 
132
135
  # Add the new shards
@@ -136,11 +139,20 @@ module Adhd
136
139
  conn = UpdateNotifierConnection.new(@config.node_url,
137
140
  @config.couchdb_server_port,
138
141
  @our_node.name + "_" + shard_db.this_shard.shard_db_name + "_content_db", # NOTE: Sooo ugly!
139
- Proc.new { |data| shard_db.sync })
142
+ Proc.new { |data|
143
+ puts "SYNC #{shard_db.this_shard.shard_db_name} #{data}"
144
+
145
+ # Lazy evaluation to make sure we
146
+ # get the latest shard information
147
+ @contentdbs[cs][0].sync
148
+ })
140
149
  @conn_manager.add_connection(conn)
141
150
 
142
151
  # Store both the shard object and the update notifier
143
152
  @contentdbs[cs] = [shard_db, conn]
153
+ else
154
+ # Keep the same connection, but update the shard information
155
+ @contentdbs[cs] = [current_shards[cs], @contentdbs[cs][1]]
144
156
  end
145
157
  end
146
158
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - dave.hrycyszyn@headlondon.com