private void checkOdActions(
List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions) {
- checkOdAction(actions, FloodActionCase.class, false);
- checkOdAction(actions, FloodAllActionCase.class, false);
- checkOdAction(actions, HwPathActionCase.class, false);
- checkOdAction(actions, LoopbackActionCase.class, false);
- checkOdAction(actions, PopVlanActionCase.class, false);
- checkOdAction(actions, PushVlanActionCase.class, true);
- checkOdAction(actions, SetDlDstActionCase.class, true);
- checkOdAction(actions, SetDlSrcActionCase.class, true);
- checkOdAction(actions, SetDlTypeActionCase.class, true);
- checkOdAction(actions, SetNwTosActionCase.class, true);
- checkOdAction(actions, SetNwDstActionCase.class, true);
- checkOdAction(actions, SetNwSrcActionCase.class, true);
- checkOdAction(actions, SetNextHopActionCase.class, true);
- checkOdAction(actions, SetTpDstActionCase.class, true);
- checkOdAction(actions, SetTpSrcActionCase.class, true);
- checkOdAction(actions, SetVlanCfiActionCase.class, true);
- checkOdAction(actions, SetVlanIdActionCase.class, true);
- checkOdAction(actions, SetVlanPcpActionCase.class, true);
- checkOdAction(actions, SwPathActionCase.class, false);
+ checkOdAction(actions, FloodActionCase.class);
+ checkOdAction(actions, FloodAllActionCase.class);
+ checkOdAction(actions, HwPathActionCase.class);
+ checkOdAction(actions, LoopbackActionCase.class);
+ checkOdAction(actions, PopVlanActionCase.class);
+ checkOdAction(actions, PushVlanActionCase.class);
+ checkOdAction(actions, SetDlDstActionCase.class);
+ checkOdAction(actions, SetDlSrcActionCase.class);
+ checkOdAction(actions, SetDlTypeActionCase.class);
+ checkOdAction(actions, SetNwTosActionCase.class);
+ checkOdAction(actions, SetNwDstActionCase.class);
+ checkOdAction(actions, SetNwSrcActionCase.class);
+ checkOdAction(actions, SetNextHopActionCase.class);
+ checkOdAction(actions, SetTpDstActionCase.class);
+ checkOdAction(actions, SetTpSrcActionCase.class);
+ checkOdAction(actions, SetVlanCfiActionCase.class);
+ checkOdAction(actions, SetVlanIdActionCase.class);
+ checkOdAction(actions, SetVlanPcpActionCase.class);
+ checkOdAction(actions, SwPathActionCase.class);
}
private void checkOdAction(
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions, Class<?> cl,
- boolean b) {
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actions, Class<?> cl) {
int numOfFoundActions = 0;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action action : actions) {
org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action innerAction = action
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainFactory;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@Override
ListenerRegistration<DataChangeListener> registerDataChangeListener(LogicalDatastoreType store,
InstanceIdentifier<?> path, DataChangeListener listener, DataChangeScope triggeringScope);
+
+ @Override
+ BindingTransactionChain createTransactionChain(TransactionChainListener listener);
}
/**
* Stores a piece of data at the specified path. This acts as an add / replace
* operation, which is to say that whole subtree will be replaced by the specified data.
+ * * <p>
+ * This method does not automatically create missing parent nodes. It is equivalent to invoking
+ * {@link #put(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)}
+ * with <code>createMissingParents</code> set to false.
* <p>
* For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
* <p>
*/
<T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
+
+ /**
+ * Stores a piece of data at the specified path. This acts as an add /
+ * replace operation, which is to say that whole subtree will be replaced by
+ * the specified data.
+ * <p>
+ * For more information on usage and examples, please see the documentation
+ * in {@link AsyncWriteTransaction}.
+ * <p>
+ * If you need to make sure that a parent object exists but you do not want
+ * modify its pre-existing state by using put, consider using {@link #merge}
+ * instead.
+ *
+ * Note: Using <code>createMissingParents</code> with value true, may
+ * introduce garbage in data store, or recreate nodes, which were deleted by
+ * previous transaction.
+ *
+ * @param store
+ * the logical data store which should be modified
+ * @param path
+ * the data object path
+ * @param data
+ * the data object to be written to the specified path
+ * @param createMissingParents
+ * if true, any missing parent nodes will be automatically
+ * created using a merge operation.
+ * @throws IllegalStateException
+ * if the transaction has already been submitted
+ */
+ <T extends DataObject> void put(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
+ boolean createMissingParents);
+
/**
* Merges a piece of data with the existing data at a specified path. Any pre-existing data
* which is not explicitly overwritten will be preserved. This means that if you store a container,
* its child lists will be merged.
* <p>
+ * This method does not automatically create missing parent nodes. It is equivalent to invoking
+ * {@link #merge(LogicalDatastoreType, InstanceIdentifier, DataObject, boolean)}
+ * with <code>createMissingParents</code> set to false.
+ * <p>
* For more information on usage and examples, please see the documentation in {@link AsyncWriteTransaction}.
*<p>
* If you require an explicit replace operation, use {@link #put} instead.
- *
* @param store
* the logical data store which should be modified
* @param path
*/
<T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data);
+ /**
+ * Merges a piece of data with the existing data at a specified path. Any
+ * pre-existing data which is not explicitly overwritten will be preserved.
+ * This means that if you store a container, its child lists will be merged.
+ * <p>
+ * For more information on usage and examples, please see the documentation
+ * in {@link AsyncWriteTransaction}.
+ * <p>
+ * If you require an explicit replace operation, use {@link #put} instead.
+ *
+ * @param store
+ * the logical data store which should be modified
+ * @param path
+ * the data object path
+ * @param data
+ * the data object to be merged to the specified path
+ * @param createMissingParents
+ * if true, any missing parent nodes will be automatically created
+ * using a merge operation.
+ * @throws IllegalStateException
+ * if the transaction has already been submitted
+ */
+ <T extends DataObject> void merge(LogicalDatastoreType store, InstanceIdentifier<T> path, T data,
+ boolean createMissingParents);
+
@Override
void delete(LogicalDatastoreType store, InstanceIdentifier<?> path);
}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
super(delegate, codec);
}
- protected final void doPutWithEnsureParents(final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
- final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
- .toNormalizedNode(path, data);
-
- final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey();
- ensureParentsByMerge(store, normalizedPath, path);
- LOG.debug("Tx: {} : Putting data {}", getDelegate().getIdentifier(), normalizedPath);
- doPut(store, path, data);
- }
-
- protected final void doMergeWithEnsureParents(final LogicalDatastoreType store, final InstanceIdentifier<?> path, final DataObject data) {
- final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
- .toNormalizedNode(path, data);
-
- final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath = normalized.getKey();
- ensureParentsByMerge(store, normalizedPath, path);
- LOG.debug("Tx: {} : Merge data {}", getDelegate().getIdentifier(), normalizedPath);
- doMerge(store, path, data);
- }
-
- private final void ensureParentsByMerge(final LogicalDatastoreType store,
+ @Override
+ protected final void ensureParentsByMerge(final LogicalDatastoreType store,
final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath,
final InstanceIdentifier<?> path) {
List<PathArgument> currentArguments = new ArrayList<>();
* Abstract Base Transaction for transactions which are backed by
* {@link DOMDataWriteTransaction}
*/
-public class AbstractWriteTransaction<T extends DOMDataWriteTransaction> extends
+public abstract class AbstractWriteTransaction<T extends DOMDataWriteTransaction> extends
AbstractForwardedTransaction<T> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractWriteTransaction.class);
super(delegate, codec);
}
- protected final void doPut(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path, final DataObject data) {
+
+ public final <U extends DataObject> void put(final LogicalDatastoreType store,
+ final InstanceIdentifier<U> path, final U data, final boolean createParents) {
final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
.toNormalizedNode(path, data);
- ensureListParentIfNeeded(store,path,normalized);
+ if(createParents) {
+ ensureParentsByMerge(store, normalized.getKey(), path);
+ } else {
+ ensureListParentIfNeeded(store,path,normalized);
+ }
getDelegate().put(store, normalized.getKey(), normalized.getValue());
}
+ public final <U extends DataObject> void merge(final LogicalDatastoreType store,
+ final InstanceIdentifier<U> path, final U data,final boolean createParents) {
+
+ final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
+ .toNormalizedNode(path, data);
+
+ if(createParents) {
+ ensureParentsByMerge(store, normalized.getKey(), path);
+ } else {
+ ensureListParentIfNeeded(store,path,normalized);
+ }
+
+ getDelegate().merge(store, normalized.getKey(), normalized.getValue());
+ }
+
+
/**
*
* Ensures list parent if item is list, otherwise noop.
}
}
- protected final void doMerge(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path, final DataObject data) {
-
- final Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, NormalizedNode<?, ?>> normalized = getCodec()
- .toNormalizedNode(path, data);
- ensureListParentIfNeeded(store,path,normalized);
- getDelegate().merge(store, normalized.getKey(), normalized.getValue());
- }
+ /**
+ * Subclasses of this class are required to implement creation of parent
+ * nodes based on behaviour of their underlying transaction.
+ *
+ * @param store
+ * @param key
+ * @param path
+ */
+ protected abstract void ensureParentsByMerge(LogicalDatastoreType store,
+ org.opendaylight.yangtools.yang.data.api.InstanceIdentifier key, InstanceIdentifier<?> path);
protected final void doDelete(final LogicalDatastoreType store,
final InstanceIdentifier<?> path) {
*/
package org.opendaylight.controller.md.sal.binding.impl;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction;
+import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
+import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationOperation;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.ListenableFuture;
}
@Override
- public <T extends DataObject> void put(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
- final T data) {
- doPut(store, path, data);
+ public <U extends DataObject> void put(final LogicalDatastoreType store, final InstanceIdentifier<U> path,
+ final U data) {
+ put(store, path, data,false);
}
@Override
public <T extends DataObject> void merge(final LogicalDatastoreType store, final InstanceIdentifier<T> path,
final T data) {
- doMerge(store, path, data);
+ merge(store, path, data,false);
+ }
+
+
+ @Override
+ protected void ensureParentsByMerge(final LogicalDatastoreType store,
+ final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier normalizedPath, final InstanceIdentifier<?> path) {
+ List<PathArgument> currentArguments = new ArrayList<>();
+ DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation();
+ Iterator<PathArgument> iterator = normalizedPath.getPathArguments().iterator();
+ while (iterator.hasNext()) {
+ PathArgument currentArg = iterator.next();
+ try {
+ currentOp = currentOp.getChild(currentArg);
+ } catch (DataNormalizationException e) {
+ throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
+ }
+ currentArguments.add(currentArg);
+ org.opendaylight.yangtools.yang.data.api.InstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.create(
+ currentArguments);
+
+ getDelegate().merge(store, currentPath, currentOp.createDefault(currentArg));
+ }
}
@Override
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
+@SuppressWarnings("deprecation")
public class ForwardedBackwardsCompatibleDataBroker extends AbstractForwardedDataBroker implements DataProviderService, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(ForwardedBackwardsCompatibleDataBroker.class);
@Override
public void putOperationalData(final InstanceIdentifier<? extends DataObject> path, final DataObject data) {
boolean previouslyRemoved = posponedRemovedOperational.remove(path);
+
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ final InstanceIdentifier<DataObject> castedPath = (InstanceIdentifier) path;
if(previouslyRemoved) {
- doPutWithEnsureParents(LogicalDatastoreType.OPERATIONAL, path, data);
+ put(LogicalDatastoreType.OPERATIONAL, castedPath, data,true);
} else {
- doMergeWithEnsureParents(LogicalDatastoreType.OPERATIONAL, path, data);
+ merge(LogicalDatastoreType.OPERATIONAL, castedPath, data,true);
}
}
created.put(path, data);
}
updated.put(path, data);
+ @SuppressWarnings({"rawtypes","unchecked"})
+ final InstanceIdentifier<DataObject> castedPath = (InstanceIdentifier) path;
if(previouslyRemoved) {
- doPutWithEnsureParents(LogicalDatastoreType.CONFIGURATION, path, data);
+ put(LogicalDatastoreType.CONFIGURATION, castedPath, data,true);
} else {
- doMergeWithEnsureParents(LogicalDatastoreType.CONFIGURATION, path, data);
+ merge(LogicalDatastoreType.CONFIGURATION, castedPath, data,true);
}
}
*/
package org.opendaylight.controller.sal.binding.codegen.impl;
+import com.google.common.base.Supplier;
+
import java.util.Map;
import java.util.WeakHashMap;
import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
import org.opendaylight.yangtools.yang.binding.util.ClassLoaderUtils;
-import com.google.common.base.Supplier;
-
abstract class AbstractRuntimeCodeGenerator implements org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator, NotificationInvokerFactory {
@GuardedBy("this")
private final Map<Class<? extends NotificationListener>, RuntimeGeneratedInvokerPrototype> invokerClasses = new WeakHashMap<>();
utils.getLock().lock();
try {
- invoker = ClassLoaderUtils.withClassLoader(cls.getClassLoader(), new Supplier<RuntimeGeneratedInvokerPrototype>() {
- @Override
- public RuntimeGeneratedInvokerPrototype get() {
- return generateListenerInvoker(cls);
- }
- });
+ synchronized (utils) {
+ invoker = ClassLoaderUtils.withClassLoader(cls.getClassLoader(), new Supplier<RuntimeGeneratedInvokerPrototype>() {
+ @Override
+ public RuntimeGeneratedInvokerPrototype get() {
+ return generateListenerInvoker(cls);
+ }
+ });
+ }
invokerClasses.put(cls, invoker);
return invoker;
public final <T extends RpcService> T getDirectProxyFor(final Class<T> serviceType) {
utils.getLock().lock();
try {
- return ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), directProxySupplier(serviceType));
+ synchronized (utils) {
+ return ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), directProxySupplier(serviceType));
+ }
} finally {
utils.getLock().unlock();
}
utils.getLock().lock();
try {
- final T instance = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), routerSupplier(serviceType, metadata));
- return new RpcRouterCodegenInstance<T>(name, serviceType, instance, metadata.getContexts());
+ synchronized (utils) {
+ final T instance = ClassLoaderUtils.withClassLoader(serviceType.getClassLoader(), routerSupplier(serviceType, metadata));
+ return new RpcRouterCodegenInstance<T>(name, serviceType, instance, metadata.getContexts());
+ }
} finally {
utils.getLock().unlock();
}
import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
*/
package org.opendaylight.controller.md.sal.binding.impl.test;
+import static org.junit.Assert.assertTrue;
+
import java.util.concurrent.ExecutionException;
import org.junit.Test;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import com.google.common.base.Optional;
+
public class WriteTransactionTest extends AbstractDataBrokerTest {
private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
-
+ private static final TopLevelList NODE = new TopLevelListBuilder().setKey(TOP_LIST_KEY).build();
@Test
public void test() throws InterruptedException, ExecutionException {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, TOP_PATH, new TopBuilder().build());
- writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, new TopLevelListBuilder().setKey(TOP_LIST_KEY).build());
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE);
writeTx.submit().get();
}
+ @Test
+ public void testPutCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
+ writeTx.submit().checkedGet();
+
+ ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+ Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
+ assertTrue("Top node must exists after commit",topNode.isPresent());
+ Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
+ assertTrue("List node must exists after commit",listNode.isPresent());
+ }
+
+ @Test
+ public void testMergeCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
+
+ WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
+ writeTx.merge(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
+ writeTx.submit().checkedGet();
+
+ ReadOnlyTransaction readTx = getDataBroker().newReadOnlyTransaction();
+ Optional<Top> topNode = readTx.read(LogicalDatastoreType.OPERATIONAL, TOP_PATH).get();
+ assertTrue("Top node must exists after commit",topNode.isPresent());
+ Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
+ assertTrue("List node must exists after commit",listNode.isPresent());
+ }
+
}
package org.opendaylight.controller.md.sal.dom.api;
import org.opendaylight.controller.sal.core.api.BrokerService;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
DOMMountPointBuilder createMountPoint(InstanceIdentifier path);
+ ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener);
public interface DOMMountPointBuilder {
--- /dev/null
+/*
+ * 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.core.api.mount;
+
+import java.util.EventListener;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+public interface MountProvisionListener extends EventListener {
+
+ void onMountPointCreated(InstanceIdentifier path);
+
+ void onMountPointRemoved(InstanceIdentifier path);
+
+}
*/
package org.opendaylight.controller.sal.core.api.mount;
-import java.util.EventListener;
-
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener);
- public interface MountProvisionListener extends EventListener {
-
- void onMountPointCreated(InstanceIdentifier path);
-
- void onMountPointRemoved(InstanceIdentifier path);
-
- }
}
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.controller.md.sal.dom.api.DOMService;
import org.opendaylight.controller.md.sal.dom.broker.spi.mount.SimpleDOMMountPoint;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
+import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
private final Map<InstanceIdentifier, SimpleDOMMountPoint> mountPoints = new HashMap<>();
+ private final ListenerRegistry<MountProvisionListener> listeners = ListenerRegistry.create();
+
@Override
public Optional<DOMMountPoint> getMountPoint(final InstanceIdentifier path) {
return Optional.<DOMMountPoint>fromNullable(mountPoints.get(path));
return new DOMMountPointBuilderImpl(path);
}
+ public void notifyMountCreated(final InstanceIdentifier identifier) {
+ for (final ListenerRegistration<MountProvisionListener> listener : listeners
+ .getListeners()) {
+ listener.getInstance().onMountPointCreated(identifier);
+ }
+ }
+
+ @Override
+ public ListenerRegistration<MountProvisionListener> registerProvisionListener(
+ final MountProvisionListener listener) {
+ return listeners.register(listener);
+ }
+
public ObjectRegistration<DOMMountPoint> registerMountPoint(final SimpleDOMMountPoint mountPoint) {
synchronized (mountPoints) {
Preconditions.checkState(!mountPoints.containsKey(mountPoint.getIdentifier()), "Mount point already exists");
mountPoints.put(mountPoint.getIdentifier(), mountPoint);
}
+ notifyMountCreated(mountPoint.getIdentifier());
+
+ // FIXME this shouldnt be null
return null;
}
import org.opendaylight.controller.sal.core.api.data.DataProviderService;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
package org.opendaylight.controller.sal.dom.broker.osgi;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
import org.opendaylight.controller.sal.core.api.Provider;
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.MountProvisionService.MountProvisionListener;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
import org.opendaylight.controller.sal.rest.doc.impl.ApiDocGenerator;
import org.opendaylight.controller.sal.rest.doc.mountpoints.MountPointSwagger;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.controller.sal.core.api.model.SchemaService;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
-import org.opendaylight.controller.sal.core.api.mount.MountProvisionService.MountProvisionListener;
+import org.opendaylight.controller.sal.core.api.mount.MountProvisionListener;
import org.opendaylight.controller.sal.rest.doc.impl.BaseYangSwaggerGenerator;
import org.opendaylight.controller.sal.rest.doc.swagger.Api;
import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration;