2 * Copyright (c) 2015 Brocade Communications 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.datastore.entityownership;
10 import akka.actor.Props;
12 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
13 import org.opendaylight.controller.cluster.datastore.Shard;
14 import org.opendaylight.controller.cluster.datastore.identifiers.ShardIdentifier;
15 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 * Special Shard for EntityOwnership.
20 * @author Thomas Pantelis
22 public class EntityOwnershipShard extends Shard {
24 private static DatastoreContext noPersistenceDatastoreContext(DatastoreContext datastoreContext) {
25 return DatastoreContext.newBuilderFrom(datastoreContext).persistent(false).build();
28 protected EntityOwnershipShard(ShardIdentifier name, Map<String, String> peerAddresses,
29 DatastoreContext datastoreContext, SchemaContext schemaContext) {
30 super(name, peerAddresses, noPersistenceDatastoreContext(datastoreContext), schemaContext);
34 protected void onDatastoreContext(DatastoreContext context) {
35 super.onDatastoreContext(noPersistenceDatastoreContext(context));
38 public static Props props(final ShardIdentifier name, final Map<String, String> peerAddresses,
39 final DatastoreContext datastoreContext, final SchemaContext schemaContext) {
40 return Props.create(new Creator(name, peerAddresses, datastoreContext, schemaContext));
43 private static class Creator extends AbstractShardCreator {
44 private static final long serialVersionUID = 1L;
46 Creator(final ShardIdentifier name, final Map<String, String> peerAddresses,
47 final DatastoreContext datastoreContext, final SchemaContext schemaContext) {
48 super(name, peerAddresses, datastoreContext, schemaContext);
52 public Shard create() throws Exception {
53 return new EntityOwnershipShard(name, peerAddresses, datastoreContext, schemaContext);