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.commands;
10 import akka.actor.ActorRef;
11 import com.google.common.annotations.Beta;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.base.Preconditions;
14 import javax.annotation.Nonnull;
15 import org.opendaylight.controller.cluster.access.ABIVersion;
16 import org.opendaylight.controller.cluster.access.concepts.AbstractRequestProxy;
17 import org.opendaylight.controller.cluster.access.concepts.ClientIdentifier;
18 import org.opendaylight.controller.cluster.access.concepts.Request;
19 import org.opendaylight.controller.cluster.access.concepts.RequestException;
22 * Request to connect a frontend instance to the backend. It carries basic information about the frontend:
23 * - its coordinates in {@link #getReplyTo()}.
24 * - its minimum supported ABI version
25 * - its maximum supported ABI version
27 * It also includes request stream sequencing information.
29 * @author Robert Varga
32 public final class ConnectClientRequest extends Request<ClientIdentifier, ConnectClientRequest> {
33 private static final long serialVersionUID = 1L;
35 private final ABIVersion minVersion;
36 private final ABIVersion maxVersion;
38 ConnectClientRequest(final ClientIdentifier identifier, final long txSequence, final ActorRef replyTo,
39 final ABIVersion minVersion, final ABIVersion maxVersion) {
40 super(identifier, txSequence, replyTo);
41 this.minVersion = Preconditions.checkNotNull(minVersion);
42 this.maxVersion = Preconditions.checkNotNull(maxVersion);
45 public ConnectClientRequest(final ClientIdentifier identifier, final ActorRef replyTo, final ABIVersion minVersion,
46 final ABIVersion maxVersion) {
47 this(identifier, 0, replyTo, minVersion, maxVersion);
50 private ConnectClientRequest(final ConnectClientRequest request, final ABIVersion version) {
51 super(request, version);
52 this.minVersion = request.minVersion;
53 this.maxVersion = request.maxVersion;
56 public ABIVersion getMinVersion() {
60 public ABIVersion getMaxVersion() {
65 public final ConnectClientFailure toRequestFailure(final RequestException cause) {
66 return new ConnectClientFailure(getTarget(), getSequence(), cause);
70 protected AbstractRequestProxy<ClientIdentifier, ConnectClientRequest> externalizableProxy(final ABIVersion version) {
71 return new ConnectClientRequestProxyV1(this);
75 protected ConnectClientRequest cloneAsVersion(final ABIVersion version) {
76 return new ConnectClientRequest(this, version);
80 protected @Nonnull ToStringHelper addToStringAttributes(final @Nonnull ToStringHelper toStringHelper) {
81 return super.addToStringAttributes(toStringHelper).add("minVersion", minVersion).add("maxVersion", maxVersion);