6a4a26b3a5c3ad02f0e515c9e6cb9699c0143915
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / TransactionRequest.java
1 /*
2  * Copyright (c) 2016 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 package org.opendaylight.controller.cluster.access.commands;
9
10 import akka.actor.ActorRef;
11 import com.google.common.annotations.Beta;
12 import org.opendaylight.controller.cluster.access.ABIVersion;
13 import org.opendaylight.controller.cluster.access.concepts.Request;
14 import org.opendaylight.controller.cluster.access.concepts.RequestException;
15 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
16
17 /**
18  * Abstract base class for {@link Request}s involving specific transaction. This class is visible outside of this
19  * package solely for the ability to perform a unified instanceof check.
20  *
21  * @author Robert Varga
22  *
23  * @param <T> Message type
24  */
25 @Beta
26 public abstract class TransactionRequest<T extends TransactionRequest<T>> extends Request<TransactionIdentifier, T> {
27     private static final long serialVersionUID = 1L;
28
29     TransactionRequest(final TransactionIdentifier identifier, final long sequence, final long retry,
30         final ActorRef replyTo) {
31         super(identifier, sequence, retry, replyTo);
32     }
33
34     TransactionRequest(final T request, final ABIVersion version) {
35         super(request, version);
36     }
37
38     TransactionRequest(final T request, final long retry) {
39         super(request, retry);
40     }
41
42     @Override
43     public final TransactionFailure toRequestFailure(final RequestException cause) {
44         return new TransactionFailure(getTarget(), getSequence(), getRetry(), cause);
45     }
46
47     @Override
48     protected abstract AbstractTransactionRequestProxy<T> externalizableProxy(final ABIVersion version);
49 }