Migrate nullness annotations
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / exceptions / NoShardLeaderException.java
index b205b0fe7853c176be3f92ef2a2f3d3fd952dbab..205de939559caaa684a2c21a7034489f5e40746d 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.controller.cluster.datastore.exceptions;
 
+import com.google.common.base.Strings;
+import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
+
 /**
  * Exception indicating a shard has no current leader.
  *
@@ -15,7 +18,16 @@ package org.opendaylight.controller.cluster.datastore.exceptions;
 public class NoShardLeaderException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
-    public NoShardLeaderException(String message){
+    public NoShardLeaderException(final String message) {
         super(message);
     }
+
+    public NoShardLeaderException(final String message, final String shardName) {
+        super(String.format("%sShard %s currently has no leader. Try again later.",
+                Strings.isNullOrEmpty(message) ? "" : message + ". ", shardName));
+    }
+
+    public NoShardLeaderException(final ShardIdentifier shardId) {
+        this("Shard " + shardId + " currently has no leader. Try again later.");
+    }
 }