Option to setup a copy of the master site during init

Plugin's init step now offers to create a copy of the master site.
This works if the directory of the copy is accessible from
the machine running init and if the two peers share the same
file system at runtime.

The git, db and shared directory are symlinked from the copy to the master.
All other directories are copied:

  $COPY/bin/
  $COPY/cache/
  $COPY/data/
  $COPY/db@ -> $MASTER/db
  $COPY/etc/
  $COPY/git@ -> $MASTER/git
  $COPY/index/
  $COPY/lib/
  $COPY/logs/
  $COPY/plugins/
  $COPY/shared@ -> $MASTER/shared
  $COPY/static/
  $COPY/tmp/

Init is non-intrusive for the existing (master) Gerrit site. It doesn't
move any existing directory to a new location. If HA needs to be teared
down it can be done easily by stopping the high-availability plugin and
deleting the other (copy) instance.

The following configuration is done:

  [main]
    sharedDirectory = shared

  [peerInfo]
    strategy = jgroups

  [peerInfo "jgroups"]
    clusterName = GerritHA

in both master and copy. This way, master and copy are configured
to discover each other using jgroups and to share a common directory
$MASTER/shared.

This change doesn't make any changes in the httpd.listenUrl and
sshd.listenAddress. An admin has to make this decision depending
on if the two instances will run on the same or different machines
and how a load balancer, like HAProxy, will be configured.

By default the secondary instance is created under $SITE/ha/1. Choosing
a directory under $SITE has an advantage that we are sure that it can be
created so that the --batch init option will work. This way, developers
can quickly setup HA Gerrit with just:

  $ cp high-availability.jar $MASTER/plugins
  $ cd $MASTER
  $ java -jar bin/gerrit.war init --batch

In case local H2 database is used, set database.h2.autoServer=true
to enable its usage from two processes.

NOTE: the code which opens the account_patch_reviews H2 database doesn't
respect the database.h2.autoServer=true setting. This may cause internal
server errors when both instances try to open this database. This needs
to be fixed in Gerrit core.

Change-Id: Id8de72bd49f52ec83f445dba3d0b2b648678e1f7
4 files changed
tree: f5d22715dd357d2ca050bfc1df0ee1650cfe4aeb
  1. lib/
  2. src/
  3. .buckconfig
  4. .gitignore
  5. .mailmap
  6. BUCK