Bump versions to 4.0.0-SNAPSHOT
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / sharding / ShardProxyProducer.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.sharding;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.collect.ImmutableList;
13 import java.util.Collection;
14 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientLocalHistory;
15 import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient;
16 import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
17 import org.opendaylight.mdsal.dom.spi.shard.DOMDataTreeShardProducer;
18 import org.opendaylight.mdsal.dom.spi.shard.DOMDataTreeShardWriteTransaction;
19
20 /**
21  * Proxy producer implementation that creates transactions that forward all calls to {@link DataStoreClient}.
22  */
23 @Deprecated(forRemoval = true)
24 class ShardProxyProducer implements DOMDataTreeShardProducer {
25     private final DOMDataTreeIdentifier shardRoot;
26     private final Collection<DOMDataTreeIdentifier> prefixes;
27     private final ClientLocalHistory history;
28     private DistributedShardModificationFactory modificationFactory;
29
30     ShardProxyProducer(final DOMDataTreeIdentifier shardRoot,
31                        final Collection<DOMDataTreeIdentifier> prefixes,
32                        final DataStoreClient client,
33                        final DistributedShardModificationFactory modificationFactory) {
34         this.shardRoot = requireNonNull(shardRoot);
35         this.prefixes = ImmutableList.copyOf(prefixes);
36         this.modificationFactory = requireNonNull(modificationFactory);
37         history = requireNonNull(client).createLocalHistory();
38     }
39
40     @Override
41     public Collection<DOMDataTreeIdentifier> getPrefixes() {
42         return prefixes;
43     }
44
45     @Override
46     public DOMDataTreeShardWriteTransaction createTransaction() {
47         return new ShardProxyTransaction(shardRoot, prefixes,
48                 modificationFactory.createModification(history.createTransaction()));
49     }
50
51     DistributedShardModificationFactory getModificationFactory() {
52         return modificationFactory;
53     }
54
55     void setModificationFactory(final DistributedShardModificationFactory modificationFactory) {
56         this.modificationFactory = requireNonNull(modificationFactory);
57     }
58
59     @Override
60     public void close() {
61         // FIXME: implement this
62     }
63 }

©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.