X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fdom%2Fbroker%2Fimpl%2FHashMapDataStore.xtend;h=12835ccf0a235ec2a312e32313818525425c6f36;hp=7d57819cbf0ac3a1775c4eedc026719740a8fce7;hb=26da3c2a206a753356b507b018052cbb9cccca7d;hpb=05d3c60109c1d0fc24f0f1ffa3e5aeed929e3c24 diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.xtend index 7d57819cbf..12835ccf0a 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.xtend +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/HashMapDataStore.xtend @@ -1,7 +1,12 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.dom.broker.impl -import org.opendaylight.controller.md.sal.common.api.data.DataReader -import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler import org.opendaylight.controller.md.sal.common.api.data.DataModification import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction import org.opendaylight.yangtools.yang.common.RpcResult @@ -11,23 +16,44 @@ import org.opendaylight.controller.sal.common.util.Rpcs import java.util.Collections import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier import org.opendaylight.yangtools.yang.data.api.CompositeNode -import static extension org.opendaylight.controller.sal.dom.broker.impl.DataUtils.*; +import org.opendaylight.controller.sal.core.api.data.DataStore +import java.util.HashSet +import org.slf4j.LoggerFactory +import org.slf4j.Logger -class HashMapDataStore // -implements // -DataReader, DataCommitHandler { +final class HashMapDataStore implements DataStore, AutoCloseable { + private val Logger LOG = LoggerFactory.getLogger(HashMapDataStore) val Map configuration = new ConcurrentHashMap(); val Map operational = new ConcurrentHashMap(); + + + + override containsConfigurationPath(InstanceIdentifier path) { + return configuration.containsKey(path) + } + + override containsOperationalPath(InstanceIdentifier path) { + return operational.containsKey(path) + } + + override getStoredConfigurationPaths() { + configuration.keySet + } + + override getStoredOperationalPaths() { + operational.keySet + } override readConfigurationData(InstanceIdentifier path) { - configuration.read(path); + LOG.trace("Reading configuration path {}", path) + configuration.get(path); } override readOperationalData(InstanceIdentifier path) { - operational.read(path); + LOG.trace("Reading operational path {}", path) + operational.get(path); } - @@ -41,18 +67,47 @@ DataReader, DataCommitHandler finish(HashMapDataStoreTransaction transaction) { val modification = transaction.modification; - configuration.putAll(modification.updatedConfigurationData); - operational.putAll(modification.updatedOperationalData); - for (removal : modification.removedConfigurationData) { - configuration.remove(removal); + LOG.trace("Removing configuration path {}", removal) + remove(configuration,removal); } for (removal : modification.removedOperationalData) { - operational.remove(removal); + LOG.trace("Removing operational path {}", removal) + remove(operational,removal); + } + if (LOG.isTraceEnabled()) { + for (a : modification.updatedConfigurationData.keySet) { + LOG.trace("Adding configuration path {}", a) + } + for (a : modification.updatedOperationalData.keySet) { + LOG.trace("Adding operational path {}", a) + } } + configuration.putAll(modification.updatedConfigurationData); + operational.putAll(modification.updatedOperationalData); + return Rpcs.getRpcResult(true, null, Collections.emptySet); } + + def remove(Map map, InstanceIdentifier identifier) { + val affected = new HashSet(); + for(path : map.keySet) { + if(identifier.contains(path)) { + affected.add(path); + } + } + for(pathToRemove : affected) { + LOG.trace("Removed path {}", pathToRemove) + map.remove(pathToRemove); + } + + } + + override close() { + // NOOP + } + } class HashMapDataStoreTransaction implements //