Migrate nullness annotations
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / exceptions / NoShardLeaderException.java
1 /*
2  * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore.exceptions;
9
10 import com.google.common.base.Strings;
11 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
12
13 /**
14  * Exception indicating a shard has no current leader.
15  *
16  * @author Thomas Pantelis
17  */
18 public class NoShardLeaderException extends RuntimeException {
19     private static final long serialVersionUID = 1L;
20
21     public NoShardLeaderException(final String message) {
22         super(message);
23     }
24
25     public NoShardLeaderException(final String message, final String shardName) {
26         super(String.format("%sShard %s currently has no leader. Try again later.",
27                 Strings.isNullOrEmpty(message) ? "" : message + ". ", shardName));
28     }
29
30     public NoShardLeaderException(final ShardIdentifier shardId) {
31         this("Shard " + shardId + " currently has no leader. Try again later.");
32     }
33 }