From: Tony Tkacik Date: Thu, 15 Jan 2015 15:49:44 +0000 (+0000) Subject: Merge "Bug 2358: Removed unused Hydrogen Data Store leftovers" X-Git-Tag: release/lithium~703 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=464b8b3ed84c6750905c3ded5dbd9328a18d7652;hp=10b50c92929fe43986639a7cd95fcfaa7e9c3478 Merge "Bug 2358: Removed unused Hydrogen Data Store leftovers" --- diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java index d299afa057..b8861b3465 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/impl/DomBrokerImplModule.java @@ -17,18 +17,14 @@ import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; import org.opendaylight.controller.sal.core.api.data.DataBrokerService; import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.data.DataStore; import org.opendaylight.controller.sal.core.api.model.SchemaService; import org.opendaylight.controller.sal.core.api.mount.MountProvisionService; import org.opendaylight.controller.sal.core.api.mount.MountService; import org.opendaylight.controller.sal.dom.broker.BackwardsCompatibleMountPointManager; import org.opendaylight.controller.sal.dom.broker.BrokerImpl; -import org.opendaylight.controller.sal.dom.broker.DataBrokerImpl; import org.opendaylight.controller.sal.dom.broker.GlobalBundleScanningSchemaServiceImpl; -import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter; import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareRpcBroker; import org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProviders; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; /** * @@ -51,25 +47,19 @@ public final class DomBrokerImplModule extends org.opendaylight.controller.confi @Override public java.lang.AutoCloseable createInstance() { - final DataStore legacyStore = getDataStoreDependency(); final DOMDataBroker asyncBroker= getAsyncDataBrokerDependency(); - ClassToInstanceMap services = MutableClassToInstanceMap.create(); + final ClassToInstanceMap services = MutableClassToInstanceMap.create(); - SchemaService schemaService = getSchemaServiceImpl(); + final SchemaService schemaService = getSchemaServiceImpl(); services.putInstance(SchemaService.class, schemaService); - SchemaAwareRpcBroker router = new SchemaAwareRpcBroker("/", SchemaContextProviders + final SchemaAwareRpcBroker router = new SchemaAwareRpcBroker("/", SchemaContextProviders .fromSchemaService(schemaService)); services.putInstance(RpcProvisionRegistry.class, router); - final DataProviderService legacyData; - if(asyncBroker != null) { - services.putInstance(DOMDataBroker.class, asyncBroker); - legacyData = new BackwardsCompatibleDataBroker(asyncBroker,schemaService); - } else { - legacyData = createLegacyDataService(legacyStore,schemaService); - } + services.putInstance(DOMDataBroker.class, asyncBroker); + final DataProviderService legacyData = new BackwardsCompatibleDataBroker(asyncBroker,schemaService); services.putInstance(DataProviderService.class,legacyData); services.putInstance(DataBrokerService.class, legacyData); @@ -84,22 +74,6 @@ public final class DomBrokerImplModule extends org.opendaylight.controller.confi return new BrokerImpl(router, services); } - @Deprecated - private DataProviderService createLegacyDataService(final DataStore legacyStore, final SchemaService schemaService) { - YangInstanceIdentifier rootPath = YangInstanceIdentifier.builder().toInstance(); - DataBrokerImpl dataService = new DataBrokerImpl(); - SchemaAwareDataStoreAdapter wrappedStore = new SchemaAwareDataStoreAdapter(); - wrappedStore.changeDelegate(legacyStore); - wrappedStore.setValidationEnabled(false); - - schemaService.registerSchemaContextListener(wrappedStore); - - dataService.registerConfigurationReader(rootPath, wrappedStore); - dataService.registerCommitHandler(rootPath, wrappedStore); - dataService.registerOperationalReader(rootPath, wrappedStore); - return dataService; - } - private SchemaService getSchemaServiceImpl() { final SchemaService schemaService; if(getRootSchemaService() != null) { diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataStoreStatsWrapper.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataStoreStatsWrapper.java deleted file mode 100644 index bc86581a20..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/DataStoreStatsWrapper.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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 java.util.concurrent.atomic.AtomicLong; - -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.controller.sal.core.api.data.DataStore; -import org.opendaylight.yangtools.concepts.Delegator; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; - -@Deprecated -public class DataStoreStatsWrapper implements Delegator, DataStore { - - private final DataStore delegate; - - private AtomicLong cfgReadCount = new AtomicLong(); - private AtomicLong cfgReadTimeTotal = new AtomicLong(); - - private AtomicLong operReadCount = new AtomicLong(); - private AtomicLong operReadTimeTotal = new AtomicLong(); - - private AtomicLong requestCommitCount = new AtomicLong(); - private AtomicLong requestCommitTimeTotal = new AtomicLong(); - - public DataStoreStatsWrapper(DataStore store) { - delegate = store; - } - - @Override - public DataStore getDelegate() { - return delegate; - } - - @Override - public CompositeNode readConfigurationData(YangInstanceIdentifier path) { - cfgReadCount.incrementAndGet(); - final long startTime = System.nanoTime(); - try { - return delegate.readConfigurationData(path); - } finally { - final long endTime = System.nanoTime(); - final long runTime = endTime - startTime; - cfgReadTimeTotal.addAndGet(runTime); - } - } - - @Override - public CompositeNode readOperationalData(YangInstanceIdentifier path) { - operReadCount.incrementAndGet(); - final long startTime = System.nanoTime(); - try { - return delegate.readOperationalData(path); - } finally { - final long endTime = System.nanoTime(); - final long runTime = endTime - startTime; - operReadTimeTotal.addAndGet(runTime); - } - } - - public DataCommitTransaction requestCommit( - DataModification modification) { - requestCommitCount.incrementAndGet(); - final long startTime = System.nanoTime(); - try { - return delegate.requestCommit(modification); - } finally { - final long endTime = System.nanoTime(); - final long runTime = endTime - startTime; - requestCommitTimeTotal.addAndGet(runTime); - } - }; - - @Override - public boolean containsConfigurationPath(YangInstanceIdentifier path) { - return delegate.containsConfigurationPath(path); - } - - public Iterable getStoredConfigurationPaths() { - return delegate.getStoredConfigurationPaths(); - } - - public Iterable getStoredOperationalPaths() { - return delegate.getStoredOperationalPaths(); - } - - public boolean containsOperationalPath(YangInstanceIdentifier path) { - return delegate.containsOperationalPath(path); - } - - public final long getConfigurationReadCount() { - return cfgReadCount.get(); - } - - public final long getOperationalReadCount() { - return operReadCount.get(); - } - - public final long getRequestCommitCount() { - return requestCommitCount.get(); - } - - public final double getConfigurationReadTotalTime() { - return cfgReadTimeTotal.get() / 1000.0d; - } - - public final double getOperationalReadTotalTime() { - return operReadTimeTotal.get() / 1000.0d; - } - - public final double getRequestCommitTotalTime() { - return requestCommitTimeTotal.get() / 1000.0d; - } - - public final double getConfigurationReadAverageTime() { - long readCount = cfgReadCount.get(); - if(readCount == 0) { - return 0; - } - return getConfigurationReadTotalTime() / readCount; - } - - public final double getOperationalReadAverageTime() { - long readCount = operReadCount.get(); - if(readCount == 0) { - return 0; - } - return getOperationalReadTotalTime() / readCount; - } - - public final double getRequestCommitAverageTime() { - long count = requestCommitCount.get(); - if(count == 0) { - return 0; - } - return getRequestCommitTotalTime() / count; - } - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java deleted file mode 100644 index 6a456ba0e8..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareDataStoreAdapter.java +++ /dev/null @@ -1,456 +0,0 @@ -/* - * 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 static com.google.common.base.Preconditions.checkState; -import com.google.common.base.Predicate; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.concurrent.Future; -import org.opendaylight.controller.md.sal.common.api.TransactionStatus; -import org.opendaylight.controller.md.sal.common.api.data.DataModification; -import org.opendaylight.controller.md.sal.common.api.data.DataReader; -import org.opendaylight.controller.md.sal.common.impl.AbstractDataModification; -import org.opendaylight.controller.md.sal.common.impl.util.AbstractLockableDelegator; -import org.opendaylight.controller.sal.core.api.data.DataStore; -import org.opendaylight.controller.sal.dom.broker.util.YangDataOperations; -import org.opendaylight.controller.sal.dom.broker.util.YangSchemaUtils; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; -import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; -import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.api.SchemaContextListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Deprecated -public class SchemaAwareDataStoreAdapter extends AbstractLockableDelegator implements DataStore, SchemaContextListener, AutoCloseable { - - private final static Logger LOG = LoggerFactory.getLogger(SchemaAwareDataStoreAdapter.class); - - private SchemaContext schema = null; - private boolean validationEnabled = false; - private final DataReader reader = new MergeFirstLevelReader(); - - @Override - public boolean containsConfigurationPath(final YangInstanceIdentifier path) { - try { - getDelegateReadLock().lock(); - return getDelegate().containsConfigurationPath(path); - - } finally { - getDelegateReadLock().unlock(); - } - } - - @Override - public boolean containsOperationalPath(final YangInstanceIdentifier path) { - try { - getDelegateReadLock().lock(); - return getDelegate().containsOperationalPath(path); - - } finally { - getDelegateReadLock().unlock(); - } - } - - @Override - public Iterable getStoredConfigurationPaths() { - try { - getDelegateReadLock().lock(); - return getDelegate().getStoredConfigurationPaths(); - - } finally { - getDelegateReadLock().unlock(); - } - } - - @Override - public Iterable getStoredOperationalPaths() { - try { - getDelegateReadLock().lock(); - return getDelegate().getStoredOperationalPaths(); - - } finally { - getDelegateReadLock().unlock(); - } - } - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { - return reader.readConfigurationData(path); - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier path) { - return reader.readOperationalData(path); - } - - @Override - public org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction requestCommit( - final DataModification modification) { - validateAgainstSchema(modification); - NormalizedDataModification cleanedUp = prepareMergedTransaction(modification); - cleanedUp.status = TransactionStatus.SUBMITED; - return retrieveDelegate().requestCommit(cleanedUp); - } - - public boolean isValidationEnabled() { - return validationEnabled; - } - - public void setValidationEnabled(final boolean validationEnabled) { - this.validationEnabled = validationEnabled; - } - - private void validateAgainstSchema(final DataModification modification) { - if (!validationEnabled) { - return; - } - - if (schema == null) { - LOG.warn("Validation not performed for {}. Reason: YANG Schema not present.", modification.getIdentifier()); - return; - } - } - - @Override - protected void onDelegateChanged(final DataStore oldDelegate, final DataStore newDelegate) { - // NOOP - } - - @Override - public void onGlobalContextUpdated(final SchemaContext context) { - this.schema = context; - } - - @Override - public void close() throws Exception { - this.schema = null; - } - - protected CompositeNode mergeData(final YangInstanceIdentifier path, final CompositeNode stored, final CompositeNode modified, - final boolean config) { - // long startTime = System.nanoTime(); - try { - DataSchemaNode node = schemaNodeFor(path); - return YangDataOperations.merge(node, stored, modified, config); - } finally { - // System.out.println("Merge time: " + ((System.nanoTime() - - // startTime) / 1000.0d)); - } - } - - private DataSchemaNode schemaNodeFor(final YangInstanceIdentifier path) { - checkState(schema != null, "YANG Schema is not available"); - return YangSchemaUtils.getSchemaNode(schema, path); - } - - private NormalizedDataModification prepareMergedTransaction( - final DataModification original) { - NormalizedDataModification normalized = new NormalizedDataModification(original); - LOG.trace("Transaction: {} Removed Configuration {}, Removed Operational {}", original.getIdentifier(), - original.getRemovedConfigurationData(), original.getRemovedConfigurationData()); - LOG.trace("Transaction: {} Created Configuration {}, Created Operational {}", original.getIdentifier(), - original.getCreatedConfigurationData().entrySet(), original.getCreatedOperationalData().entrySet()); - LOG.trace("Transaction: {} Updated Configuration {}, Updated Operational {}", original.getIdentifier(), - original.getUpdatedConfigurationData().entrySet(), original.getUpdatedOperationalData().entrySet()); - - for (YangInstanceIdentifier entry : original.getRemovedConfigurationData()) { - normalized.deepRemoveConfigurationData(entry); - } - for (YangInstanceIdentifier entry : original.getRemovedOperationalData()) { - normalized.deepRemoveOperationalData(entry); - } - for (Entry entry : original.getUpdatedConfigurationData().entrySet()) { - normalized.putDeepConfigurationData(entry.getKey(), entry.getValue()); - } - for (Entry entry : original.getUpdatedOperationalData().entrySet()) { - normalized.putDeepOperationalData(entry.getKey(), entry.getValue()); - } - return normalized; - } - - private Iterable getConfigurationSubpaths(final YangInstanceIdentifier entry) { - // FIXME: This should be replaced by index - Iterable paths = getStoredConfigurationPaths(); - - return getChildrenPaths(entry, paths); - - } - - public Iterable getOperationalSubpaths(final YangInstanceIdentifier entry) { - // FIXME: This should be indexed - Iterable paths = getStoredOperationalPaths(); - - return getChildrenPaths(entry, paths); - } - - private static final Iterable getChildrenPaths(final YangInstanceIdentifier entry, - final Iterable paths) { - ImmutableSet.Builder children = ImmutableSet.builder(); - for (YangInstanceIdentifier potential : paths) { - if (entry.contains(potential)) { - children.add(entry); - } - } - return children.build(); - } - - private final Comparator> preparationComparator = new Comparator>() { - @Override - public int compare(final Entry o1, final Entry o2) { - YangInstanceIdentifier o1Key = o1.getKey(); - YangInstanceIdentifier o2Key = o2.getKey(); - return Integer.compare(Iterables.size(o1Key.getPathArguments()), Iterables.size(o2Key.getPathArguments())); - } - }; - - private class MergeFirstLevelReader implements DataReader { - - @Override - public CompositeNode readConfigurationData(final YangInstanceIdentifier path) { - getDelegateReadLock().lock(); - try { - if (Iterables.isEmpty(path.getPathArguments())) { - return null; - } - QName qname = null; - CompositeNode original = getDelegate().readConfigurationData(path); - ArrayList> childNodes = new ArrayList>(); - if (original != null) { - childNodes.addAll(original.getValue()); - qname = original.getNodeType(); - } else { - qname = path.getLastPathArgument().getNodeType(); - } - - FluentIterable directChildren = FluentIterable.from(getStoredConfigurationPaths()) - .filter(new Predicate() { - @Override - public boolean apply(final YangInstanceIdentifier input) { - if (path.contains(input)) { - int nesting = Iterables.size(input.getPathArguments()) - Iterables.size(path.getPathArguments()); - if (nesting == 1) { - return true; - } - } - return false; - } - }); - for (YangInstanceIdentifier instanceIdentifier : directChildren) { - childNodes.add(getDelegate().readConfigurationData(instanceIdentifier)); - } - if (original == null && childNodes.isEmpty()) { - return null; - } - - return new CompositeNodeTOImpl(qname, null, childNodes); - } finally { - getDelegateReadLock().unlock(); - } - } - - @Override - public CompositeNode readOperationalData(final YangInstanceIdentifier path) { - getDelegateReadLock().lock(); - try { - if (Iterables.isEmpty(path.getPathArguments())) { - return null; - } - QName qname = null; - CompositeNode original = getDelegate().readOperationalData(path); - ArrayList> childNodes = new ArrayList>(); - if (original != null) { - childNodes.addAll(original.getValue()); - qname = original.getNodeType(); - } else { - qname = path.getLastPathArgument().getNodeType(); - } - - FluentIterable directChildren = FluentIterable.from(getStoredOperationalPaths()) - .filter(new Predicate() { - @Override - public boolean apply(final YangInstanceIdentifier input) { - if (path.contains(input)) { - int nesting = Iterables.size(input.getPathArguments()) - Iterables.size(path.getPathArguments()); - if (nesting == 1) { - return true; - } - } - return false; - } - }); - - for (YangInstanceIdentifier instanceIdentifier : directChildren) { - childNodes.add(getDelegate().readOperationalData(instanceIdentifier)); - } - if (original == null && childNodes.isEmpty()) { - return null; - } - - return new CompositeNodeTOImpl(qname, null, childNodes); - } finally { - getDelegateReadLock().unlock(); - } - } - } - - private class NormalizedDataModification extends AbstractDataModification { - - private final String CONFIGURATIONAL_DATA_STORE_MARKER = "configurational"; - private final String OPERATIONAL_DATA_STORE_MARKER = "operational"; - private final Object identifier; - private TransactionStatus status; - - public NormalizedDataModification(final DataModification original) { - super(getDelegate()); - identifier = original; - status = TransactionStatus.NEW; - } - - /** - * - * Ensures all subpaths are removed - this currently does slow lookup in - * all keys. - * - * @param entry - */ - public void deepRemoveOperationalData(final YangInstanceIdentifier entry) { - Iterable paths = getOperationalSubpaths(entry); - removeOperationalData(entry); - for (YangInstanceIdentifier potential : paths) { - removeOperationalData(potential); - } - } - - public void deepRemoveConfigurationData(final YangInstanceIdentifier entry) { - Iterable paths = getConfigurationSubpaths(entry); - removeConfigurationData(entry); - for (YangInstanceIdentifier potential : paths) { - removeConfigurationData(potential); - } - } - - public void putDeepConfigurationData(final YangInstanceIdentifier entryKey, final CompositeNode entryData) { - this.putCompositeNodeData(entryKey, entryData, CONFIGURATIONAL_DATA_STORE_MARKER); - } - - public void putDeepOperationalData(final YangInstanceIdentifier entryKey, final CompositeNode entryData) { - this.putCompositeNodeData(entryKey, entryData, OPERATIONAL_DATA_STORE_MARKER); - } - - @Override - public Object getIdentifier() { - return this.identifier; - } - - @Override - public TransactionStatus getStatus() { - return status; - } - - @Override - public Future> commit() { - throw new UnsupportedOperationException("Commit should not be invoked on this"); - } - - @Override - protected CompositeNode mergeConfigurationData(final YangInstanceIdentifier path, final CompositeNode stored, - final CompositeNode modified) { - return mergeData(path, stored, modified, true); - } - - @Override - protected CompositeNode mergeOperationalData(final YangInstanceIdentifier path, final CompositeNode stored, - final CompositeNode modified) { - return mergeData(path, stored, modified, false); - } - - private void putData(final YangInstanceIdentifier entryKey, final CompositeNode entryData, final String dataStoreIdentifier) { - if (dataStoreIdentifier != null && entryKey != null && entryData != null) { - switch (dataStoreIdentifier) { - case (CONFIGURATIONAL_DATA_STORE_MARKER): - this.putConfigurationData(entryKey, entryData); - break; - case (OPERATIONAL_DATA_STORE_MARKER): - this.putOperationalData(entryKey, entryData); - break; - - default: - LOG.error(dataStoreIdentifier + " is NOT valid DataStore switch marker"); - throw new RuntimeException(dataStoreIdentifier + " is NOT valid DataStore switch marker"); - } - } - } - - private void putCompositeNodeData(final YangInstanceIdentifier entryKey, final CompositeNode entryData, - final String dataStoreIdentifier) { - this.putData(entryKey, entryData, dataStoreIdentifier); - - for (Node child : entryData.getValue()) { - YangInstanceIdentifier subEntryId = YangInstanceIdentifier.builder(entryKey).node(child.getNodeType()) - .toInstance(); - if (child instanceof CompositeNode) { - DataSchemaNode subSchema = schemaNodeFor(subEntryId); - CompositeNode compNode = (CompositeNode) child; - YangInstanceIdentifier instanceId = null; - - if (subSchema instanceof ListSchemaNode) { - ListSchemaNode listSubSchema = (ListSchemaNode) subSchema; - Map mapOfSubValues = this.getValuesFromListSchema(listSubSchema, - (CompositeNode) child); - if (mapOfSubValues != null) { - instanceId = YangInstanceIdentifier.builder(entryKey) - .nodeWithKey(listSubSchema.getQName(), mapOfSubValues).toInstance(); - } - } else if (subSchema instanceof ContainerSchemaNode) { - ContainerSchemaNode containerSchema = (ContainerSchemaNode) subSchema; - instanceId = YangInstanceIdentifier.builder(entryKey).node(subSchema.getQName()).toInstance(); - } - if (instanceId != null) { - this.putCompositeNodeData(instanceId, compNode, dataStoreIdentifier); - } - } - } - } - - private Map getValuesFromListSchema(final ListSchemaNode listSchema, final CompositeNode entryData) { - List keyDef = listSchema.getKeyDefinition(); - if (keyDef != null && !keyDef.isEmpty()) { - Map map = new HashMap(); - for (QName key : keyDef) { - List> data = entryData.get(key); - if (data != null && !data.isEmpty()) { - for (Node nodeData : data) { - if (nodeData instanceof SimpleNode) { - map.put(key, data.get(0).getValue()); - } - } - } - } - return map; - } - return null; - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProvider.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProvider.java deleted file mode 100644 index e49a28d8e0..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProvider.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2013 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; - -/** - * @deprecated Use org.opendaylight.yangtools.yang.model.api.SchemaContextProvider instead - */ -@Deprecated -public interface SchemaContextProvider extends org.opendaylight.yangtools.yang.model.api.SchemaContextProvider{ - -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.java deleted file mode 100644 index 41fcd08773..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataOperations.java +++ /dev/null @@ -1,170 +0,0 @@ -/* - * 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.util; - -import static com.google.common.base.Preconditions.checkArgument; - -import com.google.common.base.Preconditions; -import com.google.common.collect.Iterables; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; - -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.Node; -import org.opendaylight.yangtools.yang.data.impl.CompositeNodeTOImpl; -import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode; -import org.opendaylight.yangtools.yang.model.api.DataNodeContainer; -import org.opendaylight.yangtools.yang.model.api.DataSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode; -import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode; -import org.opendaylight.yangtools.yang.model.api.ListSchemaNode; - -@Deprecated -public class YangDataOperations { - - public static CompositeNode merge(final DataSchemaNode schema, - final CompositeNode stored, final CompositeNode modified, - final boolean config) { - if (stored == null) { - return modified; - } - - Preconditions.checkArgument(schema instanceof ListSchemaNode - || schema instanceof ContainerSchemaNode, - "Supplied node is not data node container."); - - return YangDataOperations.mergeContainer((DataNodeContainer) schema, - stored, modified, config); - } - - private static Iterable> _mergeMultiple( - final LeafSchemaNode node, final List> original, - final List> modified, final boolean configurational) { - checkArgument(original.size() == 1); - checkArgument(modified.size() == 1); - - return modified; - } - - private static Iterable> _mergeMultiple( - final LeafListSchemaNode node, final List> original, - final List> modified, final boolean configurational) { - return modified; - } - - private static Iterable> _mergeMultiple( - final ContainerSchemaNode node, final List> original, - final List> modified, final boolean configurational) { - checkArgument(original.size() == 1); - checkArgument(modified.size() == 1); - return Collections.singletonList(merge(node, - (CompositeNode) original.get(0), - (CompositeNode) modified.get(0), configurational)); - } - - private static Iterable> _mergeMultiple( - final ListSchemaNode node, final List> original, - final List> modified, final boolean configurational) { - - if (node.getKeyDefinition() == null - || node.getKeyDefinition().isEmpty()) { - return modified; - } - @SuppressWarnings({ "unchecked", "rawtypes" }) - final Map, CompositeNode> originalMap = YangDataUtils - .toIndexMap((List) original, node.getKeyDefinition()); - @SuppressWarnings({ "unchecked", "rawtypes" }) - final Map, CompositeNode> modifiedMap = YangDataUtils - .toIndexMap((List) modified, node.getKeyDefinition()); - - final List> mergedNodes = new ArrayList>( - original.size() + modified.size()); - for (final Map.Entry, CompositeNode> entry : modifiedMap - .entrySet()) { - final CompositeNode originalEntry = originalMap.get(entry.getKey()); - if (originalEntry != null) { - originalMap.remove(entry.getKey()); - mergedNodes.add(merge(node, originalEntry, entry.getValue(), - configurational)); - } else { - mergedNodes.add(entry.getValue()); - } - } - mergedNodes.addAll(originalMap.values()); - return mergedNodes; - } - - private static Iterable> mergeMultiple( - final DataSchemaNode node, final List> original, - final List> modified, final boolean configurational) { - if (node instanceof ContainerSchemaNode) { - return _mergeMultiple((ContainerSchemaNode) node, original, - modified, configurational); - } else if (node instanceof LeafListSchemaNode) { - return _mergeMultiple((LeafListSchemaNode) node, original, - modified, configurational); - } else if (node instanceof LeafSchemaNode) { - return _mergeMultiple((LeafSchemaNode) node, original, modified, - configurational); - } else if (node instanceof ListSchemaNode) { - return _mergeMultiple((ListSchemaNode) node, original, modified, - configurational); - } else { - throw new IllegalArgumentException("Unhandled parameter types: " - + Arrays. asList(node, original, modified, - configurational).toString()); - } - } - - private static CompositeNode mergeContainer(final DataNodeContainer schema, - final CompositeNode stored, final CompositeNode modified, - final boolean config) { - if (stored == null) { - return modified; - } - Preconditions.checkNotNull(stored); - Preconditions.checkNotNull(modified); - Preconditions.checkArgument(Objects.equals(stored.getNodeType(), - modified.getNodeType())); - - final List> mergedChildNodes = new ArrayList>(stored - .getValue().size() + modified.getValue().size()); - final Set toProcess = new HashSet(stored.keySet()); - toProcess.addAll(modified.keySet()); - - for (QName qname : toProcess) { - final DataSchemaNode schemaChild = schema.getDataChildByName(qname); - final List> storedChildren = stored.get(qname); - final List> modifiedChildren = modified.get(qname); - - if (modifiedChildren != null && !modifiedChildren.isEmpty()) { - if (storedChildren == null || storedChildren.isEmpty() - || schemaChild == null) { - mergedChildNodes.addAll(modifiedChildren); - } else { - final Iterable> _mergeMultiple = mergeMultiple( - schemaChild, storedChildren, modifiedChildren, - config); - Iterables.addAll(mergedChildNodes, _mergeMultiple); - } - } else if (storedChildren != null && !storedChildren.isEmpty()) { - mergedChildNodes.addAll(storedChildren); - } - } - return new CompositeNodeTOImpl(stored.getNodeType(), null, - mergedChildNodes); - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataUtils.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataUtils.java deleted file mode 100644 index bdd3e8d69b..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/util/YangDataUtils.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.util; - -import static com.google.common.base.Preconditions.checkArgument; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.SimpleNode; - -@Deprecated -public final class YangDataUtils { - - private YangDataUtils() { - throw new UnsupportedOperationException("Utility class"); - } - - public static Map,CompositeNode> toIndexMap(final List nodes,final List keys) { - ConcurrentHashMap,CompositeNode> ret = new ConcurrentHashMap<>(); - for(CompositeNode node : nodes) { - Map key = getKeyMap(node,keys); - ret.put(key, node); - } - return ret; - } - - public static Map getKeyMap(final CompositeNode node, final List keys) { - Map map = new HashMap<>(); - for(QName key : keys) { - SimpleNode keyNode = node.getFirstSimpleByName(QName.create(node.getNodeType(), key.getLocalName())); - checkArgument(keyNode != null,"Node must contains all keys."); - Object value = keyNode.getValue(); - map.put(key, value); - - } - return map; - } -} diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java index 2000e11a35..bdeb129d55 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/sal/NetconfDeviceSalFacade.java @@ -31,6 +31,7 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.model.api.RpcDefinition; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; import org.osgi.framework.BundleContext; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,7 +66,7 @@ public final class NetconfDeviceSalFacade implements AutoCloseable, RemoteDevice final NetconfSessionCapabilities netconfSessionPreferences, final RpcImplementation deviceRpc) { // TODO move SchemaAwareRpcBroker from sal-broker-impl, now we have depend on the whole sal-broker-impl - final RpcProvisionRegistry rpcRegistry = new SchemaAwareRpcBroker(id.getPath().toString(), new org.opendaylight.controller.sal.dom.broker.impl.SchemaContextProvider() { + final RpcProvisionRegistry rpcRegistry = new SchemaAwareRpcBroker(id.getPath().toString(), new SchemaContextProvider() { @Override public SchemaContext getSchemaContext() { return schemaContext;