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.sal.core.api.model.SchemaService;
14 import org.osgi.framework.BundleContext;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 public class DistributedDataStoreFactory {
19 private static final Logger LOG = LoggerFactory.getLogger(DistributedDataStoreFactory.class);
21 public static DistributedDataStore createInstance(SchemaService schemaService,
22 DatastoreContext datastoreContext, ActorSystem actorSystem, BundleContext bundleContext) {
24 LOG.info("Create data store instance of type : {}", datastoreContext.getDataStoreType());
26 DatastoreContextIntrospector introspector = new DatastoreContextIntrospector(datastoreContext);
27 DatastoreContextConfigAdminOverlay overlay = new DatastoreContextConfigAdminOverlay(
28 introspector, bundleContext);
30 Configuration config = new ConfigurationImpl("module-shards.conf", "modules.conf");
31 final DistributedDataStore dataStore = new DistributedDataStore(actorSystem,
32 new ClusterWrapperImpl(actorSystem), config, introspector.getContext());
34 overlay.setListener(dataStore);
36 schemaService.registerSchemaContextListener(dataStore);
38 dataStore.setCloseable(overlay);
39 dataStore.waitTillReady();