Merge "Do not use ActorSystem.actorFor as it is deprecated"
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / messages / FindPrimary.java
1 /*
2  * Copyright (c) 2014 Cisco 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
9 package org.opendaylight.controller.cluster.datastore.messages;
10
11 import com.google.common.base.Preconditions;
12
13 /**
14  * The FindPrimary message is used to locate the primary of any given shard
15  *
16  */
17 public class FindPrimary implements SerializableMessage{
18     public static final Class<FindPrimary> SERIALIZABLE_CLASS = FindPrimary.class;
19
20     private final String shardName;
21     private final boolean waitUntilReady;
22
23     public FindPrimary(String shardName, boolean waitUntilReady){
24
25         Preconditions.checkNotNull(shardName, "shardName should not be null");
26
27         this.shardName = shardName;
28         this.waitUntilReady = waitUntilReady;
29     }
30
31     public String getShardName() {
32         return shardName;
33     }
34
35     public boolean isWaitUntilReady() {
36         return waitUntilReady;
37     }
38
39     @Override
40     public Object toSerializable() {
41         return this;
42     }
43
44     public static FindPrimary fromSerializable(Object message){
45         return (FindPrimary) message;
46     }
47
48     @Override
49     public String toString() {
50         StringBuilder builder = new StringBuilder();
51         builder.append("FindPrimary [shardName=").append(shardName).append(", waitUntilReady=").append(waitUntilReady)
52                 .append("]");
53         return builder.toString();
54     }
55 }