2 * Copyright (c) 2015 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.datastore.compat;
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;
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
24 public final class PreLithiumTransactionReadyReplyMapper extends TransactionReadyReplyMapper {
25 private final String transactionPath;
27 private PreLithiumTransactionReadyReplyMapper(ActorContext actorContext, TransactionIdentifier identifier, final String transactionPath) {
28 super(actorContext, identifier);
29 this.transactionPath = Preconditions.checkNotNull(transactionPath);
33 protected String extractCohortPathFrom(final ReadyTransactionReply readyTxReply) {
34 return getActorContext().resolvePath(transactionPath, readyTxReply.getCohortPath());
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());