Merge branch 'stable-2.15'

* stable-2.15:
  RestForwarder: Tidy up debug logging
  JGroupsPeerInfoProvider: Adjust javadoc and log output
  Compile against 2.15-rc1
  JGroupsPeerInfoProvider: Fix broken log formatting
  Improve the debug log when RestForwarder fails

Change-Id: Id16c39f2000b885c139606f046c658bbf4da6ee8
diff --git a/WORKSPACE b/WORKSPACE
index e820776..ce8fcd5 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -3,27 +3,27 @@
 load("//:bazlets.bzl", "load_bazlets")
 
 load_bazlets(
-    commit = "42bffc66c0e92753133e4cea2debe65abc359c4d",
+    commit = "cbddbc2b9571b1d692fb823ba8791ccd60b52421",
     #local_path = "/home/ehugare/workspaces/bazlets",
 )
 
 #Snapshot Plugin API
-load(
-    "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
-    "gerrit_api_maven_local",
-)
-
-# Load snapshot Plugin API
-gerrit_api_maven_local()
-
-# Release Plugin API
 #load(
-#   "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
-#   "gerrit_api",
+#    "@com_googlesource_gerrit_bazlets//:gerrit_api_maven_local.bzl",
+#    "gerrit_api_maven_local",
 #)
 
+# Load snapshot Plugin API
+#gerrit_api_maven_local()
+
+# Release Plugin API
+load(
+   "@com_googlesource_gerrit_bazlets//:gerrit_api.bzl",
+   "gerrit_api",
+)
+
 # Load release Plugin API
-#gerrit_api()
+gerrit_api()
 
 load("//:external_plugin_deps.bzl", "external_plugin_deps")
 
diff --git a/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarder.java b/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarder.java
index c38e849..c1c46d9 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarder.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/highavailability/forwarder/rest/RestForwarder.java
@@ -131,20 +131,22 @@
           log.debug("{} OK", name);
           return true;
         } catch (ForwardingException e) {
+          int maxTries = cfg.http().maxTries();
+          log.debug("Failed to {} [{}/{}]", name, execCnt, maxTries, e);
           if (!e.isRecoverable()) {
-            log.error("Failed to {}", name, e);
+            log.error("{} failed with unrecoverable error; giving up", name);
             return false;
           }
-          if (execCnt >= cfg.http().maxTries()) {
-            log.error("Failed to {}, after {} tries", name, cfg.http().maxTries());
+          if (execCnt >= maxTries) {
+            log.error("Failed to {} after {} tries; giving up", name, maxTries);
             return false;
           }
 
-          log.debug("Retrying to {} caused by '{}'", name, e);
+          log.debug("Retrying to {}", name);
           try {
             Thread.sleep(cfg.http().retryInterval());
           } catch (InterruptedException ie) {
-            log.error("{} was interrupted, giving up", name, ie);
+            log.error("{} was interrupted; giving up", name, ie);
             Thread.currentThread().interrupt();
             return false;
           }
diff --git a/src/main/java/com/ericsson/gerrit/plugins/highavailability/peers/jgroups/JGroupsPeerInfoProvider.java b/src/main/java/com/ericsson/gerrit/plugins/highavailability/peers/jgroups/JGroupsPeerInfoProvider.java
index 610d781..cc573fc 100644
--- a/src/main/java/com/ericsson/gerrit/plugins/highavailability/peers/jgroups/JGroupsPeerInfoProvider.java
+++ b/src/main/java/com/ericsson/gerrit/plugins/highavailability/peers/jgroups/JGroupsPeerInfoProvider.java
@@ -32,13 +32,13 @@
 
 /**
  * Provider which uses JGroups to find the peer gerrit instances. On startup every gerrit instance
- * joins a jgroups channel. Whenever the set of channel members changes each gerrit server publishes
- * its url to all channel members.
+ * creates its own channel and joins jgroup cluster. Whenever the set of cluster members changes
+ * each gerrit server publishes its url to all cluster members (publishes it to all channels).
  *
- * <p>This provider maintains a list of all members which joined the jgroups channel. This may be
+ * <p>This provider maintains a list of all members which joined the jgroups cluster. This may be
  * more than two. But will always pick the first node which sent its url as the peer to be returned
  * by {@link #get()}. It will continue to return that node until that node leaves the jgroups
- * channel.
+ * cluster.
  */
 @Singleton
 public class JGroupsPeerInfoProvider extends ReceiverAdapter
@@ -81,8 +81,10 @@
     synchronized (this) {
       if (view.getMembers().size() > 2) {
         log.warn(
-            "{} members joined the jgroups channel {}. Only two members are supported. Members: {}",
+            "{} members joined the jgroups cluster {} ({}). "
+                + " Only two members are supported. Members: {}",
             view.getMembers().size(),
+            jgroupsConfig.clusterName(),
             channel.getName(),
             view.getMembers());
       }
@@ -98,7 +100,10 @@
       } catch (Exception e) {
         // channel communication caused an error. Can't do much about it.
         log.error(
-            "Sending a message over jgroups channel {} failed", jgroupsConfig.clusterName(), e);
+            "Sending a message over channel {} to cluster {} failed",
+            channel.getName(),
+            jgroupsConfig.clusterName(),
+            e);
       }
     }
   }
@@ -113,9 +118,16 @@
       channel.setReceiver(this);
       channel.setDiscardOwnMessages(true);
       channel.connect(jgroupsConfig.clusterName());
-      log.info("Succesfully joined jgroups channel {}", channel);
+      log.info(
+          "Channel {} successfully joined jgroups cluster {}",
+          channel.getName(),
+          jgroupsConfig.clusterName());
     } catch (Exception e) {
-      log.error("joining jgroups channel {} failed", e);
+      log.error(
+          "joining cluster {} for channel {} failed",
+          jgroupsConfig.clusterName(),
+          channel.getName(),
+          e);
     }
   }
 
@@ -131,7 +143,8 @@
 
   @Override
   public void stop() {
-    log.info("closing jgroups channel {}", jgroupsConfig.clusterName());
+    log.info(
+        "closing jgroups channel {} (cluster {})", channel.getName(), jgroupsConfig.clusterName());
     channel.close();
     peerInfo = Optional.empty();
     peerAddress = null;