2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.cluster.access.client;
10 import akka.actor.ActorRef;
11 import com.google.common.base.MoreObjects;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.base.Preconditions;
14 import org.opendaylight.controller.cluster.access.ABIVersion;
17 * Basic information about how to talk to the backend. ClientActorBehavior uses this information to dispatch requests
21 * This class is not final so concrete actor behavior implementations may subclass it and track more information about
22 * the backend. The {@link #hashCode()} and {@link #equals(Object)} methods are made final to ensure subclasses compare
25 * @author Robert Varga
27 public class BackendInfo {
28 private final ABIVersion version;
29 private final ActorRef actor;
30 private final int maxMessages;
31 private final long sessionId;
32 private final String name;
34 protected BackendInfo(final ActorRef actor, final String name, final long sessionId, final ABIVersion version,
35 final int maxMessages) {
36 this.version = Preconditions.checkNotNull(version);
37 this.actor = Preconditions.checkNotNull(actor);
38 this.name = Preconditions.checkNotNull(name);
39 Preconditions.checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
40 this.maxMessages = maxMessages;
41 this.sessionId = sessionId;
44 public final ActorRef getActor() {
48 public final String getName() {
52 public final ABIVersion getVersion() {
56 public final int getMaxMessages() {
60 public final long getSessionId() {
65 public final int hashCode() {
66 return super.hashCode();
70 public final boolean equals(final Object obj) {
71 return super.equals(obj);
75 public final String toString() {
76 return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
79 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
80 return toStringHelper.add("actor", actor).add("sessionId", sessionId).add("version", version)
81 .add("maxMessages", maxMessages);