Merge branch 'stable-3.0' into stable-3.1

* stable-3.0:
  Add newline at EOF as required by HAProxy
  Use GerritForge's archive-ci for downloading artifacts
  Fix issue with disabling ref-database

Change-Id: I9b5ee3270e7aeecbead81ac4ede3fc0ea747cfce
diff --git a/.gitignore b/.gitignore
index 4d4a78b..73f4353 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,8 +8,6 @@
 /.settings/
 
 /bazel-bin
-/bazel-genfiles
-/bazel-multi-site
 /bazel-out
 /bazel-reviewers
 /bazel-testlogs
diff --git a/DESIGN.md b/DESIGN.md
index 3cdef94..1bbe78f 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -192,6 +192,10 @@
 to push them again. However, someone needs to manually detect the issue in the
 replication log and get in touch with the user.
 
+The [pull-replication plugin](https://gerrit.googlesource.com/plugins/pull-replication)
+supports synchronous replication and has the structure to perform also the
+asynchronous variant in the future.
+
 ## History and maturity level of the multi-site plugin
 
 This plugin expands upon the excellent work on the high-availability plugin,
@@ -250,8 +254,8 @@
 The current limitations of Stage #9 are:
 
 - **Limited supports for many sites**:
-  One could, potentially, support a very high number of sites, but replication lag
-  to all sites could have a serious consequence in the overall perceived latency.
+  One could, potentially, support a very high number of sites, but the pull-replication
+  logic to all sites could have a serious consequence in the overall perceived latency.
   Having to deal with a very high number of site requires the implementation of a quorum on
   all the nodes available for replication.
 
@@ -648,9 +652,6 @@
 - Implement more global-refdb storage layers (e.g. TiKV) and more cloud-native
   message brokers (e.g. NATS)
 
-- Implement a synchronous pull-replication plugin for triggering the replication
-  logic on all the other sites, based on Git protocol v2 upload-pack.
-
 - Implement a quorum-based policy for accepting or rejecting changes in the pull-replication
   plugin
 
diff --git a/dockerised_local_env/.gitignore b/dockerised_local_env/.gitignore
deleted file mode 100644
index bc7d3f3..0000000
--- a/dockerised_local_env/.gitignore
+++ /dev/null
@@ -1,30 +0,0 @@
-# LC_COLLATE=C sort
-
-/gerrit-1/bin/
-/gerrit-1/data/
-/gerrit-1/db/
-/gerrit-1/etc/
-/gerrit-1/git/
-/gerrit-1/index/
-/gerrit-1/lib/
-/gerrit-1/logs/
-/gerrit-1/plugins/
-/gerrit-1/ssh/known_hosts
-/gerrit-1/tmp/
-
-/gerrit-2/bin/
-/gerrit-2/data/
-/gerrit-2/db/
-/gerrit-2/etc/
-/gerrit-2/git/
-/gerrit-2/index/
-/gerrit-2/lib/
-/gerrit-2/logs/
-/gerrit-2/plugins/
-/gerrit-2/ssh/known_hosts
-/gerrit-2/tmp/
-
-/gerrit-common/shared-dir/
-
-/syslog-sidecar/logs/
-/syslog-sidecar/socket/
diff --git a/dockerised_local_env/Makefile b/dockerised_local_env/Makefile
deleted file mode 100644
index d48a672..0000000
--- a/dockerised_local_env/Makefile
+++ /dev/null
@@ -1,75 +0,0 @@
-GERRIT_JOB=Gerrit-bazel-stable-2.16
-BUILD_NUM=377
-GERRIT_1_BIN_DIRECTORY=./gerrit-1/bin
-GERRIT_2_BIN_DIRECTORY=./gerrit-2/bin
-GERRIT_1_LIB_DIRECTORY=./gerrit-1/lib
-GERRIT_2_LIB_DIRECTORY=./gerrit-2/lib
-GERRIT_1_ETC_DIRECTORY=./gerrit-1/etc
-GERRIT_2_ETC_DIRECTORY=./gerrit-2/etc
-GERRIT_1_PLUGINS_DIRECTORY=./gerrit-1/plugins
-GERRIT_2_PLUGINS_DIRECTORY=./gerrit-2/plugins
-CORE_PLUGINS=replication
-CI_URL=https://gerrit-ci.gerritforge.com/job
-MYDIR=$(shell basename $(shell pwd))
-WGET=wget -N -q
-
-all: prepare download build
-
-prepare:
-	-mkdir -p $(GERRIT_1_PLUGINS_DIRECTORY) $(GERRIT_2_PLUGINS_DIRECTORY) $(GERRIT_1_BIN_DIRECTORY) $(GERRIT_2_BIN_DIRECTORY) $(GERRIT_1_ETC_DIRECTORY) $(GERRIT_2_ETC_DIRECTORY) $(GERRIT_1_LIB_DIRECTORY) $(GERRIT_2_LIB_DIRECTORY)
-
-download: gerrit plugin_websession_flatfile \
-	plugin_healthcheck \
-	plugin_delete_project \
-	plugin_multi_site
-
-
-gerrit: prepare
-	$(WGET) $(CI_URL)/$(GERRIT_JOB)/lastSuccessfulBuild/artifact/gerrit/bazel-bin/release.war -P $(GERRIT_1_BIN_DIRECTORY)
-	cp $(GERRIT_1_BIN_DIRECTORY)/*.war $(GERRIT_2_BIN_DIRECTORY)
-	for plugin in $(CORE_PLUGINS); do $(WGET) $(CI_URL)/$(GERRIT_JOB)/lastSuccessfulBuild/artifact/gerrit/bazel-bin/plugins/$$plugin/$$plugin.jar -P $(GERRIT_1_PLUGINS_DIRECTORY); done
-	cp $(GERRIT_1_PLUGINS_DIRECTORY)/*.jar $(GERRIT_2_PLUGINS_DIRECTORY)
-
-plugin_websession_flatfile: prepare
-	$(WGET) $(CI_URL)/plugin-websession-flatfile-bazel-master-stable-2.16/lastSuccessfulBuild/artifact/bazel-bin/plugins/websession-flatfile/websession-flatfile.jar -P $(GERRIT_1_PLUGINS_DIRECTORY)
-	cp $(GERRIT_1_PLUGINS_DIRECTORY)/websession-flatfile.jar $(GERRIT_2_PLUGINS_DIRECTORY)/websession-flatfile.jar
-
-plugin_multi_site: prepare
-	$(WGET) $(CI_URL)/plugin-multi-site-bazel-stable-2.16/lastSuccessfulBuild/artifact/bazel-bin/plugins/multi-site/multi-site.jar -P $(GERRIT_1_LIB_DIRECTORY)
-	cp $(GERRIT_1_PLUGINS_DIRECTORY)/replication.jar $(GERRIT_1_LIB_DIRECTORY)
-	cp $(GERRIT_1_LIB_DIRECTORY)/*.jar $(GERRIT_2_LIB_DIRECTORY)
-
-plugin_healthcheck: prepare
-	$(WGET) $(CI_URL)/plugin-healthcheck-bazel-stable-2.16/lastSuccessfulBuild/artifact/bazel-bin/plugins/healthcheck/healthcheck.jar -P $(GERRIT_1_PLUGINS_DIRECTORY)
-	cp $(GERRIT_1_PLUGINS_DIRECTORY)/healthcheck.jar $(GERRIT_2_PLUGINS_DIRECTORY)/healthcheck.jar
-
-plugin_delete_project: prepare
-	$(WGET) $(CI_URL)/plugin-delete-project-bazel-stable-2.16/lastSuccessfulBuild/artifact/bazel-bin/plugins/delete-project/delete-project.jar -P $(GERRIT_1_PLUGINS_DIRECTORY)
-	cp $(GERRIT_1_PLUGINS_DIRECTORY)/delete-project.jar $(GERRIT_2_PLUGINS_DIRECTORY)/delete-project.jar
-
-build:
-	docker build -t $(MYDIR) ./gerrit-1
-	docker build -t $(MYDIR) ./gerrit-2
-
-clean_gerrit: prepare
-	-rm -fr gerrit-{1,2}/{db,data,cache,db,git,index,etc,bin,tmp,plugins,lib}/*
-	export GERRIT_REPLICATION_INSTANCE=gerrit-2; cat ./gerrit-common/replication.config.template | envsubst '$${GERRIT_REPLICATION_INSTANCE}' > ./gerrit-1/etc/replication.config
-	export GERRIT_REPLICATION_INSTANCE=gerrit-1; cat ./gerrit-common/replication.config.template | envsubst '$${GERRIT_REPLICATION_INSTANCE}' > ./gerrit-2/etc/replication.config
-	cp ./gerrit-common/*.config ./gerrit-1/etc
-	cp ./gerrit-common/*.config ./gerrit-2/etc
-	cp ./gerrit-common/git-daemon.sh ./gerrit-1/bin
-	cp ./gerrit-common/git-daemon.sh ./gerrit-2/bin
-
-init_gerrit:
-	docker-compose down && docker-compose build gerrit-1 && docker-compose build gerrit-2 && docker-compose up -d gerrit-1 && docker-compose up -d gerrit-2
-
-init_all: clean_gerrit download
-		docker-compose down && docker-compose build && INIT=1 docker-compose up -d
-restart_gerrit_1:
-		cp ./gerrit-common/*.db ./gerrit-1/db
-		-docker-compose kill gerrit-1
-		sleep 3; INIT=0 docker-compose up -d gerrit-1
-restart_gerrit_2:
-		cp ./gerrit-common/*.db ./gerrit-2/db
-		-docker-compose kill gerrit-2
-		sleep 3; INIT=0 docker-compose up -d gerrit-2
diff --git a/dockerised_local_env/README.md b/dockerised_local_env/README.md
deleted file mode 100644
index 92be0cd..0000000
--- a/dockerised_local_env/README.md
+++ /dev/null
@@ -1,64 +0,0 @@
-# Dockerised test environment
-
-## Prerequisites
-
-* envsubst:
-
-```bash
-brew install gettext
-brew link --force gettext
-```
-
-* wget:
-
-```bash
-brew install wget
-```
-
-## Instructions
-
-The docker compose provided in this directory is meant to orchestrate the spin up
-of a dockerised test environment with the latest stable Gerrit version.
-Run it with:
-
-```bash
-make init_all
-```
-
-The spin up will take a while, check what is going on with:
-
-```bash
-docker-compose logs -f
-```
-
-*NOTE:* If you want to run any ssh command as admin you can use the ssh keys into the *gerrit-{1,2}/ssh* directory.
-
-If you need to restart one of the Gerrit instances to simulate, for example,
-an upgrade, you can do it this way:
-
-```bash
-make restart_gerrit_1 # (or make restart_gerrit_2)
-```
-
-## How to test
-
-Consider the
-[instructions](https://gerrit-review.googlesource.com/Documentation/dev-e2e-tests.html)
-on how to use Gerrit core's Gatling framework, to run non-core test scenarios
-such as this plugin one below:
-
-```bash
-sbt "gatling:testOnly com.googlesource.gerrit.plugins.multisite.scenarios.CloneUsingMultiGerrit1"
-```
-
-This is a scenario that can serve as an example for how to start testing a
-multi-site Gerrit system, here such as this dockerized one. That scenario tries
-to clone a project created on this dockerized multi Gerrit, from gerrit-1 (port
-8081). The scenario therefore expects Gerrit multi-site to have properly
-synchronized the new project from the up node gerrit-2 to gerrit-1. That
-project gets deleted after by the (so aggregate) scenario.
-
-Scenario scala source files and their companion json resource ones are stored
-under the usual src/test directories. That structure follows the scala package
-one from the scenario classes. The core framework expects such a directory
-structure for both the scala and resources (json data) files.
diff --git a/dockerised_local_env/docker-compose.yaml b/dockerised_local_env/docker-compose.yaml
deleted file mode 100644
index b15684d..0000000
--- a/dockerised_local_env/docker-compose.yaml
+++ /dev/null
@@ -1,111 +0,0 @@
-version: '3'
-services:
-  gerrit-1:
-    build: ./gerrit-1
-    networks:
-      gerrit-net:
-    environment:
-      INIT: ${INIT:-1}
-    volumes:
-       - ./gerrit-1/git:/var/gerrit/git
-       - ./gerrit-1/logs:/var/gerrit/logs
-       - ./gerrit-1/ssh:/var/gerrit/.ssh
-       - ./gerrit-1/index:/var/gerrit/index
-       - ./gerrit-1/data:/var/gerrit/data
-       - ./gerrit-1/etc:/var/gerrit/etc
-       - ./gerrit-1/db:/var/gerrit/db
-       - ./gerrit-1/plugins:/var/gerrit/plugins
-       - ./gerrit-1/lib:/var/gerrit/lib
-       - ./gerrit-1/tmp:/var/gerrit/tmp
-       - ./gerrit-common/shared-dir:/var/gerrit/shared-dir
-    ports:
-       - "39418:29418"
-       - "8081:8080"
-    depends_on:
-      - sshd
-      - zookeeper
-      - kafka-broker
-    container_name: gerrit-1
-  gerrit-2:
-    build: ./gerrit-2
-    networks:
-      gerrit-net:
-    environment:
-      INIT: ${INIT:-1}
-    volumes:
-       - ./gerrit-2/git:/var/gerrit/git
-       - ./gerrit-2/logs:/var/gerrit/logs
-       - ./gerrit-2/ssh:/var/gerrit/.ssh
-       - ./gerrit-2/index:/var/gerrit/index
-       - ./gerrit-2/data:/var/gerrit/data
-       - ./gerrit-2/etc:/var/gerrit/etc
-       - ./gerrit-2/db:/var/gerrit/db
-       - ./gerrit-2/plugins:/var/gerrit/plugins
-       - ./gerrit-2/lib:/var/gerrit/lib
-       - ./gerrit-2/tmp:/var/gerrit/tmp
-       - ./gerrit-common/shared-dir:/var/gerrit/shared-dir
-    ports:
-       - "49418:29418"
-       - "8082:8080"
-    depends_on:
-      - sshd
-      - zookeeper
-      - kafka-broker
-    container_name: gerrit-2
-  sshd:
-    build: ./sshd
-    networks:
-      gerrit-net:
-    volumes:
-       - ./gerrit-2/git:/var/gerrit-2/git
-       - ./gerrit-2/ssh:/root/.ssh
-       - ./gerrit-1/git:/var/gerrit-1/git
-    container_name: sshd
-  zookeeper:
-    image: wurstmeister/zookeeper:latest
-    networks:
-      gerrit-net:
-    ports:
-      - "2181:2181"
-  kafka-broker:
-    image: wurstmeister/kafka:2.12-2.1.0
-    networks:
-      gerrit-net:
-    ports:
-      - "9092:9092"
-    container_name: kafka-broker
-    environment:
-      KAFKA_ADVERTISED_HOST_NAME: kafka-broker
-      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
-  haproxy:
-    build: haproxy
-    ports:
-      - "8080:8080"
-      - "29418:29418"
-    networks:
-      gerrit-net:
-    depends_on:
-      - syslog-sidecar
-      - gerrit-1
-      - gerrit-2
-    environment:
-      - SYSLOG_SIDECAR=syslog-sidecar
-      - GERRIT_1=gerrit-1
-      - GERRIT_1_SSH=29418
-      - GERRIT_1_HTTP=8080
-      - GERRIT_2=gerrit-2
-      - GERRIT_2_SSH=29418
-      - GERRIT_2_HTTP=8080
-      - HAPROXY_HTTP_PORT=8080
-      - HAPROXY_SSH_PORT=29418
-  syslog-sidecar:
-    image: balabit/syslog-ng:3.19.1
-    volumes:
-      - "./syslog-sidecar/logs:/var/log/syslog-ng"
-      - "./syslog-sidecar/socket:/var/run/syslog-ng"
-      - "./syslog-sidecar/config/:/etc/syslog-ng"
-    networks:
-      gerrit-net:
-networks:
-  gerrit-net:
-    driver: bridge
diff --git a/dockerised_local_env/gerrit-1/Dockerfile b/dockerised_local_env/gerrit-1/Dockerfile
deleted file mode 100644
index 0842933..0000000
--- a/dockerised_local_env/gerrit-1/Dockerfile
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM openjdk:8-jdk-alpine
-
-RUN adduser -D -h /var/gerrit gerrit && \
-    apk update && apk upgrade && \
-    apk add --no-cache bash git openssh netcat-openbsd curl ttf-dejavu && \
-    apk add --no-cache git-daemon
-
-COPY --chown=gerrit:gerrit bin/release.war /var/gerrit/bin/gerrit.war
-COPY --chown=gerrit:gerrit plugins /var/gerrit/plugins
-COPY --chown=gerrit:gerrit etc /var/gerrit/etc
-
-ADD bin/git-daemon.sh /usr/local/bin/git-daemon.sh
-RUN chmod +x /usr/local/bin/git-daemon.sh
-
-USER gerrit
-
-WORKDIR /var/gerrit
-
-COPY docker-entrypoint.sh /bin
-
-ENTRYPOINT /bin/docker-entrypoint.sh
diff --git a/dockerised_local_env/gerrit-1/docker-entrypoint.sh b/dockerised_local_env/gerrit-1/docker-entrypoint.sh
deleted file mode 100755
index d0eb5f2..0000000
--- a/dockerised_local_env/gerrit-1/docker-entrypoint.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/bash -ex
-
-echo "Starting git daemon"
-/usr/local/bin/git-daemon.sh &
-
-if [[ $INIT == 1 ]]; then
-  echo "Initializing Gerrit..."
-  java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit --batch --dev --install-all-plugins --no-auto-start
-  java -jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit --index accounts
-  java -jar /var/gerrit/bin/gerrit.war reindex -d /var/gerrit --index groups
-fi
-
-java -jar /var/gerrit/bin/gerrit.war daemon
diff --git a/dockerised_local_env/gerrit-1/ssh/authorized_keys b/dockerised_local_env/gerrit-1/ssh/authorized_keys
deleted file mode 100644
index 951a480..0000000
--- a/dockerised_local_env/gerrit-1/ssh/authorized_keys
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4e8vBvNFfv/tkKbS2HnnmVpy+AL0pDRQCLoXy6dqjA+67wjBy8Bexn+iH5YDfvNq89Q//6gJ5vV+uGvhzBWrELPQyuim9hBhKooGf5STzr8qrO5SWyhuiE+L3gBQdqoxgC/Bzb5hAAQinGqCdyQAPaPuEP1nse4MEQTzNRhUhsjHdHAVz4gY12NvXoPIP+1ObHDp5rz1HkwWFAyiQpxhctB6r9SyJRkaaesN8X8q4wEVnK0+zhGawenhfPAzPETiLmg2k5IaHhWG+zsExfrLOoKRvc4EPTHbmyRNlefSciU9c00lrivSfLu4x2864uKaLRMQIEZV9EqgPur+At5nTutodBWz/kvyf19D+RnsG7+jJQVOWbAbQtmjxNbYH6IvnMBgLqQf8MEbTvXdnOF0Q0iCfoyhHrD4IueOmcdUOBkXEpqHn05FUX7/+UY8ZUG64+o4cz0A0g3BypigmI/ksoNAQA/AiehXNmhjI67J8clAsY/s3TJUZE/f8JFg5tO7SVCba65Ja7vlyyBDn6VTSuOYJ2ofzByvdaUxqtV9y8AvE1K/NOWDwNoQ/HGQWTVCBcu1+CM0RsObMuoFzZ/t7MY29tmB5R/nGl99Z/PWTvxrpsQx+TcUEKem3eS4ToYqUn/+5/5Wa3oUP1F4POYgRJh8x0DBJSkEuS44XeMsXHw== your_email@example.com
diff --git a/dockerised_local_env/gerrit-1/ssh/config b/dockerised_local_env/gerrit-1/ssh/config
deleted file mode 100644
index e76bebf..0000000
--- a/dockerised_local_env/gerrit-1/ssh/config
+++ /dev/null
@@ -1,6 +0,0 @@
-Host *
-   User root
-   IdentityFile /var/gerrit/.ssh/id_rsa
-   PreferredAuthentications publickey
-   # Not ideal at all. Just a quick workaround to avoid updating the known_hosts at startup
-   StrictHostKeyChecking no
diff --git a/dockerised_local_env/gerrit-1/ssh/id_rsa b/dockerised_local_env/gerrit-1/ssh/id_rsa
deleted file mode 100644
index 6535ddf..0000000
--- a/dockerised_local_env/gerrit-1/ssh/id_rsa
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-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
------END RSA PRIVATE KEY-----
diff --git a/dockerised_local_env/gerrit-1/ssh/id_rsa.pub b/dockerised_local_env/gerrit-1/ssh/id_rsa.pub
deleted file mode 100644
index 951a480..0000000
--- a/dockerised_local_env/gerrit-1/ssh/id_rsa.pub
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4e8vBvNFfv/tkKbS2HnnmVpy+AL0pDRQCLoXy6dqjA+67wjBy8Bexn+iH5YDfvNq89Q//6gJ5vV+uGvhzBWrELPQyuim9hBhKooGf5STzr8qrO5SWyhuiE+L3gBQdqoxgC/Bzb5hAAQinGqCdyQAPaPuEP1nse4MEQTzNRhUhsjHdHAVz4gY12NvXoPIP+1ObHDp5rz1HkwWFAyiQpxhctB6r9SyJRkaaesN8X8q4wEVnK0+zhGawenhfPAzPETiLmg2k5IaHhWG+zsExfrLOoKRvc4EPTHbmyRNlefSciU9c00lrivSfLu4x2864uKaLRMQIEZV9EqgPur+At5nTutodBWz/kvyf19D+RnsG7+jJQVOWbAbQtmjxNbYH6IvnMBgLqQf8MEbTvXdnOF0Q0iCfoyhHrD4IueOmcdUOBkXEpqHn05FUX7/+UY8ZUG64+o4cz0A0g3BypigmI/ksoNAQA/AiehXNmhjI67J8clAsY/s3TJUZE/f8JFg5tO7SVCba65Ja7vlyyBDn6VTSuOYJ2ofzByvdaUxqtV9y8AvE1K/NOWDwNoQ/HGQWTVCBcu1+CM0RsObMuoFzZ/t7MY29tmB5R/nGl99Z/PWTvxrpsQx+TcUEKem3eS4ToYqUn/+5/5Wa3oUP1F4POYgRJh8x0DBJSkEuS44XeMsXHw== your_email@example.com
diff --git a/dockerised_local_env/gerrit-2/Dockerfile b/dockerised_local_env/gerrit-2/Dockerfile
deleted file mode 100644
index d71b6c2..0000000
--- a/dockerised_local_env/gerrit-2/Dockerfile
+++ /dev/null
@@ -1,21 +0,0 @@
-FROM openjdk:8-jdk-alpine
-
-RUN adduser -D -h /var/gerrit gerrit && \
-    apk update && apk upgrade && \
-    apk add --no-cache bash git openssh netcat-openbsd curl ttf-dejavu && \
-    apk add --no-cache git-daemon
-
-COPY --chown=gerrit:gerrit bin/release.war /var/gerrit/bin/gerrit.war
-COPY --chown=gerrit:gerrit plugins/* /var/gerrit/plugins/
-COPY --chown=gerrit:gerrit etc /var/gerrit/etc
-
-ADD bin/git-daemon.sh /usr/local/bin/git-daemon.sh
-RUN chmod +x /usr/local/bin/git-daemon.sh
-
-USER gerrit
-
-WORKDIR /var/gerrit
-
-COPY docker-entrypoint.sh /bin
-
-ENTRYPOINT /bin/docker-entrypoint.sh
diff --git a/dockerised_local_env/gerrit-2/docker-entrypoint.sh b/dockerised_local_env/gerrit-2/docker-entrypoint.sh
deleted file mode 100755
index 06f928f..0000000
--- a/dockerised_local_env/gerrit-2/docker-entrypoint.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash -ex
-
-echo "Starting git daemon"
-/usr/local/bin/git-daemon.sh &
-
-if [[ $INIT == 1 ]]; then
-  java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit --batch --dev --no-auto-start --install-all-plugins
-
-  echo "Remove git repos created during init phase"
-  rm -fr /var/gerrit/git/*
-
-  echo "Waiting for gerrit1 server to become available."
-  sleep 120
-
-  chmod go-r /var/gerrit/.ssh/id_rsa
-  ssh-keyscan -t rsa -p 29418 gerrit-1 > /var/gerrit/.ssh/known_hosts
-  ssh -p 29418 admin@gerrit-1 replication start
-
-  echo "Waiting for replication to complete."
-  sleep 30
-fi
-
-java -jar /var/gerrit/bin/gerrit.war daemon
diff --git a/dockerised_local_env/gerrit-2/ssh/authorized_keys b/dockerised_local_env/gerrit-2/ssh/authorized_keys
deleted file mode 100644
index 951a480..0000000
--- a/dockerised_local_env/gerrit-2/ssh/authorized_keys
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4e8vBvNFfv/tkKbS2HnnmVpy+AL0pDRQCLoXy6dqjA+67wjBy8Bexn+iH5YDfvNq89Q//6gJ5vV+uGvhzBWrELPQyuim9hBhKooGf5STzr8qrO5SWyhuiE+L3gBQdqoxgC/Bzb5hAAQinGqCdyQAPaPuEP1nse4MEQTzNRhUhsjHdHAVz4gY12NvXoPIP+1ObHDp5rz1HkwWFAyiQpxhctB6r9SyJRkaaesN8X8q4wEVnK0+zhGawenhfPAzPETiLmg2k5IaHhWG+zsExfrLOoKRvc4EPTHbmyRNlefSciU9c00lrivSfLu4x2864uKaLRMQIEZV9EqgPur+At5nTutodBWz/kvyf19D+RnsG7+jJQVOWbAbQtmjxNbYH6IvnMBgLqQf8MEbTvXdnOF0Q0iCfoyhHrD4IueOmcdUOBkXEpqHn05FUX7/+UY8ZUG64+o4cz0A0g3BypigmI/ksoNAQA/AiehXNmhjI67J8clAsY/s3TJUZE/f8JFg5tO7SVCba65Ja7vlyyBDn6VTSuOYJ2ofzByvdaUxqtV9y8AvE1K/NOWDwNoQ/HGQWTVCBcu1+CM0RsObMuoFzZ/t7MY29tmB5R/nGl99Z/PWTvxrpsQx+TcUEKem3eS4ToYqUn/+5/5Wa3oUP1F4POYgRJh8x0DBJSkEuS44XeMsXHw== your_email@example.com
diff --git a/dockerised_local_env/gerrit-2/ssh/config b/dockerised_local_env/gerrit-2/ssh/config
deleted file mode 100644
index e76bebf..0000000
--- a/dockerised_local_env/gerrit-2/ssh/config
+++ /dev/null
@@ -1,6 +0,0 @@
-Host *
-   User root
-   IdentityFile /var/gerrit/.ssh/id_rsa
-   PreferredAuthentications publickey
-   # Not ideal at all. Just a quick workaround to avoid updating the known_hosts at startup
-   StrictHostKeyChecking no
diff --git a/dockerised_local_env/gerrit-2/ssh/id_rsa b/dockerised_local_env/gerrit-2/ssh/id_rsa
deleted file mode 100644
index 6535ddf..0000000
--- a/dockerised_local_env/gerrit-2/ssh/id_rsa
+++ /dev/null
@@ -1,51 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-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
------END RSA PRIVATE KEY-----
diff --git a/dockerised_local_env/gerrit-2/ssh/id_rsa.pub b/dockerised_local_env/gerrit-2/ssh/id_rsa.pub
deleted file mode 100644
index 951a480..0000000
--- a/dockerised_local_env/gerrit-2/ssh/id_rsa.pub
+++ /dev/null
@@ -1 +0,0 @@
-ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC4e8vBvNFfv/tkKbS2HnnmVpy+AL0pDRQCLoXy6dqjA+67wjBy8Bexn+iH5YDfvNq89Q//6gJ5vV+uGvhzBWrELPQyuim9hBhKooGf5STzr8qrO5SWyhuiE+L3gBQdqoxgC/Bzb5hAAQinGqCdyQAPaPuEP1nse4MEQTzNRhUhsjHdHAVz4gY12NvXoPIP+1ObHDp5rz1HkwWFAyiQpxhctB6r9SyJRkaaesN8X8q4wEVnK0+zhGawenhfPAzPETiLmg2k5IaHhWG+zsExfrLOoKRvc4EPTHbmyRNlefSciU9c00lrivSfLu4x2864uKaLRMQIEZV9EqgPur+At5nTutodBWz/kvyf19D+RnsG7+jJQVOWbAbQtmjxNbYH6IvnMBgLqQf8MEbTvXdnOF0Q0iCfoyhHrD4IueOmcdUOBkXEpqHn05FUX7/+UY8ZUG64+o4cz0A0g3BypigmI/ksoNAQA/AiehXNmhjI67J8clAsY/s3TJUZE/f8JFg5tO7SVCba65Ja7vlyyBDn6VTSuOYJ2ofzByvdaUxqtV9y8AvE1K/NOWDwNoQ/HGQWTVCBcu1+CM0RsObMuoFzZ/t7MY29tmB5R/nGl99Z/PWTvxrpsQx+TcUEKem3eS4ToYqUn/+5/5Wa3oUP1F4POYgRJh8x0DBJSkEuS44XeMsXHw== your_email@example.com
diff --git a/dockerised_local_env/gerrit-common/ReviewDB.h2.db b/dockerised_local_env/gerrit-common/ReviewDB.h2.db
deleted file mode 100644
index d23d444..0000000
--- a/dockerised_local_env/gerrit-common/ReviewDB.h2.db
+++ /dev/null
Binary files differ
diff --git a/dockerised_local_env/gerrit-common/ReviewDB.trace.db b/dockerised_local_env/gerrit-common/ReviewDB.trace.db
deleted file mode 100644
index 52681d8..0000000
--- a/dockerised_local_env/gerrit-common/ReviewDB.trace.db
+++ /dev/null
@@ -1,3 +0,0 @@
-11-23 08:24:02 jdbc[3]: exception
-org.h2.jdbc.JdbcSQLException: Table "SCHEMA_VERSION" not found; SQL statement:
-SELECT T.version_nbr,T.singleton FROM schema_version T WHERE T.singleton=? [42102-176]
diff --git a/dockerised_local_env/gerrit-common/gerrit.config b/dockerised_local_env/gerrit-common/gerrit.config
deleted file mode 100644
index 0a47bea..0000000
--- a/dockerised_local_env/gerrit-common/gerrit.config
+++ /dev/null
@@ -1,39 +0,0 @@
-[gerrit]
-	basePath = git
-	serverId = ff17821f-9571-42df-b690-30660f2d6e20
-	canonicalWebUrl = http://localhost:8080/
-	installModule = com.googlesource.gerrit.plugins.multisite.Module
-[database]
-	type = h2
-	database = db/ReviewDB
-[noteDb "changes"]
-	autoMigrate = true
-	disableReviewDb = true
-	primaryStorage = note db
-	read = true
-	sequence = true
-	write = true
-[container]
-	javaOptions = "-Dflogger.backend_factory=com.google.common.flogger.backend.log4j.Log4jBackendFactory#getInstance"
-	javaOptions = "-Dflogger.logging_context=com.google.gerrit.server.logging.LoggingContext#getInstance"
-	javaHome = /usr/lib/jvm/java-1.8-openjdk/jre
-	user = gerrit
-[index]
-	type = LUCENE
-[auth]
-	type = DEVELOPMENT_BECOME_ANY_ACCOUNT
-[receive]
-	enableSignedPush = false
-[sendemail]
-	smtpServer = localhost
-[sshd]
-	listenAddress = *:29418
-	advertisedAddress = *:29418
-[httpd]
-	listenUrl = proxy-http://*:8080/
-[cache]
-	directory = cache
-[plugins]
-	allowRemoteAdmin = true
-[plugin "websession-flatfile"]
-    directory = /var/gerrit/shared-dir
diff --git a/dockerised_local_env/gerrit-common/git-daemon.sh b/dockerised_local_env/gerrit-common/git-daemon.sh
deleted file mode 100644
index a54c8e0..0000000
--- a/dockerised_local_env/gerrit-common/git-daemon.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-git daemon --verbose --enable=receive-pack --base-path=/var/gerrit/git --export-all
diff --git a/dockerised_local_env/gerrit-common/healthcheck.config b/dockerised_local_env/gerrit-common/healthcheck.config
deleted file mode 100644
index 849e23f..0000000
--- a/dockerised_local_env/gerrit-common/healthcheck.config
+++ /dev/null
@@ -1,9 +0,0 @@
-[healthcheck]
-	timeout = 10s
-
-[healthcheck "querychanges"]
-	# No changes available when Gerrit is installed from scratch
-	enabled = false
-
-[healthcheck "auth"]
-	username = "admin"
\ No newline at end of file
diff --git a/dockerised_local_env/gerrit-common/multi-site.config b/dockerised_local_env/gerrit-common/multi-site.config
deleted file mode 100644
index deec00f..0000000
--- a/dockerised_local_env/gerrit-common/multi-site.config
+++ /dev/null
@@ -1,21 +0,0 @@
-[index]
-  maxTries = 6
-  retryInterval = 30000
-  numStripedLocks = 100
-
-[kafka]
-	bootstrapServers = kafka-broker:9092
-	securityProtocol = PLAINTEXT
-	indexEventTopic = gerrit_index
-	streamEventTopic = gerrit_stream
-	projectListEventTopic = gerrit_list_project
-	cacheEventTopic = gerrit_cache_eviction
-
-[kafka "subscriber"]
-	pollingIntervalMs = 1000
-	KafkaProp-enableAutoCommit = true
-	KafkaProp-autoCommitIntervalMs = 1000
-	KafkaProp-autoOffsetReset = latest
-
-[ref-database "zookeeper"]
-	connectString = "zookeeper:2181"
diff --git a/dockerised_local_env/gerrit-common/replication.config.template b/dockerised_local_env/gerrit-common/replication.config.template
deleted file mode 100644
index 3864e92..0000000
--- a/dockerised_local_env/gerrit-common/replication.config.template
+++ /dev/null
@@ -1,17 +0,0 @@
-[remote "Replication"]
-    url = git://${GERRIT_REPLICATION_INSTANCE}:9418/${name}.git
-    adminUrl = ssh://root@sshd:22/var/${GERRIT_REPLICATION_INSTANCE}/git/${name}.git
-    push = +refs/*:refs/*
-    timeout = 600
-    rescheduleDelay = 15
-    replicationDelay = 5
-    mirror = true
-    createMissingRepositories = true
-    replicateProjectDeletions = true
-    replicateHiddenProjects = true
-[gerrit]
-    autoReload = true
-    replicateOnStartup = false
-[replication]
-    lockErrorMaxRetries = 5
-    maxRetries = 5
diff --git a/dockerised_local_env/haproxy/Dockerfile b/dockerised_local_env/haproxy/Dockerfile
deleted file mode 100644
index dd3f9cd..0000000
--- a/dockerised_local_env/haproxy/Dockerfile
+++ /dev/null
@@ -1,13 +0,0 @@
-FROM haproxy:1.9.4
-
-RUN apt-get update && \
-    apt-get -y install gettext-base netcat && \
-    rm -rf /var/lib/apt/lists/* && \
-    mkdir /var/lib/haproxy && \
-    mkdir /var/run/haproxy && \
-    useradd haproxy && \
-    chown haproxy: /var/lib/haproxy /var/run/haproxy
-
-COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg.template
-
-COPY docker-entrypoint.sh /
diff --git a/dockerised_local_env/haproxy/docker-entrypoint.sh b/dockerised_local_env/haproxy/docker-entrypoint.sh
deleted file mode 100755
index b78a994..0000000
--- a/dockerised_local_env/haproxy/docker-entrypoint.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-envsubst < /usr/local/etc/haproxy/haproxy.cfg.template > /usr/local/etc/haproxy/haproxy.cfg
-haproxy -f /usr/local/etc/haproxy/haproxy.cfg
diff --git a/dockerised_local_env/haproxy/haproxy.cfg b/dockerised_local_env/haproxy/haproxy.cfg
deleted file mode 100644
index 000ed9e..0000000
--- a/dockerised_local_env/haproxy/haproxy.cfg
+++ /dev/null
@@ -1,63 +0,0 @@
-global
-    log $SYSLOG_SIDECAR local0
-    maxconn 2048
-
-defaults
-  log     global
-  mode    http
-  option  httplog
-  option  dontlognull
-  timeout connect 5000
-  timeout client  900000
-  timeout server  900000
-  timeout check 30000
-
-frontend haproxynode
-    bind *:$HAPROXY_HTTP_PORT
-    mode http
-    acl redirect_reads url_reg -i git-upload-pack
-    acl redirect_reads url_reg -i clone.bundle
-    acl redirect_writes url_reg -i git-receive-pack
-    use_backend read-backendnodes if redirect_reads
-    use_backend write-backendnodes if redirect_writes
-    default_backend read-backendnodes
-
-frontend git_ssh
-    bind *:$HAPROXY_SSH_PORT
-    option tcplog
-    mode tcp
-    timeout client  5m
-    default_backend ssh
-
-backend read-backendnodes
-    mode http
-    balance source
-    option forwardfor
-    http-request set-header X-Forwarded-Port %[dst_port]
-    default-server inter 10s fall 3 rise 2
-    option httpchk GET /config/server/healthcheck~status HTTP/1.0
-    http-check expect status 200
-    server node1 $GERRIT_1:$GERRIT_1_HTTP check inter 10s
-    server node2 $GERRIT_2:$GERRIT_2_HTTP check inter 10s
-
-backend write-backendnodes
-    mode http
-    balance roundrobin
-    option forwardfor
-    http-request set-header X-Forwarded-Port %[dst_port]
-    default-server inter 10s fall 3 rise 2
-    option httpchk GET /config/server/healthcheck~status HTTP/1.0
-    http-check expect status 200
-    server node1 $GERRIT_1:$GERRIT_1_HTTP check inter 10s
-    server node2 $GERRIT_2:$GERRIT_2_HTTP check inter 10s backup
-
-backend ssh
-    mode tcp
-    option redispatch
-    option httpchk GET /config/server/healthcheck~status HTTP/1.0
-    http-check expect status 200
-    balance source
-    timeout connect 10s
-    timeout server 5m
-    server ssh_node1 $GERRIT_1:$GERRIT_1_SSH check inter 10s check port $GERRIT_1_HTTP inter 10s
-    server ssh_node2 $GERRIT_2:$GERRIT_2_SSH check inter 10s check port $GERRIT_2_HTTP inter 10s backup
diff --git a/dockerised_local_env/sshd/Dockerfile b/dockerised_local_env/sshd/Dockerfile
deleted file mode 100644
index d1065cd..0000000
--- a/dockerised_local_env/sshd/Dockerfile
+++ /dev/null
@@ -1,6 +0,0 @@
-FROM sickp/alpine-sshd:6.8
-
-RUN apk update && apk upgrade && \
-    apk add --no-cache bash git netcat-openbsd curl
-
-COPY sshd_config /etc/ssh/sshd_config
diff --git a/dockerised_local_env/sshd/sshd_config b/dockerised_local_env/sshd/sshd_config
deleted file mode 100644
index c40561f..0000000
--- a/dockerised_local_env/sshd/sshd_config
+++ /dev/null
@@ -1,16 +0,0 @@
-Port 22
-HostKey /etc/ssh/ssh_host_rsa_key
-HostKey /etc/ssh/ssh_host_ecdsa_key
-HostKey /etc/ssh/ssh_host_ed25519_key
-SyslogFacility AUTHPRIV
-LogLevel INFO
-PermitRootLogin yes
-AuthorizedKeysFile	/root/.ssh/authorized_keys
-PasswordAuthentication no
-ChallengeResponseAuthentication no
-UsePAM yes
-AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
-AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
-AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
-AcceptEnv XMODIFIERS
-Subsystem	sftp	/usr/libexec/openssh/sftp-server
diff --git a/dockerised_local_env/syslog-sidecar/config/syslog-ng.conf b/dockerised_local_env/syslog-sidecar/config/syslog-ng.conf
deleted file mode 100644
index bbd27b6..0000000
--- a/dockerised_local_env/syslog-sidecar/config/syslog-ng.conf
+++ /dev/null
@@ -1,31 +0,0 @@
-@version: 3.11
-
-options {
-    keep_hostname(yes);
-    create_dirs(yes);
-    ts_format(iso);
-    time_reopen (10);
-    chain_hostnames (no);
-};
-
-source s_net {
-    tcp(
-     ip("0.0.0.0")
-    );
-    udp(
-     ip("0.0.0.0")
-    );
-    syslog(
-     ip("0.0.0.0")
-    );
-    unix-stream("/var/run/lock/syslog-ng.sock");
-};
-
-destination logfiles {
-    file("/var/log/syslog-ng/$PROGRAM.log");
-};
-
-log {
-    source(s_net);
-    destination(logfiles);
-};
diff --git a/external_plugin_deps.bzl b/external_plugin_deps.bzl
index fa6c4e7..9cbb332 100644
--- a/external_plugin_deps.bzl
+++ b/external_plugin_deps.bzl
@@ -3,12 +3,12 @@
 def external_plugin_deps():
     maven_jar(
         name = "global-refdb",
-        artifact = "com.gerritforge:global-refdb:3.0.2",
-        sha1 = "293a807bd82a284c215213b442b3930258e01f5e",
+        artifact = "com.gerritforge:global-refdb:3.1.2",
+        sha1 = "6ddee3de0f3fe9254453118ae1eca481ec03e957",
     )
 
     maven_jar(
         name = "events-broker",
-        artifact = "com.gerritforge:events-broker:3.0.5",
-        sha1 = "7abf72d2252f975baff666fbbf28b7036767aa81",
+        artifact = "com.gerritforge:events-broker:3.1.4",
+        sha1 = "5672908dde0bd02cabc95efe34a8d8507d44b6ac",
     )
diff --git a/setup_local_env/configs/gerrit.config b/setup_local_env/configs/gerrit.config
index f9eca89..884b5be 100644
--- a/setup_local_env/configs/gerrit.config
+++ b/setup_local_env/configs/gerrit.config
@@ -39,7 +39,7 @@
     allowRemoteAdmin = true
 [plugin "websession-flatfile"]
     directory = $FAKE_NFS
-[plugin "kafka-events"]
+[plugin "events-kafka"]
     sendAsync = true
     bootstrapServers = localhost:$KAFKA_PORT
     groupId = $KAFKA_GROUP_ID
diff --git a/setup_local_env/configs/replication.config b/setup_local_env/configs/replication.config
index cf7f66a..ece1b3e 100644
--- a/setup_local_env/configs/replication.config
+++ b/setup_local_env/configs/replication.config
@@ -1,6 +1,7 @@
 [remote "Replication"]
     $REPLICATION_URL
     push = +refs/*:refs/*
+    mirror = true
     timeout = 600
     rescheduleDelay = 15
     replicationDelay = $REPLICATION_DELAY_SEC
diff --git a/setup_local_env/setup.sh b/setup_local_env/setup.sh
index e78d167..777e7fc 100755
--- a/setup_local_env/setup.sh
+++ b/setup_local_env/setup.sh
@@ -16,9 +16,10 @@
 
 
 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
-GERRIT_BRANCH=stable-3.0
+GERRIT_BRANCH=stable-3.1
 GERRIT_CI=https://archive-ci.gerritforge.com/view/Plugins-$GERRIT_BRANCH/job
 LAST_BUILD=lastSuccessfulBuild/artifact/bazel-bin/plugins
+EVENTS_BROKER_VER=`grep 'com.gerritforge:events-broker' $(dirname $0)/../external_plugin_deps.bzl | cut -d '"' -f 2 | cut -d ':' -f 3`
 
 function check_application_requirements {
   type haproxy >/dev/null 2>&1 || { echo >&2 "Require haproxy but it's not installed. Aborting."; exit 1; }
@@ -356,13 +357,13 @@
 ing"; exit 1; }
 
 echo "Downloading events-broker library $GERRIT_BRANCH"
-  wget https://repo1.maven.org/maven2/com/gerritforge/events-broker/3.0.5/events-broker-3.0.5.jar \
+  wget https://repo1.maven.org/maven2/com/gerritforge/events-broker/$EVENTS_BROKER_VER/events-broker-$EVENTS_BROKER_VER.jar \
   -O $DEPLOYMENT_LOCATION/events-broker.jar || { echo >&2 "Cannot download events-broker library: Check internet connection. Abort\
 ing"; exit 1; }
 
-echo "Downloading kafka-events plugin $GERRIT_BRANCH"
-  wget $GERRIT_CI/plugin-kafka-events-bazel-$GERRIT_BRANCH/$LAST_BUILD/kafka-events/kafka-events.jar \
-  -O $DEPLOYMENT_LOCATION/kafka-events.jar || { echo >&2 "Cannot download kafka-events plugin: Check internet connection. Abort\
+echo "Downloading events-kafka plugin $GERRIT_BRANCH"
+  wget $GERRIT_CI/plugin-events-kafka-bazel-$GERRIT_BRANCH/$LAST_BUILD/events-kafka/events-kafka.jar \
+  -O $DEPLOYMENT_LOCATION/events-kafka.jar || { echo >&2 "Cannot download events-kafka plugin: Check internet connection. Abort\
 ing"; exit 1; }
 
 echo "Downloading metrics-reporter-prometheus plugin $GERRIT_BRANCH"
@@ -412,8 +413,8 @@
   echo "Copy events broker library"
   cp -f $DEPLOYMENT_LOCATION/events-broker.jar $LOCATION_TEST_SITE_1/lib/events-broker.jar
 
-  echo "Copy kafka events plugin"
-  cp -f $DEPLOYMENT_LOCATION/kafka-events.jar $LOCATION_TEST_SITE_1/plugins/kafka-events.jar
+  echo "Copy events kafka plugin"
+  cp -f $DEPLOYMENT_LOCATION/events-kafka.jar $LOCATION_TEST_SITE_1/plugins/events-kafka.jar
 
   echo "Copy metrics-reporter-prometheus plugin"
   cp -f $DEPLOYMENT_LOCATION/metrics-reporter-prometheus.jar $LOCATION_TEST_SITE_1/plugins/metrics-reporter-prometheus.jar
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jProjectVersionLogger.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jProjectVersionLogger.java
index 7e38e06..c2c4b46 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jProjectVersionLogger.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jProjectVersionLogger.java
@@ -14,7 +14,7 @@
 
 package com.googlesource.gerrit.plugins.multisite;
 
-import com.google.gerrit.reviewdb.client.Project.NameKey;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.util.SystemLog;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -34,7 +34,7 @@
   }
 
   @Override
-  public void log(NameKey projectName, long currentVersion, long replicationLag) {
+  public void log(Project.NameKey projectName, long currentVersion, long replicationLag) {
     if (replicationLag > 0) {
       verLog.warn(
           "{ \"project\":\"{}\", \"version\":{}, \"lag\":{} }",
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jSharedRefLogger.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jSharedRefLogger.java
index 95202b5..003ce5b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jSharedRefLogger.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/Log4jSharedRefLogger.java
@@ -19,9 +19,9 @@
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.common.GitPerson;
 import com.google.gerrit.json.OutputFormat;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.CommonConverters;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.util.SystemLog;
@@ -59,8 +59,7 @@
   @Override
   public void logRefUpdate(String project, Ref currRef, ObjectId newRefValue) {
     if (!ObjectId.zeroId().equals(newRefValue)) {
-      try (Repository repository =
-              gitRepositoryManager.openRepository(new Project.NameKey(project));
+      try (Repository repository = gitRepositoryManager.openRepository(Project.nameKey(project));
           RevWalk walk = new RevWalk(repository)) {
         GitPerson committer = null;
         String commitMessage = null;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/MultiSiteMetrics.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/MultiSiteMetrics.java
new file mode 100644
index 0000000..fbe1152
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/MultiSiteMetrics.java
@@ -0,0 +1,35 @@
+// Copyright (C) 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.multisite;
+
+import com.google.gerrit.metrics.Description;
+import com.google.gerrit.metrics.Field;
+import com.google.gerrit.server.logging.PluginMetadata;
+
+public abstract class MultiSiteMetrics {
+
+  public Field<String> stringField(String metadataKey, String description) {
+    return Field.ofString(
+            metadataKey,
+            (metadataBuilder, fieldValue) ->
+                metadataBuilder.addPluginMetadata(PluginMetadata.create(metadataKey, fieldValue)))
+        .description(description)
+        .build();
+  }
+
+  public Description rateDescription(String unit, String description) {
+    return new Description(description).setRate().setUnit(unit);
+  }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/ProjectVersionLogger.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/ProjectVersionLogger.java
index 0ae1cc2..6ababb6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/ProjectVersionLogger.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/ProjectVersionLogger.java
@@ -14,7 +14,7 @@
 
 package com.googlesource.gerrit.plugins.multisite;
 
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 
 public interface ProjectVersionLogger {
 
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/SharedRefDatabaseWrapper.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/SharedRefDatabaseWrapper.java
index 0ea78a9..b56f2ea 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/SharedRefDatabaseWrapper.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/SharedRefDatabaseWrapper.java
@@ -18,8 +18,8 @@
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbLockException;
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbSystemError;
 import com.google.common.annotations.VisibleForTesting;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.registration.DynamicItem;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.inject.Inject;
 import java.util.Optional;
 import org.eclipse.jgit.lib.ObjectId;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerMetrics.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerMetrics.java
index f6be65a..1d9f46d 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerMetrics.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/broker/BrokerMetrics.java
@@ -15,14 +15,13 @@
 package com.googlesource.gerrit.plugins.multisite.broker;
 
 import com.google.gerrit.metrics.Counter1;
-import com.google.gerrit.metrics.Description;
-import com.google.gerrit.metrics.Field;
 import com.google.gerrit.metrics.MetricMaker;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
+import com.googlesource.gerrit.plugins.multisite.MultiSiteMetrics;
 
 @Singleton
-public class BrokerMetrics {
+public class BrokerMetrics extends MultiSiteMetrics {
   private static final String PUBLISHER_SUCCESS_COUNTER = "broker_msg_publisher_counter";
   private static final String PUBLISHER_FAILURE_COUNTER = "broker_msg_publisher_failure_counter";
 
@@ -35,17 +34,15 @@
     this.brokerPublisherSuccessCounter =
         metricMaker.newCounter(
             "multi_site/broker/broker_message_publisher_counter",
-            new Description("Number of messages published by the broker publisher")
-                .setRate()
-                .setUnit("messages"),
-            Field.ofString(PUBLISHER_SUCCESS_COUNTER, "Broker message published count"));
+            rateDescription("messages", "Number of messages published by the broker publisher"),
+            stringField(PUBLISHER_SUCCESS_COUNTER, "Broker message published count"));
+
     this.brokerPublisherFailureCounter =
         metricMaker.newCounter(
             "multi_site/broker/broker_message_publisher_failure_counter",
-            new Description("Number of messages failed to publish by the broker publisher")
-                .setRate()
-                .setUnit("errors"),
-            Field.ofString(PUBLISHER_FAILURE_COUNTER, "Broker failed to publish message count"));
+            rateDescription(
+                "errors", "Number of messages failed to publish by the broker publisher"),
+            stringField(PUBLISHER_FAILURE_COUNTER, "Broker failed to publish message count"));
   }
 
   public void incrementBrokerPublishedMessage() {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetrics.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetrics.java
index 1474262..4459859 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetrics.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetrics.java
@@ -16,15 +16,15 @@
 
 import com.gerritforge.gerrit.eventbroker.EventMessage;
 import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.metrics.Counter1;
 import com.google.gerrit.metrics.Description;
-import com.google.gerrit.metrics.Field;
 import com.google.gerrit.metrics.MetricMaker;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.events.Event;
 import com.google.gerrit.server.events.RefUpdatedEvent;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
+import com.googlesource.gerrit.plugins.multisite.MultiSiteMetrics;
 import com.googlesource.gerrit.plugins.multisite.ProjectVersionLogger;
 import com.googlesource.gerrit.plugins.multisite.validation.ProjectVersionRefUpdate;
 import com.googlesource.gerrit.plugins.replication.RefReplicatedEvent;
@@ -37,7 +37,7 @@
 import java.util.Optional;
 
 @Singleton
-public class SubscriberMetrics {
+public class SubscriberMetrics extends MultiSiteMetrics {
   private static final FluentLogger logger = FluentLogger.forEnclosingClass();
   private static final String SUBSCRIBER_SUCCESS_COUNTER = "subscriber_msg_consumer_counter";
   private static final String SUBSCRIBER_FAILURE_COUNTER =
@@ -67,15 +67,14 @@
             new Description("Number of messages consumed by the subscriber")
                 .setRate()
                 .setUnit("messages"),
-            Field.ofString(SUBSCRIBER_SUCCESS_COUNTER, "Subscriber message consumed count"));
+            stringField(SUBSCRIBER_SUCCESS_COUNTER, "Subscriber message consumed count"));
     this.subscriberFailureCounter =
         metricMaker.newCounter(
             "multi_site/subscriber/subscriber_message_consumer_failure_counter",
             new Description("Number of messages failed to consume by the subscriber consumer")
                 .setRate()
                 .setUnit("errors"),
-            Field.ofString(
-                SUBSCRIBER_FAILURE_COUNTER, "Subscriber failed to consume messages count"));
+            stringField(SUBSCRIBER_FAILURE_COUNTER, "Subscriber failed to consume messages count"));
     metricMaker.newCallbackMetric(
         REPLICATION_LAG_SEC,
         Long.class,
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandler.java
index 6d1d6cf..5212aa4 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandler.java
@@ -14,7 +14,7 @@
 
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
-import com.google.gerrit.reviewdb.client.Account;
+import com.google.gerrit.entities.Account;
 import com.google.gerrit.server.index.account.AccountIndexer;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandler.java
index 8340a5f..8d41500 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandler.java
@@ -15,7 +15,7 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 import com.google.common.base.Splitter;
-import com.google.gerrit.reviewdb.client.Change;
+import com.google.gerrit.entities.Change;
 import com.google.gerrit.server.index.change.ChangeIndexer;
 import com.google.gerrit.server.notedb.ChangeNotes;
 import com.google.gerrit.server.util.ManualRequestContext;
@@ -23,15 +23,12 @@
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.googlesource.gerrit.plugins.multisite.Configuration;
-import com.googlesource.gerrit.plugins.multisite.Configuration.Index;
 import com.googlesource.gerrit.plugins.multisite.forwarder.events.ChangeIndexEvent;
 import com.googlesource.gerrit.plugins.multisite.index.ChangeChecker;
 import com.googlesource.gerrit.plugins.multisite.index.ChangeCheckerImpl;
 import com.googlesource.gerrit.plugins.multisite.index.ForwardedIndexExecutor;
 import java.util.Optional;
-import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Index a change using {@link ChangeIndexer}. This class is meant to be used on the receiving side
@@ -41,12 +38,8 @@
  */
 @Singleton
 public class ForwardedIndexChangeHandler
-    extends ForwardedIndexingHandler<String, ChangeIndexEvent> {
+    extends ForwardedIndexingHandlerWithRetries<String, ChangeIndexEvent> {
   private final ChangeIndexer indexer;
-  private final ScheduledExecutorService indexExecutor;
-  private final OneOffRequestContext oneOffCtx;
-  private final int retryInterval;
-  private final int maxTries;
   private final ChangeCheckerImpl.Factory changeCheckerFactory;
 
   @Inject
@@ -56,43 +49,22 @@
       @ForwardedIndexExecutor ScheduledExecutorService indexExecutor,
       OneOffRequestContext oneOffCtx,
       ChangeCheckerImpl.Factory changeCheckerFactory) {
-    super(configuration.index().numStripedLocks());
+    super(indexExecutor, configuration, oneOffCtx);
     this.indexer = indexer;
-    this.indexExecutor = indexExecutor;
-    this.oneOffCtx = oneOffCtx;
     this.changeCheckerFactory = changeCheckerFactory;
-
-    Index indexConfig = configuration.index();
-    this.retryInterval = indexConfig != null ? indexConfig.retryInterval() : 0;
-    this.maxTries = indexConfig != null ? indexConfig.maxTries() : 0;
   }
 
   @Override
   protected void doIndex(String id, Optional<ChangeIndexEvent> indexEvent) {
-    doIndex(id, indexEvent, 0);
+    attemptToIndex(id, indexEvent, 0);
   }
 
-  private void doIndex(String id, Optional<ChangeIndexEvent> indexEvent, int retryCount) {
+  @Override
+  protected void attemptToIndex(String id, Optional<ChangeIndexEvent> indexEvent, int retryCount) {
     ChangeChecker checker = changeCheckerFactory.create(id);
     Optional<ChangeNotes> changeNotes = checker.getChangeNotes();
     if (changeNotes.isPresent()) {
-      ChangeNotes notes = changeNotes.get();
-      reindex(notes);
-
-      if (checker.isChangeUpToDate(indexEvent)) {
-        if (retryCount > 0) {
-          log.warn("Change {} has been eventually indexed after {} attempt(s)", id, retryCount);
-        } else {
-          log.debug("Change {} successfully indexed", id);
-        }
-      } else {
-        log.warn(
-            "Change {} seems too old compared to the event timestamp (event={} >> change-Ts={})",
-            id,
-            indexEvent,
-            checker);
-        rescheduleIndex(id, indexEvent, retryCount + 1);
-      }
+      reindexAndCheckIsUpToDate(id, indexEvent, checker, retryCount);
     } else {
       log.warn(
           "Change {} not present yet in local Git repository (event={}) after {} attempt(s)",
@@ -106,42 +78,20 @@
     }
   }
 
-  private void reindex(ChangeNotes notes) {
+  @Override
+  protected void reindex(String id) {
     try (ManualRequestContext ctx = oneOffCtx.open()) {
+      ChangeChecker checker = changeCheckerFactory.create(id);
+      Optional<ChangeNotes> changeNotes = checker.getChangeNotes();
+      ChangeNotes notes = changeNotes.get();
       notes.reload();
       indexer.index(notes.getChange());
     }
   }
 
-  private boolean rescheduleIndex(
-      String id, Optional<ChangeIndexEvent> indexEvent, int retryCount) {
-    if (retryCount > maxTries) {
-      log.error(
-          "Change {} could not be indexed after {} retries. Change index could be stale.",
-          id,
-          retryCount);
-      return false;
-    }
-
-    log.warn(
-        "Retrying for the #{} time to index Change {} after {} msecs",
-        retryCount,
-        id,
-        retryInterval);
-    @SuppressWarnings("unused")
-    Future<?> possiblyIgnoredError =
-        indexExecutor.schedule(
-            () -> {
-              try (ManualRequestContext ctx = oneOffCtx.open()) {
-                Context.setForwardedEvent(true);
-                doIndex(id, indexEvent, retryCount);
-              } catch (Exception e) {
-                log.warn("Change {} could not be indexed", id, e);
-              }
-            },
-            retryInterval,
-            TimeUnit.MILLISECONDS);
-    return true;
+  @Override
+  protected String indexName() {
+    return "change";
   }
 
   @Override
@@ -151,7 +101,7 @@
   }
 
   private static Change.Id parseChangeId(String id) {
-    Change.Id changeId = new Change.Id(Integer.parseInt(Splitter.on("~").splitToList(id).get(1)));
+    Change.Id changeId = Change.id(Integer.parseInt(Splitter.on("~").splitToList(id).get(1)));
     return changeId;
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
index f9423b5..c4906a9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandler.java
@@ -14,8 +14,9 @@
 
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
-import com.google.gerrit.reviewdb.client.AccountGroup;
+import com.google.gerrit.entities.AccountGroup;
 import com.google.gerrit.server.index.group.GroupIndexer;
+import com.google.gerrit.server.util.OneOffRequestContext;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.googlesource.gerrit.plugins.multisite.Configuration;
@@ -23,9 +24,7 @@
 import com.googlesource.gerrit.plugins.multisite.index.ForwardedIndexExecutor;
 import com.googlesource.gerrit.plugins.multisite.index.GroupChecker;
 import java.util.Optional;
-import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Index a group using {@link GroupIndexer}. This class is meant to be used on the receiving side of
@@ -34,76 +33,42 @@
  * done for the same group uuid
  */
 @Singleton
-public class ForwardedIndexGroupHandler extends ForwardedIndexingHandler<String, GroupIndexEvent> {
+public class ForwardedIndexGroupHandler
+    extends ForwardedIndexingHandlerWithRetries<String, GroupIndexEvent> {
   private final GroupIndexer indexer;
   private final GroupChecker groupChecker;
-  private final ScheduledExecutorService indexExecutor;
-  private final int retryInterval;
-  private final int maxTries;
 
   @Inject
   ForwardedIndexGroupHandler(
       GroupIndexer indexer,
       Configuration config,
       GroupChecker groupChecker,
+      OneOffRequestContext oneOffRequestContext,
       @ForwardedIndexExecutor ScheduledExecutorService indexExecutor) {
-    super(config.index().numStripedLocks());
+    super(indexExecutor, config, oneOffRequestContext);
     this.indexer = indexer;
     this.groupChecker = groupChecker;
-    this.indexExecutor = indexExecutor;
-    Configuration.Index indexConfig = config.index();
-    this.retryInterval = indexConfig != null ? indexConfig.retryInterval() : 0;
-    this.maxTries = indexConfig != null ? indexConfig.maxTries() : 0;
   }
 
   @Override
   protected void doIndex(String uuid, Optional<GroupIndexEvent> event) {
-    doIndex(uuid, event, 0);
+    attemptToIndex(uuid, event, 0);
   }
 
-  protected void doIndex(String uuid, Optional<GroupIndexEvent> groupIndexEvent, int retryCount) {
-    indexer.index(new AccountGroup.UUID(uuid));
-    if (groupChecker.isGroupUpToDate(groupIndexEvent)) {
-      if (retryCount > 0) {
-        log.warn("Group '{}' has been eventually indexed after {} attempt(s)", uuid, retryCount);
-      } else {
-        log.debug("Group '{}' successfully indexed", uuid);
-      }
-    } else {
-      log.debug("Group '{}' rescheduling indexing", uuid);
-      rescheduleIndex(uuid, groupIndexEvent, retryCount + 1);
-    }
+  @Override
+  protected void reindex(String id) {
+    indexer.index(AccountGroup.uuid(id));
   }
 
-  private boolean rescheduleIndex(
-      String uuid, Optional<GroupIndexEvent> indexEvent, int retryCount) {
-    if (retryCount > maxTries) {
-      log.error(
-          "Group '{}' could not be indexed after {} retries. Group index could be stale.",
-          uuid,
-          retryCount);
-      return false;
-    }
+  @Override
+  protected String indexName() {
+    return "group";
+  }
 
-    log.warn(
-        "Retrying for the #{} time to index Group {} after {} msecs",
-        retryCount,
-        uuid,
-        retryInterval);
-    @SuppressWarnings("unused")
-    Future<?> possiblyIgnoredError =
-        indexExecutor.schedule(
-            () -> {
-              try {
-                Context.setForwardedEvent(true);
-                doIndex(uuid, indexEvent, retryCount);
-              } catch (Exception e) {
-                log.warn("Group {} could not be indexed", uuid, e);
-              }
-            },
-            retryInterval,
-            TimeUnit.MILLISECONDS);
-    return true;
+  @Override
+  protected void attemptToIndex(
+      String uuid, Optional<GroupIndexEvent> groupIndexEvent, int retryCount) {
+    reindexAndCheckIsUpToDate(uuid, groupIndexEvent, groupChecker, retryCount);
   }
 
   @Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandler.java
index e5f7e10..3787a80 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandler.java
@@ -14,8 +14,9 @@
 
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.index.project.ProjectIndexer;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.server.util.OneOffRequestContext;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
 import com.googlesource.gerrit.plugins.multisite.Configuration;
@@ -24,7 +25,6 @@
 import com.googlesource.gerrit.plugins.multisite.index.ProjectChecker;
 import java.util.Optional;
 import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
 
 /**
  * Index a project using {@link ProjectIndexer}. This class is meant to be used on the receiving
@@ -34,78 +34,40 @@
  */
 @Singleton
 public class ForwardedIndexProjectHandler
-    extends ForwardedIndexingHandler<String, ProjectIndexEvent> {
+    extends ForwardedIndexingHandlerWithRetries<String, ProjectIndexEvent> {
   private final ProjectIndexer indexer;
-  private final int retryInterval;
-  private final int maxTries;
   private final ProjectChecker projectChecker;
-  private final ScheduledExecutorService indexExecutor;
 
   @Inject
   ForwardedIndexProjectHandler(
       ProjectIndexer indexer,
       ProjectChecker projectChecker,
+      OneOffRequestContext oneOffRequestContext,
       @ForwardedIndexExecutor ScheduledExecutorService indexExecutor,
       Configuration config) {
-    super(config.index().numStripedLocks());
+    super(indexExecutor, config, oneOffRequestContext);
     this.indexer = indexer;
-    Configuration.Index indexConfig = config.index();
-    this.retryInterval = indexConfig != null ? indexConfig.retryInterval() : 0;
-    this.maxTries = indexConfig != null ? indexConfig.maxTries() : 0;
-    this.indexExecutor = indexExecutor;
     this.projectChecker = projectChecker;
   }
 
   @Override
   protected void doIndex(String projectName, Optional<ProjectIndexEvent> event) {
-    if (!attemptIndex(projectName, event)) {
-      log.warn("First Attempt failed, scheduling again after {} msecs", retryInterval);
-      rescheduleIndex(projectName, event, 1);
-    }
+    attemptToIndex(projectName, event, 0);
   }
 
-  public boolean attemptIndex(String projectName, Optional<ProjectIndexEvent> event) {
-    log.debug("Attempt to index project {}, event: [{}]", projectName, event);
-    final Project.NameKey projectNameKey = new Project.NameKey(projectName);
-    if (projectChecker.isProjectUpToDate(projectNameKey)) {
-      indexer.index(projectNameKey);
-      log.debug("Project {} successfully indexed", projectName);
-      return true;
-    }
-    return false;
+  @Override
+  protected void reindex(String id) {
+    indexer.index(Project.nameKey(id));
   }
 
-  public void rescheduleIndex(
-      String projectName, Optional<ProjectIndexEvent> event, int retryCount) {
-    if (retryCount > maxTries) {
-      log.error(
-          "Project {} could not be indexed after {} retries. index could be stale.",
-          projectName,
-          retryCount);
+  @Override
+  protected String indexName() {
+    return "project";
+  }
 
-      return;
-    }
-
-    log.warn(
-        "Retrying for the #{} time to index project {} after {} msecs",
-        retryCount,
-        projectName,
-        retryInterval);
-
-    indexExecutor.schedule(
-        () -> {
-          Context.setForwardedEvent(true);
-          if (!attemptIndex(projectName, event)) {
-            log.warn(
-                "Attempt {} to index project {} failed, scheduling again after {} msecs",
-                retryCount,
-                projectName,
-                retryInterval);
-            rescheduleIndex(projectName, event, retryCount + 1);
-          }
-        },
-        retryInterval,
-        TimeUnit.MILLISECONDS);
+  @Override
+  protected void attemptToIndex(String id, Optional<ProjectIndexEvent> indexEvent, int retryCount) {
+    reindexAndCheckIsUpToDate(id, indexEvent, projectChecker, retryCount);
   }
 
   @Override
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandlerWithRetries.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandlerWithRetries.java
new file mode 100644
index 0000000..5c64431
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexingHandlerWithRetries.java
@@ -0,0 +1,109 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.multisite.forwarder;
+
+import com.google.gerrit.server.util.ManualRequestContext;
+import com.google.gerrit.server.util.OneOffRequestContext;
+import com.googlesource.gerrit.plugins.multisite.Configuration;
+import com.googlesource.gerrit.plugins.multisite.forwarder.events.IndexEvent;
+import com.googlesource.gerrit.plugins.multisite.index.UpToDateChecker;
+import java.util.Optional;
+import java.util.concurrent.Future;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Base class to handle forwarded indexing. This class is meant to be extended by classes used on
+ * the receiving side of the {@link IndexEvent} since it will prevent indexing to be forwarded again
+ * causing an infinite forwarding loop between the 2 nodes. It will also make sure no concurrent
+ * indexing is done for the same id.
+ */
+public abstract class ForwardedIndexingHandlerWithRetries<T, E extends IndexEvent>
+    extends ForwardedIndexingHandler<T, E> {
+
+  private final int retryInterval;
+  private final int maxTries;
+  private final ScheduledExecutorService indexExecutor;
+  protected final OneOffRequestContext oneOffCtx;
+
+  ForwardedIndexingHandlerWithRetries(
+      ScheduledExecutorService indexExecutor,
+      Configuration configuration,
+      OneOffRequestContext oneOffCtx) {
+    super(configuration.index().numStripedLocks());
+
+    Configuration.Index indexConfig = configuration.index();
+    this.oneOffCtx = oneOffCtx;
+    this.indexExecutor = indexExecutor;
+    this.retryInterval = indexConfig != null ? indexConfig.retryInterval() : 0;
+    this.maxTries = indexConfig != null ? indexConfig.maxTries() : 0;
+  }
+
+  protected abstract void reindex(T id);
+
+  protected abstract String indexName();
+
+  protected abstract void attemptToIndex(T id, Optional<E> indexEvent, int retryCount);
+
+  protected boolean rescheduleIndex(T id, Optional<E> indexEvent, int retryCount) {
+    if (retryCount > maxTries) {
+      log.error(
+          "{} {} could not be indexed after {} retries. {} index could be stale.",
+          indexName(),
+          id,
+          retryCount,
+          indexName());
+      return false;
+    }
+
+    log.warn(
+        "Retrying for the #{} time to index {} {} after {} msecs",
+        retryCount,
+        indexName(),
+        id,
+        retryInterval);
+    @SuppressWarnings("unused")
+    Future<?> possiblyIgnoredError =
+        indexExecutor.schedule(
+            () -> {
+              try (ManualRequestContext ctx = oneOffCtx.open()) {
+                Context.setForwardedEvent(true);
+                attemptToIndex(id, indexEvent, retryCount);
+              } catch (Exception e) {
+                log.warn("{} {} could not be indexed", indexName(), id, e);
+              }
+            },
+            retryInterval,
+            TimeUnit.MILLISECONDS);
+    return true;
+  }
+
+  public final void reindexAndCheckIsUpToDate(
+      T id, Optional<E> indexEvent, UpToDateChecker<E> upToDateChecker, int retryCount) {
+    reindex(id);
+
+    if (!upToDateChecker.isUpToDate(indexEvent)) {
+      log.warn("{} {} is not up-to-date. Rescheduling", indexName(), id);
+      rescheduleIndex(id, indexEvent, retryCount + 1);
+      return;
+    }
+    if (retryCount > 0) {
+      log.warn(
+          "{} {} has been eventually indexed after {} attempt(s)", indexName(), id, retryCount);
+    } else {
+      log.debug("{} {} successfully indexed", indexName(), id);
+    }
+  }
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandler.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandler.java
index 30b2b35..919a64f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandler.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandler.java
@@ -14,7 +14,7 @@
 
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -47,7 +47,7 @@
    * @throws IOException
    */
   public void update(ProjectListUpdateEvent event) throws IOException {
-    Project.NameKey projectKey = new Project.NameKey(event.projectName);
+    Project.NameKey projectKey = Project.nameKey(event.projectName);
     try {
       Context.setForwardedEvent(true);
       if (event.remove) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/GsonParser.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/GsonParser.java
index ddc184a..0bbdada 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/GsonParser.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/GsonParser.java
@@ -15,31 +15,36 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 import com.google.common.base.MoreObjects;
-import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.AccountGroup;
+import com.google.gerrit.entities.Account;
+import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.server.events.EventGson;
 import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.inject.Inject;
 import com.googlesource.gerrit.plugins.multisite.cache.Constants;
 
 public final class GsonParser {
+  private final Gson gson;
 
-  private GsonParser() {}
+  @Inject
+  public GsonParser(@EventGson Gson gson) {
+    this.gson = gson;
+  }
 
   @SuppressWarnings("cast")
-  public static Object fromJson(String cacheName, Object json) {
-    Gson gson = new GsonBuilder().create();
+  public Object fromJson(String cacheName, Object json) {
     Object key;
     // Need to add a case for 'adv_bases'
     switch (cacheName) {
       case Constants.ACCOUNTS:
-        key = gson.fromJson(nullToEmpty(json).toString().trim(), Account.Id.class);
+        key = Account.id(jsonElement(json).getAsJsonObject().get("id").getAsInt());
         break;
       case Constants.GROUPS:
-        key = gson.fromJson(nullToEmpty(json).toString().trim(), AccountGroup.Id.class);
+        key = AccountGroup.id(jsonElement(json).getAsJsonObject().get("id").getAsInt());
         break;
       case Constants.GROUPS_BYINCLUDE:
       case Constants.GROUPS_MEMBERS:
-        key = gson.fromJson(nullToEmpty(json).toString().trim(), AccountGroup.UUID.class);
+        key = AccountGroup.uuid(jsonElement(json).getAsJsonObject().get("uuid").getAsString());
         break;
       case Constants.PROJECT_LIST:
         key = gson.fromJson(nullToEmpty(json).toString(), Object.class);
@@ -58,33 +63,11 @@
     return key;
   }
 
-  public static String toJson(String cacheName, Object key) {
-    Gson gson = new GsonBuilder().create();
-    String json;
-    // Need to add a case for 'adv_bases'
-    switch (cacheName) {
-      case Constants.ACCOUNTS:
-        json = gson.toJson(key, Account.Id.class);
-        break;
-      case Constants.GROUPS:
-        json = gson.toJson(key, AccountGroup.Id.class);
-        break;
-      case Constants.GROUPS_BYINCLUDE:
-      case Constants.GROUPS_MEMBERS:
-        json = gson.toJson(key, AccountGroup.UUID.class);
-        break;
-      case Constants.PROJECT_LIST:
-      default:
-        if (key instanceof String) {
-          json = (String) key;
-        } else {
-          json = gson.toJson(key);
-        }
-    }
-    return json;
+  private JsonElement jsonElement(Object json) {
+    return gson.fromJson(nullToEmpty(json), JsonElement.class);
   }
 
-  private static Object nullToEmpty(Object value) {
-    return MoreObjects.firstNonNull(value, "");
+  private static String nullToEmpty(Object value) {
+    return MoreObjects.firstNonNull(value, "").toString().trim();
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/router/CacheEvictionEventRouter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/router/CacheEvictionEventRouter.java
index a6cd8c4..0fb0c0a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/router/CacheEvictionEventRouter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/router/CacheEvictionEventRouter.java
@@ -23,15 +23,18 @@
 
 public class CacheEvictionEventRouter implements ForwardedEventRouter<CacheEvictionEvent> {
   private final ForwardedCacheEvictionHandler cacheEvictionHanlder;
+  private final GsonParser gsonParser;
 
   @Inject
-  public CacheEvictionEventRouter(ForwardedCacheEvictionHandler cacheEvictionHanlder) {
+  public CacheEvictionEventRouter(
+      ForwardedCacheEvictionHandler cacheEvictionHanlder, GsonParser gsonParser) {
     this.cacheEvictionHanlder = cacheEvictionHanlder;
+    this.gsonParser = gsonParser;
   }
 
   @Override
   public void route(CacheEvictionEvent cacheEvictionEvent) throws CacheNotFoundException {
-    Object parsedKey = GsonParser.fromJson(cacheEvictionEvent.cacheName, cacheEvictionEvent.key);
+    Object parsedKey = gsonParser.fromJson(cacheEvictionEvent.cacheName, cacheEvictionEvent.key);
     cacheEvictionHanlder.evict(CacheEntry.from(cacheEvictionEvent.cacheName, parsedKey));
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/router/IndexEventRouter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/router/IndexEventRouter.java
index 6ab8c72..202fb42 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/router/IndexEventRouter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/forwarder/router/IndexEventRouter.java
@@ -18,9 +18,8 @@
 import static com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexingHandler.Operation.INDEX;
 
 import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.entities.Account;
 import com.google.gerrit.extensions.events.LifecycleListener;
-import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.Account.Id;
 import com.google.gerrit.server.config.AllUsersName;
 import com.google.inject.Inject;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexAccountHandler;
@@ -72,7 +71,7 @@
           Optional.of(changeIndexEvent));
     } else if (sourceEvent instanceof AccountIndexEvent) {
       AccountIndexEvent accountIndexEvent = (AccountIndexEvent) sourceEvent;
-      indexAccountHandler.indexAsync(new Account.Id(accountIndexEvent.accountId), INDEX);
+      indexAccountHandler.indexAsync(Account.id(accountIndexEvent.accountId), INDEX);
     } else if (sourceEvent instanceof GroupIndexEvent) {
       GroupIndexEvent groupIndexEvent = (GroupIndexEvent) sourceEvent;
       indexGroupHandler.index(groupIndexEvent.groupUUID, INDEX, Optional.of(groupIndexEvent));
@@ -102,13 +101,13 @@
 
   @Override
   public void stop() {
-    Set<Id> accountsToIndex = indexAccountHandler.pendingAccountsToIndex();
+    Set<Account.Id> accountsToIndex = indexAccountHandler.pendingAccountsToIndex();
     if (!accountsToIndex.isEmpty()) {
       logger.atWarning().log("Forcing reindex of accounts %s upon shutdown", accountsToIndex);
       indexAccountHandler.doAsyncIndex();
     }
 
-    Set<Id> accountsIndexFailed = indexAccountHandler.pendingAccountsToIndex();
+    Set<Account.Id> accountsIndexFailed = indexAccountHandler.pendingAccountsToIndex();
     if (!accountsIndexFailed.isEmpty()) {
       logger.atSevere().log(
           "The accounts %s failed to be indexed and their Lucene index is stale",
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeChecker.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeChecker.java
index 3646b3a..9ee59eb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeChecker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeChecker.java
@@ -20,7 +20,7 @@
 import java.util.Optional;
 
 /** Encapsulates the logic of verifying the up-to-date status of a change. */
-public interface ChangeChecker {
+public interface ChangeChecker extends UpToDateChecker<ChangeIndexEvent> {
 
   /**
    * Return the Change nodes read from ReviewDb or NoteDb.
@@ -48,7 +48,7 @@
    * @param indexEvent indexing event
    * @return true if the local Change is up-to-date, false otherwise.
    */
-  public boolean isChangeUpToDate(Optional<ChangeIndexEvent> indexEvent);
+  public boolean isUpToDate(Optional<ChangeIndexEvent> indexEvent);
 
   /**
    * Return the last computed up-to-date Change time-stamp.
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
index f1e80cc..6ba18ed 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ChangeCheckerImpl.java
@@ -14,9 +14,9 @@
 
 package com.googlesource.gerrit.plugins.multisite.index;
 
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Comment;
 import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.Comment;
 import com.google.gerrit.server.CommentsUtil;
 import com.google.gerrit.server.change.ChangeFinder;
 import com.google.gerrit.server.git.GitRepositoryManager;
@@ -85,7 +85,7 @@
   }
 
   @Override
-  public boolean isChangeUpToDate(Optional<ChangeIndexEvent> indexEvent) {
+  public boolean isUpToDate(Optional<ChangeIndexEvent> indexEvent) {
     getComputedChangeTs();
     if (!computedChangeTs.isPresent()) {
       log.warn("Unable to compute last updated ts for change {}", changeId);
@@ -126,7 +126,7 @@
   private String getBranchTargetSha() {
     try {
       try (Repository repo = gitRepoMgr.openRepository(changeNotes.get().getProjectName())) {
-        String refName = changeNotes.get().getChange().getDest().get();
+        String refName = changeNotes.get().getChange().getDest().branch();
         Ref ref = repo.exactRef(refName);
         if (ref == null) {
           log.warn("Unable to find target ref {} for change {}", refName, changeId);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupChecker.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupChecker.java
index 03ac30c..c19d04a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupChecker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupChecker.java
@@ -18,8 +18,10 @@
 import java.util.Optional;
 import org.eclipse.jgit.lib.ObjectId;
 
-public interface GroupChecker {
-  boolean isGroupUpToDate(Optional<GroupIndexEvent> groupIndexEvent);
+public interface GroupChecker extends UpToDateChecker<GroupIndexEvent> {
+
+  @Override
+  boolean isUpToDate(Optional<GroupIndexEvent> groupIndexEvent);
 
   ObjectId getGroupHead(String groupUUID);
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImpl.java
index 5e2a039..e9e40f3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImpl.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImpl.java
@@ -16,8 +16,8 @@
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.flogger.FluentLogger;
-import com.google.gerrit.reviewdb.client.AccountGroup;
-import com.google.gerrit.reviewdb.client.RefNames;
+import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.entities.RefNames;
 import com.google.gerrit.server.config.AllUsersName;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.inject.Inject;
@@ -44,13 +44,13 @@
   }
 
   @Override
-  public boolean isGroupUpToDate(Optional<GroupIndexEvent> groupIndexEvent) {
+  public boolean isUpToDate(Optional<GroupIndexEvent> groupIndexEvent) {
     if (!groupIndexEvent.isPresent()) {
       logger.atWarning().log("Group Index empty, considering this group up-to-date");
       return true;
     }
     GroupIndexEvent event = groupIndexEvent.get();
-    AccountGroup.UUID groupUUID = new AccountGroup.UUID(event.groupUUID);
+    AccountGroup.UUID groupUUID = AccountGroup.uuid(event.groupUUID);
 
     if (event.sha1 == null) {
       logger.atWarning().log(
@@ -79,8 +79,7 @@
   @Override
   public ObjectId getGroupHead(String groupUUID) {
     try (Repository repo = repoManager.openRepository(allUsers)) {
-      return Optional.ofNullable(
-              repo.exactRef(RefNames.refsGroups(new AccountGroup.UUID(groupUUID))))
+      return Optional.ofNullable(repo.exactRef(RefNames.refsGroups(AccountGroup.uuid(groupUUID))))
           .map(Ref::getObjectId)
           .orElse(ObjectId.zeroId());
     } catch (Exception e) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ProjectChecker.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ProjectChecker.java
index 3fabbbd..e040fce 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ProjectChecker.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ProjectChecker.java
@@ -14,9 +14,7 @@
 
 package com.googlesource.gerrit.plugins.multisite.index;
 
-import com.google.gerrit.reviewdb.client.Project;
+import com.googlesource.gerrit.plugins.multisite.forwarder.events.ProjectIndexEvent;
 
 /** Encapsulates the logic of verifying the up-to-date status of a project. */
-public interface ProjectChecker {
-  boolean isProjectUpToDate(Project.NameKey projectName);
-}
+public interface ProjectChecker extends UpToDateChecker<ProjectIndexEvent> {}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ProjectCheckerImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ProjectCheckerImpl.java
index 606ff9d..ba2a7d6 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ProjectCheckerImpl.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/ProjectCheckerImpl.java
@@ -14,9 +14,11 @@
 
 package com.googlesource.gerrit.plugins.multisite.index;
 
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.project.ProjectCache;
 import com.google.inject.Inject;
+import com.googlesource.gerrit.plugins.multisite.forwarder.events.ProjectIndexEvent;
+import java.util.Optional;
 
 public class ProjectCheckerImpl implements ProjectChecker {
   private final ProjectCache projectCache;
@@ -27,7 +29,7 @@
   }
 
   @Override
-  public boolean isProjectUpToDate(Project.NameKey projectName) {
-    return projectCache.get(projectName) != null;
+  public boolean isUpToDate(Optional<ProjectIndexEvent> indexEvent) {
+    return indexEvent.map(e -> Project.nameKey(e.projectName)).map(projectCache::get).isPresent();
   }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/index/UpToDateChecker.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/UpToDateChecker.java
new file mode 100644
index 0000000..8a7a231
--- /dev/null
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/index/UpToDateChecker.java
@@ -0,0 +1,28 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.googlesource.gerrit.plugins.multisite.index;
+
+import com.googlesource.gerrit.plugins.multisite.forwarder.events.IndexEvent;
+import java.util.Optional;
+
+public interface UpToDateChecker<E extends IndexEvent> {
+  /**
+   * Check if the local Change is aligned with the indexEvent received.
+   *
+   * @param indexEvent indexing event
+   * @return true if the local Change is up-to-date, false otherwise.
+   */
+  boolean isUpToDate(Optional<E> indexEvent);
+}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteGitRepositoryManager.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteGitRepositoryManager.java
index 594b4a0..6ece734 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteGitRepositoryManager.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteGitRepositoryManager.java
@@ -14,7 +14,7 @@
 
 package com.googlesource.gerrit.plugins.multisite.validation;
 
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.git.LocalDiskRepositoryManager;
 import com.google.gerrit.server.git.RepositoryCaseMismatchException;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteRepository.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteRepository.java
index b3678c6..fa3de64 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteRepository.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteRepository.java
@@ -53,7 +53,6 @@
 
 public class MultiSiteRepository extends Repository {
 
-  private final MultiSiteRefDatabase.Factory multiSiteRefDbFactory;
   private final Repository repository;
   private final RefDatabase refDatabase;
   private final MultiSiteRefDatabase multiSiteRefDatabase;
@@ -68,7 +67,6 @@
       @Assisted String projectName,
       @Assisted Repository repository) {
     super(new BaseRepositoryBuilder());
-    this.multiSiteRefDbFactory = multiSiteRefDbFactory;
     this.repository = repository;
     this.refDatabase = repository.getRefDatabase();
     this.multiSiteRefDatabase = multiSiteRefDbFactory.create(projectName, refDatabase);
@@ -157,6 +155,7 @@
     return repository.getFS();
   }
 
+  @SuppressWarnings("deprecation")
   @Override
   public boolean hasObject(AnyObjectId objectId) {
     return repository.hasObject(objectId);
@@ -230,16 +229,19 @@
     return repository.getAdditionalHaves();
   }
 
+  @SuppressWarnings("deprecation")
   @Override
   public Map<String, Ref> getAllRefs() {
     return repository.getAllRefs();
   }
 
+  @SuppressWarnings("deprecation")
   @Override
   public Map<String, Ref> getTags() {
     return repository.getTags();
   }
 
+  @SuppressWarnings("deprecation")
   @Override
   public Ref peel(Ref ref) {
     return repository.peel(ref);
@@ -397,4 +399,9 @@
   public void autoGC(ProgressMonitor monitor) {
     repository.autoGC(monitor);
   }
+
+  @Override
+  public String getIdentifier() {
+    return repository.getIdentifier();
+  }
 }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java
index b666c02..f831671 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/MultisiteReplicationPushFilter.java
@@ -17,7 +17,7 @@
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbLockException;
 import com.google.common.base.Preconditions;
 import com.google.common.flogger.FluentLogger;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
@@ -63,7 +63,7 @@
     Set<String> outdatedChanges = new HashSet<>();
 
     try (Repository repository =
-        gitRepositoryManager.openRepository(Project.NameKey.parse(projectName))) {
+        gitRepositoryManager.openRepository(Project.nameKey(projectName))) {
       List<RemoteRefUpdate> filteredRefUpdates =
           remoteUpdatesList.stream()
               .filter(
@@ -107,7 +107,7 @@
     String ref = refUpdate.getSrcRef();
     try {
       if (sharedRefDb.isUpToDate(
-          new Project.NameKey(projectName),
+          Project.nameKey(projectName),
           new ObjectIdRef.Unpeeled(Ref.Storage.NETWORK, ref, refUpdate.getNewObjectId()))) {
         return true;
       }
@@ -116,7 +116,7 @@
           projectName, refUpdate, ref);
 
       return sharedRefDb.isUpToDate(
-          new Project.NameKey(projectName),
+          Project.nameKey(projectName),
           new ObjectIdRef.Unpeeled(Ref.Storage.NETWORK, ref, getNotNullExactRef(repository, ref)));
     } catch (GlobalRefDbLockException gle) {
       String message =
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectDeletedSharedDbCleanup.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectDeletedSharedDbCleanup.java
index 9c93793..329c1c3 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectDeletedSharedDbCleanup.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectDeletedSharedDbCleanup.java
@@ -16,8 +16,8 @@
 
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbSystemError;
 import com.google.common.flogger.FluentLogger;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.events.ProjectDeletedListener;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.inject.Inject;
 import com.googlesource.gerrit.plugins.multisite.SharedRefDatabaseWrapper;
 
@@ -42,7 +42,7 @@
         "Deleting project '%s'. Will perform a cleanup in Shared-Ref database.", projectName);
 
     try {
-      sharedDb.remove(new Project.NameKey(projectName));
+      sharedDb.remove(Project.nameKey(projectName));
     } catch (GlobalRefDbSystemError e) {
       validationMetrics.incrementSplitBrain();
       logger.atSevere().withCause(e).log(
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateImpl.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateImpl.java
index 58df181..1e2403f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateImpl.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateImpl.java
@@ -20,8 +20,8 @@
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbSystemError;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.flogger.FluentLogger;
-import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.client.RefNames;
+import com.google.gerrit.entities.Project;
+import com.google.gerrit.entities.RefNames;
 import com.google.gerrit.server.events.Event;
 import com.google.gerrit.server.events.EventListener;
 import com.google.gerrit.server.events.RefUpdatedEvent;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/RefUpdateValidator.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/RefUpdateValidator.java
index aec5619..d7fafe0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/RefUpdateValidator.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/RefUpdateValidator.java
@@ -17,7 +17,7 @@
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbSystemError;
 import com.google.common.base.MoreObjects;
 import com.google.common.flogger.FluentLogger;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import com.google.inject.Inject;
 import com.google.inject.assistedinject.Assisted;
 import com.googlesource.gerrit.plugins.multisite.LockWrapper;
@@ -171,7 +171,7 @@
     try {
       succeeded =
           sharedRefDb.compareAndPut(
-              new Project.NameKey(projectName), refPair.compareRef, refPair.putValue);
+              Project.nameKey(projectName), refPair.compareRef, refPair.putValue);
     } catch (GlobalRefDbSystemError e) {
       logger.atWarning().withCause(e).log(
           "Not able to persist the data in Zookeeper for project '{}' and ref '{}', message: {}",
@@ -198,17 +198,15 @@
         String.format("%s-%s", projectName, refName),
         () ->
             lockWrapperFactory.create(
-                projectName,
-                refName,
-                sharedRefDb.lockRef(new Project.NameKey(projectName), refName)));
+                projectName, refName, sharedRefDb.lockRef(Project.nameKey(projectName), refName)));
 
     RefPair latestRefPair = getLatestLocalRef(refPair);
-    if (sharedRefDb.isUpToDate(new Project.NameKey(projectName), latestRefPair.compareRef)) {
+    if (sharedRefDb.isUpToDate(Project.nameKey(projectName), latestRefPair.compareRef)) {
       return latestRefPair;
     }
 
     if (isNullRef(latestRefPair.compareRef)
-        || sharedRefDb.exists(new Project.NameKey(projectName), refName)) {
+        || sharedRefDb.exists(Project.nameKey(projectName), refName)) {
       validationMetrics.incrementSplitBrainPrevention();
 
       softFailBasedOnEnforcement(
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ValidationMetrics.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ValidationMetrics.java
index ee9c5e5..cd2129a 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ValidationMetrics.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/ValidationMetrics.java
@@ -15,14 +15,13 @@
 package com.googlesource.gerrit.plugins.multisite.validation;
 
 import com.google.gerrit.metrics.Counter1;
-import com.google.gerrit.metrics.Description;
-import com.google.gerrit.metrics.Field;
 import com.google.gerrit.metrics.MetricMaker;
 import com.google.inject.Inject;
 import com.google.inject.Singleton;
+import com.googlesource.gerrit.plugins.multisite.MultiSiteMetrics;
 
 @Singleton
-public class ValidationMetrics {
+public class ValidationMetrics extends MultiSiteMetrics {
   private static final String GIT_UPDATE_SPLIT_BRAIN_PREVENTED = "git_update_split_brain_prevented";
   private static final String GIT_UPDATE_SPLIT_BRAIN = "git_update_split_brain";
 
@@ -34,16 +33,16 @@
     this.splitBrainPreventionCounter =
         metricMaker.newCounter(
             "multi_site/validation/git_update_split_brain_prevented",
-            new Description("Rate of REST API error responses").setRate().setUnit("errors"),
-            Field.ofString(
+            rateDescription("errors", "Rate of REST API error responses"),
+            stringField(
                 GIT_UPDATE_SPLIT_BRAIN_PREVENTED,
                 "Ref-update operations, split-brain detected and prevented"));
 
     this.splitBrainCounter =
         metricMaker.newCounter(
             "multi_site/validation/git_update_split_brain",
-            new Description("Rate of REST API error responses").setRate().setUnit("errors"),
-            Field.ofString(
+            rateDescription("errors", "Rate of REST API error responses"),
+            stringField(
                 GIT_UPDATE_SPLIT_BRAIN,
                 "Ref-update operation left node in a split-brain scenario"));
   }
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/NoopSharedRefDatabase.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/NoopSharedRefDatabase.java
index ef8d9b8..1530838 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/NoopSharedRefDatabase.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/NoopSharedRefDatabase.java
@@ -17,7 +17,7 @@
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDatabase;
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbLockException;
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbSystemError;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import java.util.Optional;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.Ref;
diff --git a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/OutOfSyncException.java b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/OutOfSyncException.java
index 036fa6e..50f06b9 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/OutOfSyncException.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/OutOfSyncException.java
@@ -25,7 +25,7 @@
     super(
         localRef == null
             ? String.format(
-                "Local ref does exists locally for project %s but exists in the shared ref-db",
+                "Local ref doesn't exists locally for project %s but exists in the shared ref-db",
                 project)
             : String.format(
                 "Local ref %s (ObjectId=%s) on project %s is out of sync with the shared ref-db",
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetricsTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetricsTest.java
index ead3189..99148fa 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetricsTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/consumer/SubscriberMetricsTest.java
@@ -19,8 +19,8 @@
 
 import com.gerritforge.gerrit.eventbroker.EventMessage;
 import com.google.common.base.Suppliers;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.metrics.MetricMaker;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.data.RefUpdateAttribute;
 import com.google.gerrit.server.events.RefUpdatedEvent;
 import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/CacheEvictionEventRouterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/CacheEvictionEventRouterTest.java
index 9292262..a632b74 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/CacheEvictionEventRouterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/CacheEvictionEventRouterTest.java
@@ -16,8 +16,10 @@
 
 import static org.mockito.Mockito.verify;
 
+import com.google.gson.Gson;
 import com.googlesource.gerrit.plugins.multisite.forwarder.CacheEntry;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedCacheEvictionHandler;
+import com.googlesource.gerrit.plugins.multisite.forwarder.GsonParser;
 import com.googlesource.gerrit.plugins.multisite.forwarder.events.CacheEvictionEvent;
 import com.googlesource.gerrit.plugins.multisite.forwarder.router.CacheEvictionEventRouter;
 import org.junit.Before;
@@ -34,7 +36,7 @@
 
   @Before
   public void setUp() {
-    router = new CacheEvictionEventRouter(cacheEvictionHandler);
+    router = new CacheEvictionEventRouter(cacheEvictionHandler, new GsonParser(new Gson()));
   }
 
   @Test
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/IndexEventRouterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/IndexEventRouterTest.java
index dd9b20d..1dc07bd 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/IndexEventRouterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/IndexEventRouterTest.java
@@ -14,10 +14,11 @@
 
 package com.googlesource.gerrit.plugins.multisite.event;
 
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.verifyZeroInteractions;
 
-import com.google.gerrit.reviewdb.client.Account;
+import com.google.gerrit.entities.Account;
 import com.google.gerrit.server.config.AllUsersName;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedEventHandler;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexAccountHandler;
@@ -35,7 +36,6 @@
 import com.googlesource.gerrit.plugins.replication.RefReplicationDoneEvent;
 import java.util.Optional;
 import org.eclipse.jgit.lib.ObjectId;
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -70,7 +70,7 @@
     router.route(event);
 
     verify(indexAccountHandler)
-        .indexAsync(new Account.Id(event.accountId), ForwardedIndexingHandler.Operation.INDEX);
+        .indexAsync(Account.id(event.accountId), ForwardedIndexingHandler.Operation.INDEX);
 
     verifyZeroInteractions(indexChangeHandler, indexGroupHandler, indexProjectHandler);
   }
@@ -84,7 +84,7 @@
     router.route(event);
 
     verify(indexAccountHandler)
-        .indexAsync(new Account.Id(event.accountId), ForwardedIndexingHandler.Operation.INDEX);
+        .indexAsync(Account.id(event.accountId), ForwardedIndexingHandler.Operation.INDEX);
 
     verifyZeroInteractions(indexChangeHandler, indexGroupHandler, indexProjectHandler);
 
@@ -149,12 +149,8 @@
   public void routerShouldFailForNotRecognisedEvents() throws Exception {
     final IndexEvent newEventType = new IndexEvent("new-type") {};
 
-    try {
-      router.route(newEventType);
-      Assert.fail("Expected exception for not supported event");
-    } catch (UnsupportedOperationException expected) {
-      verifyZeroInteractions(
-          indexAccountHandler, indexChangeHandler, indexGroupHandler, indexProjectHandler);
-    }
+    assertThrows(UnsupportedOperationException.class, () -> router.route(newEventType));
+    verifyZeroInteractions(
+        indexAccountHandler, indexChangeHandler, indexGroupHandler, indexProjectHandler);
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/StreamEventRouterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/StreamEventRouterTest.java
index 31afa79..3b4bec5 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/event/StreamEventRouterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/event/StreamEventRouterTest.java
@@ -16,9 +16,9 @@
 
 import static org.mockito.Mockito.verify;
 
-import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.Branch;
-import com.google.gerrit.reviewdb.client.Change;
+import com.google.gerrit.entities.Account;
+import com.google.gerrit.entities.BranchNameKey;
+import com.google.gerrit.entities.Change;
 import com.google.gerrit.server.events.CommentAddedEvent;
 import com.google.gerrit.server.util.time.TimeUtil;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedEventHandler;
@@ -51,10 +51,10 @@
 
   private Change aChange() {
     return new Change(
-        new Change.Key("Iabcd1234abcd1234abcd1234abcd1234abcd1234"),
-        new Change.Id(1),
-        new Account.Id(1),
-        new Branch.NameKey("proj", "refs/heads/master"),
+        Change.key("Iabcd1234abcd1234abcd1234abcd1234abcd1234"),
+        Change.id(1),
+        Account.id(1),
+        BranchNameKey.create("proj", "refs/heads/master"),
         TimeUtil.nowTs());
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedCacheEvictionHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedCacheEvictionHandlerTest.java
index c166077..747da79 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedCacheEvictionHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedCacheEvictionHandlerTest.java
@@ -20,8 +20,8 @@
 import static org.mockito.Mockito.verify;
 
 import com.google.common.cache.Cache;
+import com.google.gerrit.entities.Account;
 import com.google.gerrit.extensions.registration.DynamicMap;
-import com.google.gerrit.reviewdb.client.Account;
 import com.googlesource.gerrit.plugins.multisite.cache.Constants;
 import org.junit.Before;
 import org.junit.Rule;
@@ -57,7 +57,7 @@
 
   @Test
   public void testSuccessfulCacheEviction() throws Exception {
-    CacheEntry entry = new CacheEntry(Constants.GERRIT, Constants.ACCOUNTS, new Account.Id(123));
+    CacheEntry entry = new CacheEntry(Constants.GERRIT, Constants.ACCOUNTS, Account.id(123));
     doReturn(cacheMock).when(cacheMapMock).get(entry.getPluginName(), entry.getCacheName());
 
     handler.evict(entry);
@@ -75,7 +75,7 @@
 
   @Test
   public void shouldSetAndUnsetForwardedContext() throws Exception {
-    CacheEntry entry = new CacheEntry(Constants.GERRIT, Constants.ACCOUNTS, new Account.Id(456));
+    CacheEntry entry = new CacheEntry(Constants.GERRIT, Constants.ACCOUNTS, Account.id(456));
     doReturn(cacheMock).when(cacheMapMock).get(entry.getPluginName(), entry.getCacheName());
 
     // this doAnswer is to allow to assert that context is set to forwarded
@@ -98,7 +98,7 @@
 
   @Test
   public void shouldSetAndUnsetForwardedContextEvenIfExceptionIsThrown() throws Exception {
-    CacheEntry entry = new CacheEntry(Constants.GERRIT, Constants.ACCOUNTS, new Account.Id(789));
+    CacheEntry entry = new CacheEntry(Constants.GERRIT, Constants.ACCOUNTS, Account.id(789));
     doReturn(cacheMock).when(cacheMapMock).get(entry.getPluginName(), entry.getCacheName());
 
     doAnswer(
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandlerTest.java
index ff6f00e..704401b 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedEventHandlerTest.java
@@ -15,7 +15,7 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
@@ -91,12 +91,8 @@
         .postEvent(event);
 
     assertThat(Context.isForwardedEvent()).isFalse();
-    try {
-      handler.dispatch(event);
-      fail("should have throw an StorageException");
-    } catch (StorageException e) {
-      assertThat(e.getMessage()).isEqualTo("someMessage");
-    }
+    StorageException thrown = assertThrows(StorageException.class, () -> handler.dispatch(event));
+    assertThat(thrown).hasMessageThat().isEqualTo("someMessage");
     assertThat(Context.isForwardedEvent()).isFalse();
 
     verify(dispatcherMock).postEvent(event);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandlerTest.java
index 0d452a4..32c6319 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexAccountHandlerTest.java
@@ -15,12 +15,12 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import com.google.gerrit.reviewdb.client.Account;
+import com.google.gerrit.entities.Account;
 import com.google.gerrit.server.index.account.AccountIndexer;
 import com.googlesource.gerrit.plugins.multisite.Configuration;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexingHandler.Operation;
@@ -50,7 +50,7 @@
     when(config.index()).thenReturn(index);
     when(index.numStripedLocks()).thenReturn(10);
     handler = new ForwardedIndexAccountHandler(indexerMock, config);
-    id = new Account.Id(123);
+    id = Account.id(123);
   }
 
   @Test
@@ -98,12 +98,9 @@
         .index(id);
 
     assertThat(Context.isForwardedEvent()).isFalse();
-    try {
-      handler.index(id, Operation.INDEX, Optional.empty());
-      fail("should have thrown an IOException");
-    } catch (IOException e) {
-      assertThat(e.getMessage()).isEqualTo("someMessage");
-    }
+    IOException thrown =
+        assertThrows(IOException.class, () -> handler.index(id, Operation.INDEX, Optional.empty()));
+    assertThat(thrown).hasMessageThat().isEqualTo("someMessage");
     assertThat(Context.isForwardedEvent()).isFalse();
 
     verify(indexerMock).index(id);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
index 0a910c5..96470b6 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexChangeHandlerTest.java
@@ -15,7 +15,7 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doThrow;
@@ -24,9 +24,9 @@
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import com.google.gerrit.entities.Change;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.exceptions.StorageException;
-import com.google.gerrit.reviewdb.client.Change;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.server.git.GitRepositoryManager;
 import com.google.gerrit.server.index.change.ChangeIndexer;
 import com.google.gerrit.server.notedb.ChangeNotes;
@@ -82,7 +82,7 @@
   @Before
   public void setUp() throws Exception {
     when(ctxMock.open()).thenReturn(manualRequestContextMock);
-    id = new Change.Id(TEST_CHANGE_NUMBER);
+    id = Change.id(TEST_CHANGE_NUMBER);
     change = new Change(null, id, null, null, TimeUtil.nowTs());
     when(changeNotes.getChange()).thenReturn(change);
     when(changeCheckerFactoryMock.create(any())).thenReturn(changeCheckerAbsentMock);
@@ -163,12 +163,11 @@
         .index(any(Change.class));
 
     assertThat(Context.isForwardedEvent()).isFalse();
-    try {
-      handler.index(TEST_CHANGE_ID, Operation.INDEX, Optional.empty());
-      fail("should have thrown an IOException");
-    } catch (IOException e) {
-      assertThat(e.getMessage()).isEqualTo("someMessage");
-    }
+    IOException thrown =
+        assertThrows(
+            IOException.class,
+            () -> handler.index(TEST_CHANGE_ID, Operation.INDEX, Optional.empty()));
+    assertThat(thrown).hasMessageThat().isEqualTo("someMessage");
     assertThat(Context.isForwardedEvent()).isFalse();
 
     verify(indexerMock, times(1)).index(any(Change.class));
@@ -190,6 +189,6 @@
       }
     }
 
-    when(changeCheckerPresentMock.isChangeUpToDate(any())).thenReturn(changeIsUpToDate);
+    when(changeCheckerPresentMock.isUpToDate(any())).thenReturn(changeIsUpToDate);
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
index b333af0..982ac52 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexGroupHandlerTest.java
@@ -15,15 +15,16 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import com.google.gerrit.reviewdb.client.AccountGroup;
+import com.google.gerrit.entities.AccountGroup;
 import com.google.gerrit.server.index.group.GroupIndexer;
+import com.google.gerrit.server.util.OneOffRequestContext;
 import com.googlesource.gerrit.plugins.multisite.Configuration;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexingHandler.Operation;
 import com.googlesource.gerrit.plugins.multisite.forwarder.events.GroupIndexEvent;
@@ -46,6 +47,7 @@
 
   @Rule public ExpectedException exception = ExpectedException.none();
   @Mock private GroupIndexer indexerMock;
+  @Mock private OneOffRequestContext ctxMock;
   @Mock private ScheduledExecutorService indexExecutorMock;
   @Mock private Configuration config;
   @Mock private Configuration.Index index;
@@ -67,7 +69,7 @@
   @Test
   public void testSuccessfulIndexing() throws Exception {
     handler.index(uuid, Operation.INDEX, Optional.empty());
-    verify(indexerMock).index(new AccountGroup.UUID(uuid));
+    verify(indexerMock).index(AccountGroup.uuid(uuid));
   }
 
   @Test
@@ -88,13 +90,13 @@
                   return null;
                 })
         .when(indexerMock)
-        .index(new AccountGroup.UUID(uuid));
+        .index(AccountGroup.uuid(uuid));
 
     assertThat(Context.isForwardedEvent()).isFalse();
     handler.index(uuid, Operation.INDEX, Optional.empty());
     assertThat(Context.isForwardedEvent()).isFalse();
 
-    verify(indexerMock).index(new AccountGroup.UUID(uuid));
+    verify(indexerMock).index(AccountGroup.uuid(uuid));
   }
 
   @Test
@@ -106,25 +108,23 @@
                   throw new IOException("someMessage");
                 })
         .when(indexerMock)
-        .index(new AccountGroup.UUID(uuid));
+        .index(AccountGroup.uuid(uuid));
 
     assertThat(Context.isForwardedEvent()).isFalse();
-    try {
-      handler.index(uuid, Operation.INDEX, Optional.empty());
-      fail("should have thrown an IOException");
-    } catch (IOException e) {
-      assertThat(e.getMessage()).isEqualTo("someMessage");
-    }
+    IOException thrown =
+        assertThrows(
+            IOException.class, () -> handler.index(uuid, Operation.INDEX, Optional.empty()));
+    assertThat(thrown).hasMessageThat().isEqualTo("someMessage");
     assertThat(Context.isForwardedEvent()).isFalse();
 
-    verify(indexerMock).index(new AccountGroup.UUID(uuid));
+    verify(indexerMock).index(AccountGroup.uuid(uuid));
   }
 
   @Test
   public void shouldChangeIndexEventWheNotUpToDate() throws IOException {
     ForwardedIndexGroupHandler groupHandlerWithOutdatedEvent = groupHandler(false);
     groupHandlerWithOutdatedEvent.index(uuid, Operation.INDEX, groupIndexEvent(uuid));
-    verify(indexerMock).index(new AccountGroup.UUID(uuid));
+    verify(indexerMock).index(AccountGroup.uuid(uuid));
   }
 
   @Test
@@ -137,7 +137,7 @@
 
   private ForwardedIndexGroupHandler groupHandler(boolean checkIsUpToDate) {
     return new ForwardedIndexGroupHandler(
-        indexerMock, config, new TestGroupChecker(checkIsUpToDate), indexExecutorMock);
+        indexerMock, config, new TestGroupChecker(checkIsUpToDate), ctxMock, indexExecutorMock);
   }
 
   private Optional<GroupIndexEvent> groupIndexEvent(String uuid) {
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandlerTest.java
index 9f94d5f..3ce5e14 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedIndexProjectHandlerTest.java
@@ -15,14 +15,15 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.index.project.ProjectIndexer;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.server.util.OneOffRequestContext;
 import com.googlesource.gerrit.plugins.multisite.Configuration;
 import com.googlesource.gerrit.plugins.multisite.forwarder.ForwardedIndexingHandler.Operation;
 import com.googlesource.gerrit.plugins.multisite.index.ProjectChecker;
@@ -44,6 +45,7 @@
   @Rule public ExpectedException exception = ExpectedException.none();
   @Mock private ProjectIndexer indexerMock;
   @Mock private Configuration configMock;
+  @Mock private OneOffRequestContext ctxMock;
   @Mock private ProjectChecker projectCheckerMock;
   @Mock private Configuration.Index indexMock;
   @Mock private ScheduledExecutorService indexExecutorMock;
@@ -56,17 +58,17 @@
     when(indexMock.numStripedLocks()).thenReturn(10);
     when(indexMock.retryInterval()).thenReturn(0);
     when(indexMock.maxTries()).thenReturn(2);
-    when(projectCheckerMock.isProjectUpToDate(any())).thenReturn(true);
+    when(projectCheckerMock.isUpToDate(any())).thenReturn(true);
     handler =
         new ForwardedIndexProjectHandler(
-            indexerMock, projectCheckerMock, indexExecutorMock, configMock);
+            indexerMock, projectCheckerMock, ctxMock, indexExecutorMock, configMock);
     nameKey = "project/name";
   }
 
   @Test
   public void testSuccessfulIndexing() throws Exception {
     handler.index(nameKey, Operation.INDEX, Optional.empty());
-    verify(indexerMock).index(new Project.NameKey(nameKey));
+    verify(indexerMock).index(Project.nameKey(nameKey));
   }
 
   @Test
@@ -87,13 +89,13 @@
                   return null;
                 })
         .when(indexerMock)
-        .index(new Project.NameKey(nameKey));
+        .index(Project.nameKey(nameKey));
 
     assertThat(Context.isForwardedEvent()).isFalse();
     handler.index(nameKey, Operation.INDEX, Optional.empty());
     assertThat(Context.isForwardedEvent()).isFalse();
 
-    verify(indexerMock).index(new Project.NameKey(nameKey));
+    verify(indexerMock).index(Project.nameKey(nameKey));
   }
 
   @Test
@@ -105,26 +107,15 @@
                   throw new IOException("someMessage");
                 })
         .when(indexerMock)
-        .index(new Project.NameKey(nameKey));
+        .index(Project.nameKey(nameKey));
 
     assertThat(Context.isForwardedEvent()).isFalse();
-    try {
-      handler.index(nameKey, Operation.INDEX, Optional.empty());
-      fail("should have thrown an IOException");
-    } catch (IOException e) {
-      assertThat(e.getMessage()).isEqualTo("someMessage");
-    }
+    IOException thrown =
+        assertThrows(
+            IOException.class, () -> handler.index(nameKey, Operation.INDEX, Optional.empty()));
+    assertThat(thrown).hasMessageThat().isEqualTo("someMessage");
     assertThat(Context.isForwardedEvent()).isFalse();
 
-    verify(indexerMock).index(new Project.NameKey(nameKey));
-  }
-
-  @Test
-  public void indexAttemptShouldFailWhenCheckerFails() throws Exception {
-    handler =
-        new ForwardedIndexProjectHandler(
-            indexerMock, (projectName) -> false, indexExecutorMock, configMock);
-
-    assertThat(handler.attemptIndex(nameKey, Optional.empty())).isFalse();
+    verify(indexerMock).index(Project.nameKey(nameKey));
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandlerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandlerTest.java
index a3b82d0..9893ce7 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandlerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/ForwardedProjectListUpdateHandlerTest.java
@@ -15,11 +15,11 @@
 package com.googlesource.gerrit.plugins.multisite.forwarder;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.verify;
 
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.server.project.ProjectCache;
 import com.googlesource.gerrit.plugins.multisite.forwarder.events.ProjectListUpdateEvent;
 import org.junit.Before;
@@ -36,7 +36,7 @@
 
   private static final String PROJECT_NAME = "someProject";
   private static final String SOME_MESSAGE = "someMessage";
-  private static final Project.NameKey PROJECT_KEY = new Project.NameKey(PROJECT_NAME);
+  private static final Project.NameKey PROJECT_KEY = Project.nameKey(PROJECT_NAME);
   @Rule public ExpectedException exception = ExpectedException.none();
   @Mock private ProjectCache projectCacheMock;
   private ForwardedProjectListUpdateHandler handler;
@@ -110,12 +110,11 @@
         .onCreateProject(PROJECT_KEY);
 
     assertThat(Context.isForwardedEvent()).isFalse();
-    try {
-      handler.update(new ProjectListUpdateEvent(PROJECT_NAME, false));
-      fail("should have thrown a RuntimeException");
-    } catch (RuntimeException e) {
-      assertThat(e.getMessage()).isEqualTo(SOME_MESSAGE);
-    }
+    RuntimeException thrown =
+        assertThrows(
+            RuntimeException.class,
+            () -> handler.update(new ProjectListUpdateEvent(PROJECT_NAME, false)));
+    assertThat(thrown).hasMessageThat().isEqualTo(SOME_MESSAGE);
     assertThat(Context.isForwardedEvent()).isFalse();
 
     verify(projectCacheMock).onCreateProject(PROJECT_KEY);
@@ -133,12 +132,11 @@
         .remove(PROJECT_KEY);
 
     assertThat(Context.isForwardedEvent()).isFalse();
-    try {
-      handler.update(new ProjectListUpdateEvent(PROJECT_NAME, true));
-      fail("should have thrown a RuntimeException");
-    } catch (RuntimeException e) {
-      assertThat(e.getMessage()).isEqualTo(SOME_MESSAGE);
-    }
+    RuntimeException thrown =
+        assertThrows(
+            RuntimeException.class,
+            () -> handler.update(new ProjectListUpdateEvent(PROJECT_NAME, true)));
+    assertThat(thrown).hasMessageThat().isEqualTo(SOME_MESSAGE);
     assertThat(Context.isForwardedEvent()).isFalse();
 
     verify(projectCacheMock).remove(PROJECT_KEY);
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/GsonParserTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/GsonParserTest.java
index 0a1be19..12bdb74 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/GsonParserTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/forwarder/GsonParserTest.java
@@ -16,46 +16,50 @@
 
 import static com.google.common.truth.Truth.assertThat;
 
-import com.google.gerrit.reviewdb.client.Account;
-import com.google.gerrit.reviewdb.client.AccountGroup;
+import com.google.gerrit.entities.Account;
+import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.server.events.EventGsonProvider;
+import com.google.gson.Gson;
 import com.googlesource.gerrit.plugins.multisite.cache.Constants;
 import org.junit.Test;
 
 public class GsonParserTest {
   private static final Object EMPTY_JSON = "{}";
 
+  private final Gson gson = new EventGsonProvider().get();
+  private final GsonParser gsonParser = new GsonParser(gson);
+
   @Test
   public void accountIDParse() {
-    Account.Id accountId = new Account.Id(1);
-    String json = GsonParser.toJson(Constants.ACCOUNTS, accountId);
-    assertThat(accountId).isEqualTo(GsonParser.fromJson(Constants.ACCOUNTS, json));
+    Account.Id accountId = Account.id(1);
+    String json = gson.toJson(accountId);
+    assertThat(accountId).isEqualTo(gsonParser.fromJson(Constants.ACCOUNTS, json));
   }
 
   @Test
   public void accountGroupIDParse() {
-    AccountGroup.Id accountGroupId = new AccountGroup.Id(1);
-    String json = GsonParser.toJson(Constants.GROUPS, accountGroupId);
-    assertThat(accountGroupId).isEqualTo(GsonParser.fromJson(Constants.GROUPS, json));
+    AccountGroup.Id accountGroupId = AccountGroup.id(1);
+    String json = gson.toJson(accountGroupId);
+    assertThat(accountGroupId).isEqualTo(gsonParser.fromJson(Constants.GROUPS, json));
   }
 
   @Test
   public void accountGroupUUIDParse() {
-    AccountGroup.UUID accountGroupUuid = new AccountGroup.UUID("abc123");
-    String json = GsonParser.toJson(Constants.GROUPS_BYINCLUDE, accountGroupUuid);
-    assertThat(accountGroupUuid).isEqualTo(GsonParser.fromJson(Constants.GROUPS_BYINCLUDE, json));
+    AccountGroup.UUID accountGroupUuid = AccountGroup.uuid("abc123");
+    String json = gson.toJson(accountGroupUuid);
+    assertThat(accountGroupUuid).isEqualTo(gsonParser.fromJson(Constants.GROUPS_BYINCLUDE, json));
   }
 
   @Test
   public void stringParse() {
     String key = "key";
-    String json = GsonParser.toJson(Constants.PROJECTS, key);
-    assertThat(key).isEqualTo(GsonParser.fromJson(Constants.PROJECTS, json));
+    assertThat(key).isEqualTo(gsonParser.fromJson(Constants.PROJECTS, key));
   }
 
   @Test
   public void noKeyParse() {
     Object object = new Object();
-    String json = GsonParser.toJson(Constants.PROJECT_LIST, object);
+    String json = gson.toJson(object);
     assertThat(json).isEqualTo(EMPTY_JSON);
   }
 }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
index 653cffa..6403cce 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/GroupCheckerImplTest.java
@@ -18,8 +18,8 @@
 import static org.mockito.Mockito.doReturn;
 
 import com.google.gerrit.common.Nullable;
-import com.google.gerrit.reviewdb.client.AccountGroup;
-import com.google.gerrit.reviewdb.client.RefNames;
+import com.google.gerrit.entities.AccountGroup;
+import com.google.gerrit.entities.RefNames;
 import com.google.gerrit.server.config.AllUsersName;
 import com.google.gerrit.server.config.AllUsersNameProvider;
 import com.google.gerrit.server.git.GitRepositoryManager;
@@ -57,15 +57,14 @@
 
   @Test
   public void isGroupUpToDate_shouldReturnTrueWhenEventIsEmpty() {
-    assertThat(objectUnderTest.isGroupUpToDate(Optional.empty())).isTrue();
+    assertThat(objectUnderTest.isUpToDate(Optional.empty())).isTrue();
   }
 
   @Test
   public void isGroupUpToDate_shouldReturnFalseWhenSha1DoesNotExistInAllUsers() {
     setCommitExistsInRepo(false);
     assertThat(
-            objectUnderTest.isGroupUpToDate(
-                groupIndexEvent(UUID.randomUUID().toString(), AN_OBJECT_ID)))
+            objectUnderTest.isUpToDate(groupIndexEvent(UUID.randomUUID().toString(), AN_OBJECT_ID)))
         .isFalse();
   }
 
@@ -73,8 +72,7 @@
   public void isGroupUpToDate_shouldReturnFalseWhenSha1ExistsInAllUsers() {
     setCommitExistsInRepo(true);
     assertThat(
-            objectUnderTest.isGroupUpToDate(
-                groupIndexEvent(UUID.randomUUID().toString(), AN_OBJECT_ID)))
+            objectUnderTest.isUpToDate(groupIndexEvent(UUID.randomUUID().toString(), AN_OBJECT_ID)))
         .isTrue();
   }
 
@@ -83,8 +81,7 @@
     UUID groupUUID = UUID.randomUUID();
     setCommitExistsInRepo(true);
 
-    assertThat(objectUnderTest.isGroupUpToDate(groupIndexEvent(groupUUID.toString(), null)))
-        .isTrue();
+    assertThat(objectUnderTest.isUpToDate(groupIndexEvent(groupUUID.toString(), null))).isTrue();
   }
 
   @Test
@@ -119,7 +116,7 @@
 
   private void setupExactRefInGroup(UUID groupUUID, @Nullable ObjectId objectId)
       throws IOException {
-    String groupRefName = RefNames.refsGroups(new AccountGroup.UUID(groupUUID.toString()));
+    String groupRefName = RefNames.refsGroups(AccountGroup.uuid(groupUUID.toString()));
     ObjectIdRef.Unpeeled aRef = new ObjectIdRef.Unpeeled(Ref.Storage.LOOSE, groupRefName, objectId);
     doReturn(objectId == null ? null : aRef).when(refDatabaseMock).exactRef(groupRefName);
   }
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/TestGroupChecker.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/TestGroupChecker.java
index a6c2675..0af7e9e 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/index/TestGroupChecker.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/index/TestGroupChecker.java
@@ -31,7 +31,7 @@
   private static final String someObjectId = "deadbeefdeadbeefdeadbeefdeadbeefdeadbeef";
 
   @Override
-  public boolean isGroupUpToDate(Optional<GroupIndexEvent> groupIndexEvent) {
+  public boolean isUpToDate(Optional<GroupIndexEvent> groupIndexEvent) {
     return isUpToDate;
   }
 
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/BatchRefUpdateValidatorTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/BatchRefUpdateValidatorTest.java
index 17e71ce..b79740d 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/BatchRefUpdateValidatorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/BatchRefUpdateValidatorTest.java
@@ -22,8 +22,8 @@
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
 
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.metrics.DisabledMetricMaker;
-import com.google.gerrit.reviewdb.client.Project;
 import com.googlesource.gerrit.plugins.multisite.SharedRefDatabaseWrapper;
 import com.googlesource.gerrit.plugins.multisite.validation.RefUpdateValidator.OneParameterVoidFunction;
 import com.googlesource.gerrit.plugins.multisite.validation.dfsrefdb.DefaultSharedRefEnforcement;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/Log4jSharedRefLoggerTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/Log4jSharedRefLoggerTest.java
index c6f0fc1..3debdf4 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/Log4jSharedRefLoggerTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/Log4jSharedRefLoggerTest.java
@@ -18,8 +18,8 @@
 
 import com.google.gerrit.acceptance.AbstractDaemonTest;
 import com.google.gerrit.acceptance.PushOneCommit;
+import com.google.gerrit.entities.RefNames;
 import com.google.gerrit.json.OutputFormat;
-import com.google.gerrit.reviewdb.client.RefNames;
 import com.google.gerrit.server.config.SitePaths;
 import com.google.gerrit.server.notedb.Sequences;
 import com.google.gerrit.server.util.SystemLog;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteBatchRefUpdateTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteBatchRefUpdateTest.java
index 622cf9d..e9651fb 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteBatchRefUpdateTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteBatchRefUpdateTest.java
@@ -94,6 +94,7 @@
     return "branch_" + nameRule.getMethodName();
   }
 
+  @SuppressWarnings("deprecation")
   private void setMockRequiredReturnValues() throws IOException {
 
     doReturn(batchRefUpdate).when(refDatabase).newBatchUpdate();
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteRefUpdateTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteRefUpdateTest.java
index 16cda4e..9e75c8f 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteRefUpdateTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/MultiSiteRefUpdateTest.java
@@ -15,7 +15,7 @@
 package com.googlesource.gerrit.plugins.multisite.validation;
 
 import static com.google.common.truth.Truth.assertThat;
-import static org.junit.Assert.fail;
+import static com.google.gerrit.testing.GerritJUnit.assertThrows;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
 import static org.mockito.Mockito.verify;
@@ -101,12 +101,8 @@
     MultiSiteRefUpdate multiSiteRefUpdate =
         getMultiSiteRefUpdateWithDefaultPolicyEnforcement(refUpdate);
 
-    try {
-      multiSiteRefUpdate.update();
-      fail("Expecting an IOException to be thrown");
-    } catch (IOException e) {
-      verify(validationMetrics).incrementSplitBrainPrevention();
-    }
+    assertThrows(IOException.class, () -> multiSiteRefUpdate.update());
+    verify(validationMetrics).incrementSplitBrainPrevention();
   }
 
   @Test
@@ -123,12 +119,8 @@
     MultiSiteRefUpdate multiSiteRefUpdate =
         getMultiSiteRefUpdateWithDefaultPolicyEnforcement(refUpdate);
 
-    try {
-      multiSiteRefUpdate.update();
-      fail("Expecting an IOException to be thrown");
-    } catch (IOException e) {
-      verify(validationMetrics, never()).incrementSplitBrainPrevention();
-    }
+    assertThrows(IOException.class, () -> multiSiteRefUpdate.update());
+    verify(validationMetrics, never()).incrementSplitBrainPrevention();
   }
 
   @Test
@@ -145,12 +137,8 @@
     MultiSiteRefUpdate multiSiteRefUpdate =
         getMultiSiteRefUpdateWithDefaultPolicyEnforcement(refUpdate);
 
-    try {
-      multiSiteRefUpdate.update();
-      fail("Expecting an IOException to be thrown");
-    } catch (IOException e) {
-      verify(validationMetrics).incrementSplitBrain();
-    }
+    assertThrows(IOException.class, () -> multiSiteRefUpdate.update());
+    verify(validationMetrics).incrementSplitBrain();
   }
 
   @Test
@@ -180,12 +168,8 @@
     MultiSiteRefUpdate multiSiteRefUpdate =
         getMultiSiteRefUpdateWithDefaultPolicyEnforcement(refUpdate);
 
-    try {
-      multiSiteRefUpdate.delete();
-      fail("Expecting an IOException to be thrown");
-    } catch (IOException e) {
-      verify(validationMetrics).incrementSplitBrainPrevention();
-    }
+    assertThrows(IOException.class, () -> multiSiteRefUpdate.delete());
+    verify(validationMetrics).incrementSplitBrainPrevention();
   }
 
   private MultiSiteRefUpdate getMultiSiteRefUpdateWithDefaultPolicyEnforcement(
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateTest.java
index 7771406..a1303ff 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/ProjectVersionRefUpdateTest.java
@@ -24,8 +24,8 @@
 import static org.mockito.Mockito.verifyZeroInteractions;
 import static org.mockito.Mockito.when;
 
-import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.client.RefNames;
+import com.google.gerrit.entities.Project;
+import com.google.gerrit.entities.RefNames;
 import com.google.gerrit.server.events.RefUpdatedEvent;
 import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
 import com.google.gerrit.server.project.ProjectConfig;
@@ -239,8 +239,7 @@
   @Test
   public void shouldNotUpdateProjectVersionWhenProjectDoesntExist() throws IOException {
     Context.setForwardedEvent(false);
-    when(refUpdatedEvent.getProjectNameKey())
-        .thenReturn(new Project.NameKey("aNonExistentProject"));
+    when(refUpdatedEvent.getProjectNameKey()).thenReturn(Project.nameKey("aNonExistentProject"));
     when(refUpdatedEvent.getRefName()).thenReturn(A_TEST_REF_NAME);
 
     new ProjectVersionRefUpdateImpl(repoManager, sharedRefDb, gitReferenceUpdated, verLogger)
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/RefUpdateValidatorTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/RefUpdateValidatorTest.java
index 09e60d3..323db63 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/RefUpdateValidatorTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/RefUpdateValidatorTest.java
@@ -24,7 +24,7 @@
 import static org.mockito.Mockito.when;
 
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbSystemError;
-import com.google.gerrit.reviewdb.client.Project;
+import com.google.gerrit.entities.Project;
 import com.googlesource.gerrit.plugins.multisite.SharedRefDatabaseWrapper;
 import com.googlesource.gerrit.plugins.multisite.validation.RefUpdateValidator.OneParameterFunction;
 import com.googlesource.gerrit.plugins.multisite.validation.dfsrefdb.DefaultSharedRefEnforcement;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/MultisiteReplicationPushFilterTest.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/MultisiteReplicationPushFilterTest.java
index fb8eb40..7e4593b 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/MultisiteReplicationPushFilterTest.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/MultisiteReplicationPushFilterTest.java
@@ -24,8 +24,8 @@
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDatabase;
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbLockException;
 import com.gerritforge.gerrit.globalrefdb.GlobalRefDbSystemError;
+import com.google.gerrit.entities.Project;
 import com.google.gerrit.extensions.registration.DynamicItem;
-import com.google.gerrit.reviewdb.client.Project;
 import com.google.gerrit.testing.InMemoryRepositoryManager;
 import com.google.gerrit.testing.InMemoryTestEnvironment;
 import com.google.inject.Inject;
diff --git a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/RefFixture.java b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/RefFixture.java
index 8ddbf5c..baba94b 100644
--- a/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/RefFixture.java
+++ b/src/test/java/com/googlesource/gerrit/plugins/multisite/validation/dfsrefdb/RefFixture.java
@@ -14,8 +14,8 @@
 
 package com.googlesource.gerrit.plugins.multisite.validation.dfsrefdb;
 
-import com.google.gerrit.reviewdb.client.Project;
-import com.google.gerrit.reviewdb.client.RefNames;
+import com.google.gerrit.entities.Project;
+import com.google.gerrit.entities.RefNames;
 import org.eclipse.jgit.lib.ObjectId;
 import org.eclipse.jgit.lib.ObjectIdRef;
 import org.eclipse.jgit.lib.Ref;
@@ -29,7 +29,7 @@
   static final String ALLOWED_NAME_CHARS =
       ALLOWED_CHARS + ALLOWED_CHARS.toUpperCase() + ALLOWED_DIGITS;
   static final String A_TEST_PROJECT_NAME = "A_TEST_PROJECT_NAME";
-  static final Project.NameKey A_TEST_PROJECT_NAME_KEY = new Project.NameKey(A_TEST_PROJECT_NAME);
+  static final Project.NameKey A_TEST_PROJECT_NAME_KEY = Project.nameKey(A_TEST_PROJECT_NAME);
   static final ObjectId AN_OBJECT_ID_1 = new ObjectId(1, 2, 3, 4, 5);
   static final ObjectId AN_OBJECT_ID_2 = new ObjectId(1, 2, 3, 4, 6);
   static final ObjectId AN_OBJECT_ID_3 = new ObjectId(1, 2, 3, 4, 7);
diff --git a/src/test/scala/com/googlesource/gerrit/plugins/multisite/scenarios/CreateChangeUsingMultiGerrit.scala b/src/test/scala/com/googlesource/gerrit/plugins/multisite/scenarios/CreateChangeUsingMultiGerrit.scala
index eade1cf..fdacd81 100644
--- a/src/test/scala/com/googlesource/gerrit/plugins/multisite/scenarios/CreateChangeUsingMultiGerrit.scala
+++ b/src/test/scala/com/googlesource/gerrit/plugins/multisite/scenarios/CreateChangeUsingMultiGerrit.scala
@@ -25,7 +25,6 @@
 class CreateChangeUsingMultiGerrit extends GerritSimulation {
   private val data: FeederBuilder = jsonFile(resource).convert(keys).queue
   private val projectName = className
-  private val numberKey = "_number"
 
   override def relativeRuntimeWeight = 10
 
@@ -33,7 +32,7 @@
     .feed(data)
     .exec(httpRequest
       .body(ElFileBody(body)).asJson
-      .check(regex("\"" + numberKey + "\":(\\d+),").saveAs(numberKey)))
+      .check(regex("\"_" + numberKey + "\":(\\d+),").saveAs(numberKey)))
     .exec(session => {
       deleteChange.number = Some(session(numberKey).as[Int])
       session
diff --git a/src/test/scala/com/googlesource/gerrit/plugins/multisite/scenarios/DeleteChangeUsingMultiGerrit1.scala b/src/test/scala/com/googlesource/gerrit/plugins/multisite/scenarios/DeleteChangeUsingMultiGerrit1.scala
index 457de0d..b509a19 100644
--- a/src/test/scala/com/googlesource/gerrit/plugins/multisite/scenarios/DeleteChangeUsingMultiGerrit1.scala
+++ b/src/test/scala/com/googlesource/gerrit/plugins/multisite/scenarios/DeleteChangeUsingMultiGerrit1.scala
@@ -40,12 +40,12 @@
     .feed(data)
     .exec(session => {
       if (number.nonEmpty) {
-        session.set("number", number.get)
+        session.set(numberKey, number.get)
       } else {
         session
       }
     })
-    .exec(http(uniqueName).delete("${url}${number}"))
+    .exec(http(uniqueName).delete("${url}${"+ numberKey +"}"))
 
   setUp(
     test.inject(