BUG 2799: SPI for EventSources
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / datastore / WriteOnlyTransactionContextImpl.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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;
9
10 import akka.actor.ActorSelection;
11 import org.opendaylight.controller.cluster.datastore.identifiers.TransactionIdentifier;
12 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16 import scala.concurrent.Future;
17
18 /**
19  * Context for a write-only transaction.
20  *
21  * @author Thomas Pantelis
22  */
23 public class WriteOnlyTransactionContextImpl extends TransactionContextImpl {
24     private static final Logger LOG = LoggerFactory.getLogger(WriteOnlyTransactionContextImpl.class);
25
26     public WriteOnlyTransactionContextImpl(ActorSelection actor, TransactionIdentifier identifier,
27             String transactionChainId, ActorContext actorContext, SchemaContext schemaContext, boolean isTxActorLocal,
28             short remoteTransactionVersion, OperationCompleter operationCompleter) {
29         super(actor, identifier, transactionChainId, actorContext, schemaContext, isTxActorLocal,
30                 remoteTransactionVersion, operationCompleter);
31     }
32
33     @Override
34     public Future<ActorSelection> readyTransaction() {
35         LOG.debug("Tx {} readyTransaction called with {} previous recorded operations pending",
36                 identifier, recordedOperationFutures.size());
37
38         // Send the remaining batched modifications if any.
39
40         Future<Object> lastModificationsFuture = sendBatchedModifications(true);
41
42         return combineRecordedOperationsFutures(lastModificationsFuture);
43     }
44 }