2 * Copyright (c) 2014 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.datastore;
10 import akka.actor.ActorSystem;
11 import org.opendaylight.controller.cluster.datastore.config.Configuration;
12 import org.opendaylight.controller.cluster.datastore.config.ConfigurationImpl;
13 import org.opendaylight.controller.cluster.datastore.messages.DatastoreSnapshot;
14 import org.opendaylight.controller.sal.core.api.model.SchemaService;
15 import org.osgi.framework.BundleContext;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class DistributedDataStoreFactory {
20 private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreFactory.class);
22 public static DistributedDataStore createInstance(SchemaService schemaService,
23 DatastoreContext datastoreContext, DatastoreSnapshot restoreFromSnapshot, ActorSystem actorSystem,
24 BundleContext bundleContext) {
26 LOG.info("Create data store instance of type : {}", datastoreContext.getDataStoreName());
28 DatastoreContextIntrospector introspector = new DatastoreContextIntrospector(datastoreContext);
29 DatastoreContextConfigAdminOverlay overlay = new DatastoreContextConfigAdminOverlay(
30 introspector, bundleContext);
32 Configuration config = new ConfigurationImpl("module-shards.conf", "modules.conf");
33 final DistributedDataStore dataStore = new DistributedDataStore(actorSystem,
34 new ClusterWrapperImpl(actorSystem), config, introspector.newContextFactory(), restoreFromSnapshot);
36 overlay.setListener(dataStore);
38 schemaService.registerSchemaContextListener(dataStore);
40 dataStore.setCloseable(overlay);
41 dataStore.waitTillReady();