Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files
Create _global_changes database on cluster setup
  • Loading branch information
kxepal committed Apr 18, 2015
1 parent 372dd8b commit ecb601b2004f33f396530a6ae974f2f0bff4d816
Showing 2 changed files with 13 additions and 9 deletions.
@@ -43,16 +43,20 @@ is_cluster_enabled() ->
{_,[]} -> no;
{_,_} -> ok
end.


cluster_system_dbs() ->
["_users", "_replicator", "_metadata", "_global_changes"].


has_cluster_system_dbs() ->
% GET /_users /_replicator /_metadata
has_cluster_system_dbs(cluster_system_dbs()).

case catch {
fabric:get_db_info("_users"),
fabric:get_db_info("_replicator"),
fabric:get_db_info("_metadata")} of
{{ok, _}, {ok, _}, {ok, _}} -> ok;
has_cluster_system_dbs([]) ->
ok;
has_cluster_system_dbs([Db|Dbs]) ->
case catch fabric:get_db_info(Db) of
{ok, _} -> has_cluster_system_dbs(Dbs);
_ -> no
end.

@@ -115,9 +119,7 @@ finish_cluster() ->
finish_cluster_int(ok) ->
{error, cluster_finished};
finish_cluster_int(no) ->
% create clustered databases (_users, _replicator, _metadata)
Databases = ["_users", "_replicator", "_metadata"],
lists:foreach(fun fabric:create_db/1, Databases).
lists:foreach(fun fabric:create_db/1, cluster_system_dbs()).


add_node(Options) ->
@@ -49,10 +49,12 @@ curl a:b@127.0.0.1:15984/_cluster_setup -d '{"action":"finish_cluster"}' $HEADER
curl a:b@127.0.0.1:15984/_users
curl a:b@127.0.0.1:15984/_replicator
curl a:b@127.0.0.1:15984/_metadata
curl a:b@127.0.0.1:15984/_global_changes

# Show system dbs exist on node B
curl a:b@127.0.0.1:25984/_users
curl a:b@127.0.0.1:25984/_replicator
curl a:b@127.0.0.1:25984/_metadata
curl a:b@127.0.0.1:25984/_global_changes

echo "YAY ALL GOOD"

0 comments on commit ecb601b

Please sign in to comment.