/* * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.controller.cluster.sharding; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import java.util.Collection; import javax.annotation.Nonnull; import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient; import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier; import org.opendaylight.mdsal.dom.spi.shard.DOMDataTreeShardProducer; import org.opendaylight.mdsal.dom.spi.shard.DOMDataTreeShardWriteTransaction; /** * Proxy producer implementation that creates transactions that forward all calls to {@link DataStoreClient}. */ class ShardProxyProducer implements DOMDataTreeShardProducer { private final DOMDataTreeIdentifier shardRoot; private final Collection prefixes; private final DataStoreClient client; ShardProxyProducer(final DOMDataTreeIdentifier shardRoot, final Collection prefixes, final DataStoreClient client) { this.shardRoot = Preconditions.checkNotNull(shardRoot); this.prefixes = ImmutableList.copyOf(Preconditions.checkNotNull(prefixes)); this.client = Preconditions.checkNotNull(client); } @Nonnull @Override public Collection getPrefixes() { return prefixes; } @Override public DOMDataTreeShardWriteTransaction createTransaction() { return new ShardProxyTransaction(shardRoot, prefixes, client); } }