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
9 package org.opendaylight.mdsal.dom.store.inmemory;
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.ImmutableSet;
13 import java.util.Collection;
14 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
16 final class InMemoryDOMDataTreeShardProducer implements DOMDataTreeShardProducer {
18 private final InMemoryDOMDataTreeShard parentShard;
19 private final Collection<DOMDataTreeIdentifier> prefixes;
21 private InmemoryDOMDataTreeShardWriteTransaction currentTx;
22 private InmemoryDOMDataTreeShardWriteTransaction lastSubmittedTx;
24 InMemoryDOMDataTreeShardProducer(final InMemoryDOMDataTreeShard parentShard,
25 final Collection<DOMDataTreeIdentifier> prefixes) {
26 this.parentShard = Preconditions.checkNotNull(parentShard);
27 this.prefixes = ImmutableSet.copyOf(prefixes);
31 public InmemoryDOMDataTreeShardWriteTransaction createTransaction() {
32 // Preconditions.checkState(currentTx == null || currentTx.isFinished(), "Previous transaction not finished yet.");
33 if (lastSubmittedTx != null) {
34 currentTx = parentShard.createTransaction(lastSubmittedTx);
36 currentTx = parentShard.createTransaction(prefixes);
42 public Collection<DOMDataTreeIdentifier> getPrefixes() {