adhd 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/adhd.gemspec +1 -1
- data/lib/adhd/models/content_shard.rb +5 -2
- data/lib/adhd/node_manager.rb +13 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/adhd.gemspec
CHANGED
@@ -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
|
-
|
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
|
data/lib/adhd/node_manager.rb
CHANGED
@@ -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|
|
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
|
|