CDS: Implement front-end support for local transactions
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / compat / PreLithiumTransactionReadyReplyMapper.java
1 /*
2  * Copyright (c) 2015 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.datastore.compat;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.controller.cluster.datastore.TransactionReadyReplyMapper;
12 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
13 import org.opendaylight.controller.cluster.datastore.messages.ReadyTransactionReply;
14 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
15 import scala.concurrent.Future;
16 import akka.actor.ActorSelection;
17
18 /**
19  * A {@link Mapper} extracting the {@link ActorSelection} pointing to the actor which
20  * is backing a particular transaction. This class supports the Helium base release
21  * behavior.
22  */
23 @Deprecated
24 public final class PreLithiumTransactionReadyReplyMapper extends TransactionReadyReplyMapper {
25     private final String transactionPath;
26
27     private PreLithiumTransactionReadyReplyMapper(ActorContext actorContext, TransactionIdentifier identifier, final String transactionPath) {
28         super(actorContext, identifier);
29         this.transactionPath = Preconditions.checkNotNull(transactionPath);
30     }
31
32     @Override
33     protected String extractCohortPathFrom(final ReadyTransactionReply readyTxReply) {
34         return getActorContext().resolvePath(transactionPath, readyTxReply.getCohortPath());
35     }
36
37     public static Future<ActorSelection> transform(final Future<Object> readyReplyFuture, final ActorContext actorContext,
38         final TransactionIdentifier identifier, final String transactionPath) {
39         return readyReplyFuture.transform(new PreLithiumTransactionReadyReplyMapper(actorContext, identifier, transactionPath),
40             SAME_FAILURE_TRANSFORMER, actorContext.getClientDispatcher());
41     }
42 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.