Add support for replication events clustering

Share the replication events between the two
masters in the dual-master recipe.

Change-Id: I6d450484a8d0bfb745b7ef34b0f5580c37b2dd46
diff --git a/dual-master/cf-cluster.yml b/dual-master/cf-cluster.yml
index 011a2f5..771dd6a 100644
--- a/dual-master/cf-cluster.yml
+++ b/dual-master/cf-cluster.yml
@@ -165,8 +165,9 @@
             `mount -t nfs4 -o nfsvers=4.1,hard,timeo=600,retrans=2 $DIR_SRC:/ $DIR_TGT >> /home/ec2-user/echo.res` \
               && s=0 && break || s=$? && sleep 5;
           done; (exit $s)
-          mkdir $DIR_TGT/git
-          mkdir $DIR_TGT/high-availability
+          mkdir -p $DIR_TGT/git
+          mkdir -p $DIR_TGT/high-availability
+          mkdir -p $DIR_TGT/events
           chown -R 1000:1000 $DIR_TGT
           cp -p /etc/fstab /etc/fstab.back-$(date +%F)
           echo -e \"$DIR_SRC:/ \t\t $DIR_TGT \t\t nfs \t\t defaults \t\t 0 \t\t 0\" | tee -a /etc/fstab
diff --git a/dual-master/cf-service-master.yml b/dual-master/cf-service-master.yml
index 2089e8d..4b07bc1 100644
--- a/dual-master/cf-service-master.yml
+++ b/dual-master/cf-service-master.yml
@@ -77,6 +77,10 @@
       Description: Gerrit git volume name
       Type: String
       Default: gerrit-git-master
+  GerritEventsVolume:
+      Description: Gerrit replication events volume name
+      Type: String
+      Default: gerrit-events-master
   GerritWebsessionsVolume:
       Description: Gerrit git volume name
       Type: String
@@ -171,6 +175,8 @@
                       ContainerPath: /var/gerrit/db
                     - SourceVolume: !Ref GerritLogsVolume
                       ContainerPath: /var/gerrit/logs
+                    - SourceVolume: !Ref GerritEventsVolume
+                      ContainerPath: /var/gerrit/events
                   Cpu: 1024
                   Memory: 2048
                   PortMappings:
@@ -190,6 +196,9 @@
               - Name: !Ref 'GerritGitVolume'
                 Host:
                   SourcePath: "/mnt/efs/gerrit-shared/git"
+              - Name: !Ref 'GerritEventsVolume'
+                Host:
+                  SourcePath: "/mnt/efs/gerrit-shared/events"
               - Name: !Ref 'GerritWebsessionsVolume'
                 Host:
                   SourcePath: "/mnt/efs/gerrit-shared/high-availability"
diff --git a/gerrit/etc/replication.config.template b/gerrit/etc/replication.config.template
index c03a807..814a4a9 100644
--- a/gerrit/etc/replication.config.template
+++ b/gerrit/etc/replication.config.template
@@ -1,6 +1,8 @@
 [replication]
   lockErrorMaxRetries = 30
   maxRetries = 30
+  eventsDirectory = events
+  distributionInterval = 1
 
 [gerrit]
   autoReload = true