blob: 3bee3a676ae4022271e64250e0b5d0c45abf8d1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#######################################################################
###
### NOTE!
###
### Currently, mirrors do not work! The only thing that works is all
### nodes multimaster or a single master.
###
#######################################################################
#
# custom logic for couchdb json resolution
# ============================================
#
# There are three modes for a node:
#
# Multimaster
# -----------
#
# Multimaster uses bigcouch (soon to use couchdb in replication mode
# similar to bigcouch).
#
# Use "multimaster" mode when:
#
# * multiple nodes are marked couch.master
# * OR no nodes are marked couch.master
#
# Master
# ------
#
# Master uses plain couchdb that is readable and writable.
#
# Use "master" mode when:
#
# * Exactly one node, this one, is marked as master.
#
# Mirror
# ------
#
# Mirror creates a read-only copy of the database. It uses plain coucdhb
# with legacy couchdb replication (http based).
#
# This does not currently work, because http replication can't handle
# the number of user databases.
#
# Use "mirror" mode when:
#
# * some nodes are marked couch.master
# * AND this node is not a master
#
master_count = nodes_like_me['services' => 'couchdb']['couch.master' => true].size
if master_count == 0
apply_partial 'services/_couchdb_multimaster.json'
elsif couch.master && master_count > 1
apply_partial 'services/_couchdb_multimaster.json'
elsif couch.master && master_count == 1
apply_partial 'services/_couchdb_master.json'
else
apply_partial 'services/_couchdb_mirror.json'
end
|