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
8 package org.opendaylight.controller.cluster.databroker.actors.dds;
10 import java.util.function.Function;
11 import org.opendaylight.controller.cluster.access.client.ClientActorContext;
12 import org.opendaylight.controller.cluster.datastore.utils.ActorUtils;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 * {@link AbstractDataStoreClientBehavior} which performs module-based sharding.
18 * @author Robert Varga
20 final class DistributedDataStoreClientBehavior extends AbstractDataStoreClientBehavior {
21 private final Function<YangInstanceIdentifier, Long> pathToShard;
23 private DistributedDataStoreClientBehavior(final ClientActorContext context,
24 final ModuleShardBackendResolver resolver) {
25 super(context, resolver);
26 pathToShard = resolver::resolveShardForPath;
29 DistributedDataStoreClientBehavior(final ClientActorContext context, final ActorUtils actorUtils) {
30 this(context, new ModuleShardBackendResolver(context.getIdentifier(), actorUtils));
34 Long resolveShardForPath(final YangInstanceIdentifier path) {
35 return pathToShard.apply(path);