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.controller.cluster.sharding;
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.ImmutableList;
13 import java.util.Collection;
14 import javax.annotation.Nonnull;
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;
21 * Proxy producer implementation that creates transactions that forward all calls to {@link DataStoreClient}.
23 class ShardProxyProducer implements DOMDataTreeShardProducer {
25 private final DOMDataTreeIdentifier shardRoot;
26 private final Collection<DOMDataTreeIdentifier> prefixes;
27 private final DataStoreClient client;
29 ShardProxyProducer(final DOMDataTreeIdentifier shardRoot, final Collection<DOMDataTreeIdentifier> prefixes,
30 final DataStoreClient client) {
31 this.shardRoot = Preconditions.checkNotNull(shardRoot);
32 this.prefixes = ImmutableList.copyOf(Preconditions.checkNotNull(prefixes));
33 this.client = Preconditions.checkNotNull(client);
38 public Collection<DOMDataTreeIdentifier> getPrefixes() {
43 public DOMDataTreeShardWriteTransaction createTransaction() {
44 return new ShardProxyTransaction(shardRoot, prefixes, client);