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;
37 private final long resumeSequence;
39 public ConnectClientRequest(final ClientIdentifier identifier, final ActorRef replyTo, final ABIVersion minVersion,
40 final ABIVersion maxVersion) {
41 this(identifier, replyTo, minVersion, maxVersion, 0);
44 public ConnectClientRequest(final ClientIdentifier identifier, final ActorRef replyTo, final ABIVersion minVersion,
45 final ABIVersion maxVersion, final long resumeSequence) {
46 super(identifier, replyTo);
47 this.minVersion = Preconditions.checkNotNull(minVersion);
48 this.maxVersion = Preconditions.checkNotNull(maxVersion);
49 this.resumeSequence = resumeSequence;
52 private ConnectClientRequest(final ConnectClientRequest request, final ABIVersion version) {
53 super(request, version);
54 this.minVersion = request.minVersion;
55 this.maxVersion = request.maxVersion;
56 this.resumeSequence = request.resumeSequence;
59 public ABIVersion getMinVersion() {
63 public ABIVersion getMaxVersion() {
67 public long getResumeSequence() {
68 return resumeSequence;
72 public final ConnectClientFailure toRequestFailure(final RequestException cause) {
73 return new ConnectClientFailure(getTarget(), cause);
77 protected AbstractRequestProxy<ClientIdentifier, ConnectClientRequest> externalizableProxy(final ABIVersion version) {
78 return new ConnectClientRequestProxyV1(this);
82 protected ConnectClientRequest cloneAsVersion(final ABIVersion version) {
83 return new ConnectClientRequest(this, version);
87 protected @Nonnull ToStringHelper addToStringAttributes(final @Nonnull ToStringHelper toStringHelper) {
88 return super.addToStringAttributes(toStringHelper).add("minVersion", minVersion).add("maxVersion", maxVersion)
89 .add("resumeSequence", resumeSequence);