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 static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
13 import akka.actor.ActorRef;
14 import com.google.common.base.MoreObjects;
15 import com.google.common.base.MoreObjects.ToStringHelper;
16 import org.opendaylight.controller.cluster.access.ABIVersion;
19 * Basic information about how to talk to the backend. ClientActorBehavior uses this information to dispatch requests
23 * This class is not final so concrete actor behavior implementations may subclass it and track more information about
24 * the backend. The {@link #hashCode()} and {@link #equals(Object)} methods are made final to ensure subclasses compare
27 * @author Robert Varga
29 public class BackendInfo {
30 private final ABIVersion version;
31 private final ActorRef actor;
32 private final int maxMessages;
33 private final long sessionId;
34 private final String name;
36 protected BackendInfo(final ActorRef actor, final String name, final long sessionId, final ABIVersion version,
37 final int maxMessages) {
38 this.version = requireNonNull(version);
39 this.actor = requireNonNull(actor);
40 this.name = requireNonNull(name);
41 checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
42 this.maxMessages = maxMessages;
43 this.sessionId = sessionId;
46 public final ActorRef getActor() {
50 public final String getName() {
54 public final ABIVersion getVersion() {
58 public final int getMaxMessages() {
62 public final long getSessionId() {
67 public final int hashCode() {
68 return super.hashCode();
72 public final boolean equals(final Object obj) {
73 return super.equals(obj);
77 public final String toString() {
78 return addToStringAttributes(MoreObjects.toStringHelper(this).omitNullValues()).toString();
81 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
82 return toStringHelper.add("actor", actor).add("sessionId", sessionId).add("version", version)
83 .add("maxMessages", maxMessages);