3 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
5 * This program and the accompanying materials are made available under the
6 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
7 * and is available at http://www.eclipse.org/legal/epl-v10.html
12 package org.opendaylight.controller.datastore.internal;
14 import com.google.common.base.Preconditions;
15 import org.apache.felix.dm.Component;
16 import org.opendaylight.controller.clustering.services.CacheConfigException;
17 import org.opendaylight.controller.clustering.services.CacheExistException;
18 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
19 import org.opendaylight.controller.datastore.ClusteredDataStore;
20 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23 public class ClusteredDataStoreManager implements ClusteredDataStore {
25 private ClusteredDataStoreImpl clusteredDataStore = null;
26 private IClusterGlobalServices clusterGlobalServices = null;
29 public DataCommitTransaction<InstanceIdentifier<? extends Object>, Object> requestCommit(DataModification<InstanceIdentifier<? extends Object>, Object> modification) {
30 Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
31 return clusteredDataStore.requestCommit(modification);
35 public Object readOperationalData(InstanceIdentifier<? extends Object> path) {
36 Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
37 return clusteredDataStore.readOperationalData(path);
41 public Object readConfigurationData(InstanceIdentifier<? extends Object> path) {
42 Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
43 return clusteredDataStore.readConfigurationData(path);
47 public void setClusterGlobalServices(IClusterGlobalServices clusterGlobalServices){
48 this.clusterGlobalServices = clusterGlobalServices;
51 public void unsetClusterGlobalServices(IClusterGlobalServices clusterGlobalServices){
52 this.clusterGlobalServices = null;
53 this.clusteredDataStore = null;
58 * Function called by the dependency manager when all the required
59 * dependencies are satisfied
62 void init(Component c) {
64 clusteredDataStore = new ClusteredDataStoreImpl(clusterGlobalServices);
65 } catch (CacheExistException e) {
66 throw new IllegalStateException("could not construct clusteredDataStore");
67 } catch (CacheConfigException e) {
68 throw new IllegalStateException("could not construct clusteredDataStore");