From: Tony Tkacik Date: Wed, 9 Oct 2013 10:51:17 +0000 (+0200) Subject: Update to MD-SAL APIs X-Git-Tag: jenkins-controller-bulk-release-prepare-only-2-1~651 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=a251833f27fd00040904e2df316cd707c8129d1e Update to MD-SAL APIs Introduced new Common APIs from which Binding-Aware and Binding-Independent APIs are derived, this allows to maintain similar contract between sal-binding-api and sal-dom-api which provides different access to MD SAL. - Fixed typos in YANG models - Bumped version of YANG Maven Plugin to 0.5.9-SNAPSHOT which now enforces valid YANG models - Removed OFPort.yang - Part of that model should be part of flow-node-inventory.yang - Removed spaces and tabs from various files - Updated implementations to adhere to new API definitions. Change-Id: I5661a76398e8c8d82250de532aef6e5d268123e8 Signed-off-by: Tony Tkacik --- diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index e259296560..f718621b26 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -54,6 +54,16 @@ sal-core-spi ${mdsal.version} + + org.opendaylight.controller + sal-common-api + ${mdsal.version} + + + org.opendaylight.controller + sal-common-impl + ${mdsal.version} + org.opendaylight.controller sal-binding-api @@ -105,6 +115,11 @@ concepts ${concepts.version} + + org.opendaylight.yangtools + concepts + 0.1.1-SNAPSHOT + + model-flow-management @@ -36,7 +35,6 @@ org.apache.felix maven-bundle-plugin - ${bundle.plugin.version} true @@ -141,27 +139,25 @@ org.opendaylight.yangtools yang-binding - ${yang.version} org.opendaylight.yangtools yang-common - ${yang.version} org.opendaylight.yangtools.model ietf-inet-types - 2010.09.24.0 + 2010.09.24.2-SNAPSHOT org.opendaylight.yangtools.model ietf-yang-types - 2010.09.24.0 + 2010.09.24.2-SNAPSHOT org.opendaylight.yangtools.model yang-ext - 2013.09.07.0 + 2013.09.07.1-SNAPSHOT diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 1ef55c6acc..54fd037411 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -12,21 +12,30 @@ + sal-common + sal-common-api + sal-common-impl sal-common-util + sal-dom-api sal-dom-broker sal-dom-spi + sal-binding-api sal-binding-broker + samples + model + sal-compability + sal-connector-api sal-rest-connector @@ -45,8 +54,9 @@ 1.7.2 - 0.5.8 - 0.5.8 + 0.5.9-SNAPSHOT + 0.6.0-SNAPSHOT + 0.6.0-SNAPSHOT 14.0.1 5.0.0 4.8.1 @@ -65,6 +75,11 @@ true + + opendaylight-snapshot + opendaylight-snapshot + ${nexusproxy}/repositories/opendaylight.snapshot/ + opendaylight.release opendaylight.release @@ -132,7 +147,7 @@ org.opendaylight.yangtools yang-binding - ${yang.version} + ${yang.binding.version} org.opendaylight.yangtools @@ -206,7 +221,7 @@ maven-bundle-plugin ${bundle.plugin.version} true - + ${project.groupId}.${project.artifactId} @@ -222,15 +237,6 @@ ${project.basedir}/META-INF - - maven-jar-plugin - - - - ${project.basedir}/META-INF/MANIFEST.MF - - - org.eclipse.xtend xtend-maven-plugin diff --git a/opendaylight/md-sal/sal-binding-api/pom.xml b/opendaylight/md-sal/sal-binding-api/pom.xml index 4c154c5d14..c1dccdf532 100644 --- a/opendaylight/md-sal/sal-binding-api/pom.xml +++ b/opendaylight/md-sal/sal-binding-api/pom.xml @@ -29,6 +29,11 @@ 1.0-SNAPSHOT + + org.opendaylight.controller + sal-common-api + ${project.version} + org.osgi org.osgi.core diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java index 3c95ed8e1c..f6c9df23f2 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareConsumer.java @@ -1,5 +1,13 @@ +/* + * 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.binding.api; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; @@ -8,21 +16,59 @@ public abstract class AbstractBindingAwareConsumer implements BindingAwareConsum @Override public final void start(BundleContext context) throws Exception { + startImpl(context); ServiceReference brokerRef = context.getServiceReference(BindingAwareBroker.class); BindingAwareBroker broker = context.getService(brokerRef); broker.registerConsumer(this, context); - startImpl(context); + //context.ungetService(brokerRef); } - @Deprecated + /** + * Called when this bundle is started (before + * {@link #onSessionInitiated(ProviderContext)} so the Framework can perform + * the bundle-specific activities necessary to start this bundle. This + * method can be used to register services or to allocate any resources that + * this bundle needs. + * + *

+ * This method must complete and return to its caller in a timely manner. + * + * @param context + * The execution context of the bundle being started. + * @throws Exception + * If this method throws an exception, this bundle is marked as + * stopped and the Framework will remove this bundle's + * listeners, unregister all services registered by this bundle, + * and release all services used by this bundle. + */ protected void startImpl(BundleContext context) { - + // NOOP + } + + /** + * Called when this bundle is stopped so the Framework can perform the + * bundle-specific activities necessary to stop the bundle. In general, this + * method should undo the work that the {@code BundleActivator.start} method + * started. There should be no active threads that were started by this + * bundle when this bundle returns. A stopped bundle must not call any + * Framework objects. + * + *

+ * This method must complete and return to its caller in a timely manner. + * + * @param context The execution context of the bundle being stopped. + * @throws Exception If this method throws an exception, the bundle is still + * marked as stopped, and the Framework will remove the bundle's + * listeners, unregister all services registered by the bundle, and + * release all services used by the bundle. + */ + protected void stopImpl(BundleContext context) { + // NOOP } @Override public final void stop(BundleContext context) throws Exception { - // TODO Auto-generated method stub - + stopImpl(context); } } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java index 994d3f40a8..b1a0fe0c28 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/AbstractBindingAwareProvider.java @@ -1,7 +1,16 @@ +/* + * 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.binding.api; import java.util.Collection; +import java.util.Collections; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.yangtools.yang.binding.RpcService; import org.osgi.framework.BundleActivator; @@ -10,57 +19,132 @@ import org.osgi.framework.ServiceReference; public abstract class AbstractBindingAwareProvider implements BindingAwareProvider, BundleActivator { + /** + * Initializes the bundle. + * + * Implementation of initialization get's the Binding Aware Broker from + * service registry and register itself as a {@link BindingAwareProvider} + * + * Callback order is: + *

    + *
  1. {@link #startImpl(BundleContext)} + *
  2. {@link #onSessionInitiated(ProviderContext)} + *
  3. Registration of global {@link RpcService} implementations returned by + * {@link #getImplementations()} + *
  4. Registration of {@link ProviderFunctionality} implementations + * returned by {@link #getFunctionality()} + *
+ * + */ @Override public final void start(BundleContext context) throws Exception { - ServiceReference brokerRef = context.getServiceReference(BindingAwareBroker.class); - BindingAwareBroker broker = context.getService(brokerRef); - - ProviderContext ctx = broker.registerProvider(this, context); - registerRpcImplementations(ctx); - registerFunctionality(ctx); - - startImpl(context); + startImpl(context); + ServiceReference brokerRef = context.getServiceReference(BindingAwareBroker.class); + BindingAwareBroker broker = context.getService(brokerRef); + + ProviderContext ctx = broker.registerProvider(this, context); + registerRpcImplementations(ctx); + registerFunctionality(ctx); } - + private void registerFunctionality(ProviderContext ctx) { Collection functionality = this.getFunctionality(); - if(functionality == null || functionality.isEmpty()) { + if (functionality == null || functionality.isEmpty()) { return; } for (ProviderFunctionality providerFunctionality : functionality) { ctx.registerFunctionality(providerFunctionality); } - + } private void registerRpcImplementations(ProviderContext ctx) { Collection rpcs = this.getImplementations(); - if(rpcs == null || rpcs.isEmpty()) { + if (rpcs == null || rpcs.isEmpty()) { return; } for (RpcService rpcService : rpcs) { - //ctx.addRpcImplementation(type, implementation); + // ctx.addRpcImplementation(type, implementation); } - + } + /** + * Called when this bundle is started (before + * {@link #onSessionInitiated(ProviderContext)} so the Framework can perform + * the bundle-specific activities necessary to start this bundle. This + * method can be used to register services or to allocate any resources that + * this bundle needs. + * + *

+ * This method must complete and return to its caller in a timely manner. + * + * @param context + * The execution context of the bundle being started. + * @throws Exception + * If this method throws an exception, this bundle is marked as + * stopped and the Framework will remove this bundle's + * listeners, unregister all services registered by this bundle, + * and release all services used by this bundle. + */ protected void startImpl(BundleContext context) { // NOOP } - + + /** + * Called when this bundle is stopped so the Framework can perform the + * bundle-specific activities necessary to stop the bundle. In general, this + * method should undo the work that the {@code BundleActivator.start} method + * started. There should be no active threads that were started by this + * bundle when this bundle returns. A stopped bundle must not call any + * Framework objects. + * + *

+ * This method must complete and return to its caller in a timely manner. + * + * @param context The execution context of the bundle being stopped. + * @throws Exception If this method throws an exception, the bundle is still + * marked as stopped, and the Framework will remove the bundle's + * listeners, unregister all services registered by the bundle, and + * release all services used by the bundle. + */ + protected void stopImpl(BundleContext context) { + // NOOP + } + + /** + * Bundle stop callback + * + * + * Custom implementation of bundle stop could be carried by overriding + * {@link #stopImpl(BundleContext)} method. + * + */ @Override public final void stop(BundleContext context) throws Exception { - - + stopImpl(context); } - + @Override public Collection getFunctionality() { - return null; + return Collections.emptySet(); } - + @Override public Collection getImplementations() { - return null; + return Collections.emptySet(); + } + + /** + * Initialization of consumer context. + * + * {@link ProviderContext} is replacement of {@link ConsumerContext} + * so this method is not needed in case of Provider. + * + */ + @Deprecated + @Override + public final void onSessionInitialized(ConsumerContext session) { + // NOOP } } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java index 14db6e5a32..84e0561b9f 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java @@ -7,9 +7,11 @@ */ package org.opendaylight.controller.sal.binding.api; +import org.opendaylight.controller.md.sal.common.api.routing.RoutedRegistration; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality; import org.opendaylight.controller.sal.binding.api.data.DataBrokerService; import org.opendaylight.controller.sal.binding.api.data.DataProviderService; +import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.binding.BaseIdentity; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; @@ -174,42 +176,43 @@ public interface BindingAwareBroker { RpcRegistration addRpcImplementation(Class type, T implementation) throws IllegalStateException; - RpcRegistration addMountRpcImplementation(Class type, - InstanceIdentifier mount, T implementation) throws IllegalStateException; + RpcRegistration addMountRpcImplementation(Class type, InstanceIdentifier mount, + T implementation) throws IllegalStateException; RoutedRpcRegistration addRoutedRpcImplementation(Class type, T implementation) throws IllegalStateException; - + void registerFunctionality(ProviderFunctionality functionality); + void unregisterFunctionality(ProviderFunctionality functionality); } - public interface RpcRegistration { + public interface RpcRegistration extends Registration { /** * * @return instance for which registration does exists. */ + @Deprecated T getService(); - - /** - * Unregister an RpcService from broker. - * - */ - void unregister(); } - public interface RoutedRpcRegistration extends RpcRegistration { + public interface RoutedRpcRegistration extends RpcRegistration, + RoutedRegistration, InstanceIdentifier, T> { /** * Register particular instance identifier to be processed by this * RpcService * + * Deprecated in favor of {@link RoutedRegistration#registerPath(Object, Object)}. + * * @param context * @param instance */ - void registerInstance(Class context, InstanceIdentifier instance); + @Deprecated + void registerInstance(Class context, InstanceIdentifier instance); - void unregisterInstance(Class context, InstanceIdentifier instance); + @Deprecated + void unregisterInstance(Class context, InstanceIdentifier instance); } } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java index 3641d76970..120674fa0d 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java @@ -28,8 +28,6 @@ import org.opendaylight.yangtools.yang.binding.RpcService; */ public interface BindingAwareProvider { - void onSessionInitialized(ConsumerContext session); - /** * Returns a set of provided implementations of YANG modules and their rpcs. * @@ -66,4 +64,6 @@ public interface BindingAwareProvider { void onSessionInitiated(ProviderContext session); + void onSessionInitialized(ConsumerContext session); + } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java index ccc73919b6..b3309b7a12 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationListener.java @@ -1,6 +1,17 @@ +/* + * 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.binding.api; -public interface NotificationListener { +import java.util.EventListener; + +import org.opendaylight.yangtools.yang.binding.Notification; + +public interface NotificationListener extends EventListener { void onNotification(T notification); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java index 7052ab0c45..64aab6ec0c 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationProviderService.java @@ -9,11 +9,29 @@ package org.opendaylight.controller.sal.binding.api; import java.util.concurrent.ExecutorService; +import org.opendaylight.controller.md.sal.common.api.notify.NotificationPublishService; +import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.binding.Notification; -public interface NotificationProviderService extends NotificationService { +public interface NotificationProviderService extends NotificationService, NotificationPublishService { + @Deprecated void notify(Notification notification); - + + @Deprecated void notify(Notification notification, ExecutorService service); + + @Override + void publish(Notification notification); + + @Override + void publish(Notification notification, ExecutorService service); + + @Override + public Registration> registerNotificationListener( + Class notificationType, NotificationListener listener); + + @Override + public Registration registerNotificationListener( + org.opendaylight.yangtools.yang.binding.NotificationListener listener); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java index 38bf7a196c..922acb9821 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/NotificationService.java @@ -7,12 +7,28 @@ */ package org.opendaylight.controller.sal.binding.api; +import org.opendaylight.controller.md.sal.common.api.notify.NotificationSubscriptionService; +import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.binding.Notification; public interface NotificationService extends BindingAwareService { + @Deprecated void addNotificationListener(Class notificationType, NotificationListener listener); + + @Deprecated void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener); + + @Deprecated void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener); + + @Deprecated void removeNotificationListener(Class notificationType, NotificationListener listener); + + Registration> registerNotificationListener( + Class notificationType, NotificationListener listener); + + + Registration registerNotificationListener( + org.opendaylight.yangtools.yang.binding.NotificationListener listener); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java index 7ee6c65a90..50ee740718 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataBrokerService.java @@ -9,6 +9,9 @@ package org.opendaylight.controller.sal.binding.api.data; import java.util.concurrent.Future; +import org.opendaylight.controller.md.sal.common.api.data.DataChangePublisher; +import org.opendaylight.controller.md.sal.common.api.data.DataModificationTransactionFactory; +import org.opendaylight.controller.md.sal.common.api.data.DataReader; import org.opendaylight.controller.sal.binding.api.BindingAwareService; import org.opendaylight.controller.sal.common.DataStoreIdentifier; import org.opendaylight.yangtools.yang.binding.DataObject; @@ -23,7 +26,11 @@ import org.opendaylight.yangtools.yang.common.RpcResult; * * @see DataProviderService */ -public interface DataBrokerService extends BindingAwareService { +public interface DataBrokerService extends // + BindingAwareService, // + DataModificationTransactionFactory, DataObject>, // + DataReader, DataObject>, // + DataChangePublisher, DataObject, DataChangeListener> { /** * Returns a data from specified Data Store. @@ -36,6 +43,7 @@ public interface DataBrokerService extends BindingAwareService { * Identifier of the store, from which will be data retrieved * @return data visible to the consumer */ + @Deprecated T getData(DataStoreIdentifier store, Class rootType); /** @@ -139,21 +147,22 @@ public interface DataBrokerService extends BindingAwareService { @Deprecated Future> commit(DataStoreIdentifier store); - - DataObject getData(InstanceIdentifier data); - - DataObject getConfigurationData(InstanceIdentifier data); + @Deprecated + DataObject getData(InstanceIdentifier data); - + @Deprecated + DataObject getConfigurationData(InstanceIdentifier data); /** * Creates a data modification transaction. * * @return new blank data modification transaction. */ - DataModification beginTransaction(); + DataModificationTransaction beginTransaction(); - public void registerChangeListener(InstanceIdentifier path, DataChangeListener changeListener); - - public void unregisterChangeListener(InstanceIdentifier path, DataChangeListener changeListener); + @Deprecated + public void registerChangeListener(InstanceIdentifier path, DataChangeListener changeListener); + + @Deprecated + public void unregisterChangeListener(InstanceIdentifier path, DataChangeListener changeListener); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataChangeEvent.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataChangeEvent.java deleted file mode 100644 index bbe328e199..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataChangeEvent.java +++ /dev/null @@ -1,16 +0,0 @@ -package org.opendaylight.controller.sal.binding.api.data; - -import java.util.Map; -import java.util.Set; - -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public interface DataChangeEvent { - - Map getCreated(); - - Map getUpdated(); - - Set getRemoved(); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataChangeListener.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataChangeListener.java index 63f9a9c7cc..6373cfbf4a 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataChangeListener.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataChangeListener.java @@ -1,8 +1,19 @@ +/* + * 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.binding.api.data; -public interface DataChangeListener { +import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - - void onDataChange(DataChangeEvent event); - +public interface DataChangeListener extends + org.opendaylight.controller.md.sal.common.api.data.DataChangeListener, DataObject> { + + @Override + public void onDataChanged(DataChangeEvent, DataObject> change); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataCommitHandler.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataCommitHandler.java deleted file mode 100644 index 5f550c222b..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataCommitHandler.java +++ /dev/null @@ -1,177 +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.binding.api.data; - -import java.util.Set; - -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality; -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; - -/** - * Two phase commit handler (cohort) of the two-phase commit protocol of data. - * - *

- * The provider should expose the implementation of DataCommitHandler if it's - * functionality depends on any subset of data stored in data repositories, in - * order to participate in {@link DataBrokerService#commit(DataStoreIdentifier) - * operation. - * - *

- * Operations of two-phase commit handlers should not change data in data store, - * this is responsibility of the coordinator (broker or some component of the - * broker). - * - * The commit handlers are responsible for changing the internal state of the - * provider to reflect the commited changes in data. - * - *

Two-phase commit

- * - *

Commit Request Phase

- * - *
    - *
  1. Consumer edits data by invocation of - * DataBrokerService.editCandidateData(DataStoreIdentifier, DataRoot) - *
  2. Consumer starts a commit by invoking - * DataBrokerService.commit(DataStoreIdentifier) - *
  3. Broker retrieves a list of all registered - * DataCommitHandlers - *
  4. For each DataCommitHandler - *
      - *
    1. Broker invokes a - * DataCommitHandler.requestCommit(DataStoreIdentifier) operation. - *
    2. DataCommitHandler returns a RpcResult with - * CommitTransaction - *
    3. If the result was successful, broker adds CommitTransaction - * to the list of opened transactions. If not, brokers stops a commit request - * phase and starts a rollback phase. - *
    - *
  5. Broker starts a commit finish phase - *
- * - *

Commit Finish Phase

- * - *
    - *
  1. For each CommitTransaction from Commit Request phase - *
      - *
    1. Broker broker invokes a - * CommitTransaction.finish() - *
    2. The provider finishes a commit (applies the change) and returns an - * RpcResult. - *
    - *
  2. - *
      - *
    • If all returned results means successful, the brokers end two-phase - * commit by returning a success commit result to the Consumer. - *
    • If error occured, the broker starts a commit rollback phase. - *
    - *
- * - *

Commit Rollback Phase

- *
  • For each CommitTransaction from Commit Request phase - *
      - *
    1. Broker - * broker invokes a {@link CommitTransaction#finish()} - *
    2. The provider rollbacks a commit and returns an {@link RpcResult} of - * rollback.
    - *
  • Broker returns a error result to the consumer. - * - * - *

    Registration of functionality

    - * The registration could be done by : - *
      - *
    • returning an instance of implementation in the return value of - * {@link Provider#getProviderFunctionality()} - *
    • passing an instance of implementation and {@link DataStoreIdentifier} of - * rpc as arguments to the - * {@link DataProviderService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)} - *
    - * - * - * - */ -public interface DataCommitHandler extends ProviderFunctionality { - /** - * A set of Data Stores supported by implementation. - * - * The set of {@link DataStoreIdentifier}s which identifies target data - * stores which are supported by this commit handler. This set is used, when - * {@link Provider} is registered to the SAL, to register and expose the - * commit handler functionality to affected data stores. - * - * @return Set of Data Store identifiers - */ - @Deprecated - Set getSupportedDataStores(); - - /** - * The provider (commit handler) starts a commit transaction. - * - *

    - * The commit handler (provider) prepares an commit scenario, rollback - * scenario and validates data. - * - *

    - * If the provider is aware that at this point the commit would not be - * successful, the transaction is not created, but list of errors which - * prevented the start of transaction are returned. - * - * @param store - * @return Transaction object representing this commit, errors otherwise. - */ - @Deprecated - RpcResult requestCommit(DataStoreIdentifier store); - - - RpcResult requestCommit(DataModification modification); - - public interface CommitTransaction { - /** - * - * @return Data store affected by the transaction - */ - @Deprecated - DataStoreIdentifier getDataStore(); - - /** - * Returns a modification transaction which is the source of this - * commit transaction. - * - */ - DataModification getModification(); - - /** - * Returns the handler associated with this transaction. - * - * @return Handler - */ - DataCommitHandler getHandler(); - - /** - * - * Finishes a commit. - * - * The provider (commit handler) should apply all changes to its state - * which are a result of data change- - * - * @return - */ - RpcResult finish() throws IllegalStateException; - - /** - * Rollbacks a commit. - * - * @return - * @throws IllegalStateException - * If the method is invoked after {@link #finish()} - */ - RpcResult rollback() throws IllegalStateException; - } - -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModification.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModification.java deleted file mode 100644 index 4506caf94b..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModification.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.opendaylight.controller.sal.binding.api.data; - -import java.util.Map; -import java.util.Set; -import java.util.concurrent.Future; - -import org.opendaylight.yangtools.yang.binding.DataObject; -import org.opendaylight.yangtools.yang.binding.Identifiable; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcResult; - -public interface DataModification { - - /** - * Returns transaction identifier - * - * @return Transaction identifier - */ - Object getIdentifier(); - - TransactionStatus getStatus(); - - /** - * Reads data from overal data storage which includes - * runtime and configuration data. - * - * @param path - * @return - */ - DataObject read(InstanceIdentifier path); - - /** - * Reads data from configuration data storage. - * - * @param path Instance identifier which - * @return - */ - DataObject readConfiguration(InstanceIdentifier path); - - void putRuntimeData(InstanceIdentifier path,DataObject data); - void putConfigurationData(InstanceIdentifier path,DataObject data); - void removeRuntimeData(InstanceIdentifier path); - void removeConfigurationData(InstanceIdentifier path); - - - Map getRuntimeDataUpdates(); - Map getConfigurationDataUpdates(); - Set getRemovals(); - Set getConfigurationRemovals(); - - /** - * Commits transaction to be stored in global data repository. - * - * - * @return Future object which returns RpcResult with TransactionStatus - * when transaction is processed by store. - */ - Future> commit(); - - void registerListener(DataTransactionListener listener); - void unregisterListener(DataTransactionListener listener); - - public enum TransactionStatus { - - UNSUBMITTED, - COMMITING, - COMMITED, - FAILED, - CANCELED - } - - public interface DataTransactionListener { - - void onStatusUpdated(DataModification transaction,TransactionStatus status); - - } -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModificationTransaction.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModificationTransaction.java new file mode 100644 index 0000000000..4f69f0b38a --- /dev/null +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataModificationTransaction.java @@ -0,0 +1,31 @@ +/* + * 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.binding.api.data; + +import java.util.EventListener; + +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +import org.opendaylight.controller.md.sal.common.api.data.DataModification; +import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public interface DataModificationTransaction extends DataModification, DataObject> { + + ListenerRegistration registerListener(DataTransactionListener listener); + + + //FIXME: After 0.6 Release of YANG-Binding + //public T readOperationalData(InstanceIdentifier path); + //public T readConfigurationData(InstanceIdentifier path); + + public interface DataTransactionListener extends EventListener { + void onStatusUpdated(DataModificationTransaction transaction,TransactionStatus status); + } +} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataProviderService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataProviderService.java index 1057c3039e..32b1d933cf 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataProviderService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataProviderService.java @@ -7,73 +7,13 @@ */ package org.opendaylight.controller.sal.binding.api.data; -import java.util.Map; -import java.util.Set; +import org.opendaylight.controller.md.sal.common.api.data.DataProvisionService; import org.opendaylight.controller.sal.common.DataStoreIdentifier; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public interface DataProviderService extends DataBrokerService { - /** - * Adds {@link DataValidator} for specified Data Store - * - * @param store - * Data Store - * @param validator - * Validator - */ - @Deprecated - public void addValidator(DataStoreIdentifier store, DataValidator validator); - - /** - * Removes {@link DataValidator} from specified Data Store - * - * @param store - * @param validator - * Validator - */ - - @Deprecated - public void removeValidator(DataStoreIdentifier store, DataValidator validator); - - /** - * Adds {@link DataCommitHandler} for specified data store - * - * @param store - * @param provider - */ - @Deprecated - void addCommitHandler(DataStoreIdentifier store, DataCommitHandler provider); - - /** - * Removes {@link DataCommitHandler} from specified data store - * - * @param store - * @param provider - */ - @Deprecated - void removeCommitHandler(DataStoreIdentifier store, DataCommitHandler provider); - - /** - * Adds {@link DataRefresher} for specified data store - * - * @param store - * @param refresher - */ - void addRefresher(DataStoreIdentifier store, DataRefresher refresher); - - /** - * Removes {@link DataRefresher} from specified data store - * - * @param store - * @param refresher - */ - void removeRefresher(DataStoreIdentifier store, DataRefresher refresher); - - public void registerCommitHandler(InstanceIdentifier path, DataCommitHandler commitHandler); - - public void registerValidator(InstanceIdentifier path, DataValidator validator); +public interface DataProviderService extends DataBrokerService, DataProvisionService, DataObject> { } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataValidator.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataValidator.java deleted file mode 100644 index 8099600828..0000000000 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/DataValidator.java +++ /dev/null @@ -1,18 +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.binding.api.data; - -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality; -import org.opendaylight.yangtools.yang.binding.DataRoot; -import org.opendaylight.yangtools.yang.common.RpcResult; - -public interface DataValidator extends ProviderFunctionality { - - RpcResult validate(DataRoot data); -} diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java index 68a2b29342..f7116594ff 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/data/RuntimeDataProvider.java @@ -1,56 +1,23 @@ +/* + * 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.binding.api.data; import java.util.Set; +import org.opendaylight.controller.md.sal.common.api.data.DataReader; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality; import org.opendaylight.controller.sal.common.DataStoreIdentifier; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.DataRoot; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -public interface RuntimeDataProvider extends ProviderFunctionality { - - Set getSupportedStores(); - - - Set> getProvidedDataRoots(); +public interface RuntimeDataProvider extends ProviderFunctionality,DataReader, DataObject> { - /** - * Returns a data from specified Data Store. - * - * Returns all the data visible to the consumer from specified Data Store. - * - * @param - * Interface generated from YANG module representing root of data - * @param store - * Identifier of the store, from which will be data retrieved - * @return data visible to the consumer - */ - T getData(DataStoreIdentifier store, Class rootType); - /** - * Returns a filtered subset of data from specified Data Store. - * - *

    - * The filter is modeled as an hierarchy of Java TOs starting with - * implementation of {@link DataRoot} representing data root. The semantics - * of the filter tree is the same as filter semantics defined in the NETCONF - * protocol for rpc operations get and get-config - * in Section 6 of RFC6241. - * - * - * @see http://tools.ietf.org/html/rfc6241#section-6 - * @param - * Interface generated from YANG module representing root of data - * @param store - * Identifier of the store, from which will be data retrieved - * @param filter - * Data tree filter similar to the NETCONF filter - * @return - */ - T getData(DataStoreIdentifier store, T filter); - - - T getData(Class dataType, InstanceIdentifier identifier); } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountInstance.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountInstance.java index a37b14f777..b926e953b8 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountInstance.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountInstance.java @@ -14,5 +14,5 @@ import org.opendaylight.yangtools.yang.binding.RpcService; public interface MountInstance extends NotificationService, DataBrokerService { T getRpcService(Class rpcService); - + } diff --git a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountService.java b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountService.java index 9fa918f6f4..1644c4029b 100644 --- a/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountService.java +++ b/opendaylight/md-sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/mount/MountService.java @@ -12,6 +12,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public interface MountService extends BindingAwareService { - MountInstance getMountPoint(InstanceIdentifier path); + MountInstance getMountPoint(InstanceIdentifier path); } diff --git a/opendaylight/md-sal/sal-binding-broker/pom.xml b/opendaylight/md-sal/sal-binding-broker/pom.xml index e0721dffdf..34c56435d5 100644 --- a/opendaylight/md-sal/sal-binding-broker/pom.xml +++ b/opendaylight/md-sal/sal-binding-broker/pom.xml @@ -52,6 +52,11 @@ sal-common-util 1.0-SNAPSHOT + + org.opendaylight.controller + sal-common-impl + 1.0-SNAPSHOT + org.opendaylight.controller sal-binding-api diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java index 9f7e05cbbf..0d78109a69 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeGenerator.java @@ -1,3 +1,10 @@ +/* + * 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.binding.codegen; import org.opendaylight.controller.sal.binding.spi.DelegateProxy; diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend index 6bdb3c8fbe..2e73977804 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/RuntimeCodeHelper.xtend @@ -45,16 +45,16 @@ class RuntimeCodeHelper { throw new IllegalArgumentException("delegate class is not assignable to proxy"); } - public static def Map getRoutingTable(RpcService target, + public static def Map, ? extends RpcService> getRoutingTable(RpcService target, Class tableClass) { val field = target.class.getField(tableClass.routingTableField) if (field == null) throw new UnsupportedOperationException( "Unable to get routing table. Table field does not exists"); - return field.get(target) as Map; + return field.get(target) as Map, ? extends RpcService>; } public static def void setRoutingTable(RpcService target, Class tableClass, - Map routingTable) { + Map, ? extends RpcService> routingTable) { val field = target.class.getField(tableClass.routingTableField) if (field == null) throw new UnsupportedOperationException( "Unable to set routing table. Table field does not exists"); diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.xtend index 522102bdf1..6481c9d1b4 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/codegen/impl/BrokerImplClassLoader.xtend @@ -1,3 +1,10 @@ +/* + * 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.binding.codegen.impl import java.lang.ClassLoader diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend index 8a3d2c0ecc..ff8cefe01c 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingAwareBrokerImpl.xtend @@ -39,6 +39,7 @@ class BindingAwareBrokerImpl implements BindingAwareBroker { private var RuntimeCodeGenerator generator; private Map, RpcProxyContext> managedProxies = new HashMap(); private var NotificationBrokerImpl notifyBroker + private var DataBrokerImpl dataBroker private var ServiceRegistration notifyBrokerRegistration @Property @@ -126,7 +127,7 @@ class BindingAwareBrokerImpl implements BindingAwareBroker { return new RpcServiceRegistrationImpl(type, service, osgiReg); } - def RpcRegistration registerMountedRpcImplementation(Class tyoe, T service, InstanceIdentifier identifier, + def RpcRegistration registerMountedRpcImplementation(Class tyoe, T service, InstanceIdentifier identifier, OsgiProviderContext context, Hashtable properties) { throw new UnsupportedOperationException("TODO: auto-generated method stub") } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BrokerActivator.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BrokerActivator.java index c5d54ecba9..9a5cbfffcd 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BrokerActivator.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/BrokerActivator.java @@ -18,28 +18,27 @@ import org.slf4j.LoggerFactory; public class BrokerActivator implements BundleActivator { - private static final Logger log = LoggerFactory.getLogger(BrokerActivator.class); - private BindingAwareBrokerImpl baSal; - private ServiceRegistration baSalRegistration; - - - @Override - public void start(BundleContext context) throws Exception { - log.info("Binding Aware Broker initialized"); - baSal = new BindingAwareBrokerImpl(); - baSal.setBrokerBundleContext(context); - baSal.start(); - - BindingAwareBroker baSalService = baSal; - Hashtable properties = new Hashtable<>(); - this.baSalRegistration = context.registerService(BindingAwareBroker.class,baSalService, properties); - - } - - @Override - public void stop(BundleContext context) throws Exception { - log.info("Binding Aware Broker stopped"); - baSalRegistration.unregister(); - } + private static final Logger log = LoggerFactory.getLogger(BrokerActivator.class); + private BindingAwareBrokerImpl baSal; + private ServiceRegistration baSalRegistration; + + @Override + public void start(BundleContext context) throws Exception { + log.info("Binding Aware Broker initialized"); + baSal = new BindingAwareBrokerImpl(); + baSal.setBrokerBundleContext(context); + baSal.start(); + + BindingAwareBroker baSalService = baSal; + Hashtable properties = new Hashtable<>(); + this.baSalRegistration = context.registerService(BindingAwareBroker.class, baSalService, properties); + + } + + @Override + public void stop(BundleContext context) throws Exception { + log.info("Binding Aware Broker stopped"); + baSalRegistration.unregister(); + } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.xtend new file mode 100644 index 0000000000..99afbab0b5 --- /dev/null +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/DataBrokerImpl.xtend @@ -0,0 +1,67 @@ +package org.opendaylight.controller.sal.binding.impl + +import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler +import org.opendaylight.controller.sal.binding.api.data.DataChangeListener +import org.opendaylight.controller.sal.binding.api.data.DataProviderService +import org.opendaylight.controller.sal.common.DataStoreIdentifier +import org.opendaylight.yangtools.yang.binding.DataObject +import org.opendaylight.yangtools.yang.binding.DataRoot +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier + +class DataBrokerImpl implements DataProviderService { + + override beginTransaction() { + } + + override commit(DataStoreIdentifier store) { + throw new UnsupportedOperationException("Deprecated") + } + + override editCandidateData(DataStoreIdentifier store, DataRoot changeSet) { + throw new UnsupportedOperationException("Deprecated") + } + + override getCandidateData(DataStoreIdentifier store, Class rootType) { + throw new UnsupportedOperationException("Deprecated") + } + + override T getCandidateData(DataStoreIdentifier store, T filter) { + throw new UnsupportedOperationException("Deprecated") + } + + override getConfigurationData(InstanceIdentifier data) { + throw new UnsupportedOperationException("Deprecated") + } + + override getData(DataStoreIdentifier store, Class rootType) { + throw new UnsupportedOperationException("Deprecated") + } + + override T getData(DataStoreIdentifier store, T filter) { + throw new UnsupportedOperationException("Deprecated") + } + + override getData(InstanceIdentifier path) { + return readOperationalData(path); + } + + override readConfigurationData(InstanceIdentifier path) { + } + + override readOperationalData(InstanceIdentifier path) { + } + + override registerChangeListener(InstanceIdentifier path, DataChangeListener changeListener) { + } + + override registerCommitHandler(InstanceIdentifier path, + DataCommitHandler, DataObject> commitHandler) { + } + + override registerDataChangeListener(InstanceIdentifier path, DataChangeListener listener) { + } + + override unregisterChangeListener(InstanceIdentifier path, DataChangeListener changeListener) { + } + +} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend index 8b0400f512..377d12ecac 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationBrokerImpl.xtend @@ -14,6 +14,7 @@ import org.opendaylight.controller.sal.binding.api.NotificationListener import com.google.common.collect.HashMultimap import java.util.concurrent.ExecutorService import java.util.Collection +import org.opendaylight.yangtools.concepts.Registration class NotificationBrokerImpl implements NotificationProviderService { @@ -36,9 +37,7 @@ class NotificationBrokerImpl implements NotificationProviderService { } override notify(Notification notification) { - notification.notificationTypes.forEach [ - listeners.get(it as Class)?.notifyAll(notification) - ] + publish(notification) } def getNotificationTypes(Notification notification) { @@ -49,17 +48,65 @@ class NotificationBrokerImpl implements NotificationProviderService { def notifyAll(Collection> listeners, Notification notification) { listeners.forEach[(it as NotificationListener).onNotification(notification)] } - + override addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { throw new UnsupportedOperationException("TODO: auto-generated method stub") - + } - + override removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) { throw new UnsupportedOperationException("TODO: auto-generated method stub") } - + override notify(Notification notification, ExecutorService service) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") + publish(notification) + } + + override publish(Notification notification) { + notification.notificationTypes.forEach [ + listeners.get(it as Class)?.notifyAll(notification) + ] + } + + override publish(Notification notification, ExecutorService service) { + publish(notification) + } + + override registerNotificationListener(Class notificationType, + NotificationListener listener) { + val reg = new GenericNotificationRegistration(notificationType,listener,this); + listeners.put(notificationType,listener); + return reg; + } + + override registerNotificationListener( + org.opendaylight.yangtools.yang.binding.NotificationListener listener) { + + } + + + protected def unregisterListener(GenericNotificationRegistration reg) { + listeners.remove(reg.type,reg.instance); + } +} +class GenericNotificationRegistration implements Registration> { + + @Property + var NotificationListener instance; + + @Property + val Class type; + + + val NotificationBrokerImpl notificationBroker; + + public new(Class type, NotificationListener instance,NotificationBrokerImpl broker) { + _instance = instance; + _type = type; + notificationBroker = broker; + } + + override close() { + notificationBroker.unregisterListener(this); } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend index 494118b694..29c3845004 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/OsgiProviderContext.xtend @@ -43,7 +43,7 @@ class OsgiProviderContext extends OsgiConsumerContext implements ProviderContext return salReg; } - override addMountRpcImplementation(Class type, InstanceIdentifier mount, T implementation) throws IllegalStateException { + override addMountRpcImplementation(Class type, InstanceIdentifier mount, T implementation) throws IllegalStateException { val properties = new Hashtable(); properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcServiceRegistrationImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcServiceRegistrationImpl.xtend index 5b31b5f50d..31694719bb 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcServiceRegistrationImpl.xtend +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/RpcServiceRegistrationImpl.xtend @@ -26,8 +26,12 @@ class RpcServiceRegistrationImpl implements RpcRegistratio override getService() { this.service } + + override getInstance() { + this.service + } - override unregister() { + override close() { throw new UnsupportedOperationException("TODO: auto-generated method stub") } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/_DataBrokerImpl.xtend b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/_DataBrokerImpl.xtend deleted file mode 100644 index 59751443f2..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/impl/_DataBrokerImpl.xtend +++ /dev/null @@ -1,108 +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.binding.impl - -import org.opendaylight.controller.sal.binding.api.data.DataBrokerService -import org.opendaylight.controller.sal.common.DataStoreIdentifier -import org.opendaylight.yangtools.yang.binding.DataRoot -import org.opendaylight.controller.sal.binding.api.data.DataProviderService -import org.opendaylight.controller.sal.binding.api.data.DataCommitHandler -import org.opendaylight.controller.sal.binding.api.data.DataRefresher -import org.opendaylight.controller.sal.binding.api.data.DataValidator -import org.opendaylight.yangtools.yang.common.RpcResult -import org.opendaylight.controller.sal.binding.api.data.RuntimeDataProvider -import java.util.Map -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier -import org.opendaylight.controller.sal.binding.api.data.DataChangeListener - -class _DataBrokerImpl implements DataProviderService { - - Map dataProviders; - var DataProviderContext defaultDataProvider; - - override getData(DataStoreIdentifier store, Class rootType) { - val dataStore = resolveProvider(store, rootType); - return dataStore.provider.getData(store, rootType); - } - - override getData(DataStoreIdentifier store, T filter) { - } - - override T getCandidateData(DataStoreIdentifier store, Class rootType) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - override T getCandidateData(DataStoreIdentifier store, T filter) { - throw new UnsupportedOperationException("TODO: auto-generated method stub"); - } - - override commit(DataStoreIdentifier store) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override editCandidateData(DataStoreIdentifier store, DataRoot changeSet) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override addCommitHandler(DataStoreIdentifier store, DataCommitHandler provider) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override addRefresher(DataStoreIdentifier store, DataRefresher refresher) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override addValidator(DataStoreIdentifier store, DataValidator validator) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override removeRefresher(DataStoreIdentifier store, DataRefresher refresher) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override removeCommitHandler(DataStoreIdentifier store, DataCommitHandler provider) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - - } - - override removeValidator(DataStoreIdentifier store, DataValidator validator) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - def DataProviderContext resolveProvider(DataStoreIdentifier store, Class root) { - } - - override beginTransaction() { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override getConfigurationData(InstanceIdentifier data) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override getData(InstanceIdentifier data) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override registerCommitHandler(InstanceIdentifier path, DataCommitHandler commitHandler) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override registerValidator(InstanceIdentifier path, DataValidator validator) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override registerChangeListener(InstanceIdentifier path, DataChangeListener changeListener) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - - override unregisterChangeListener(InstanceIdentifier path, DataChangeListener changeListener) { - throw new UnsupportedOperationException("TODO: auto-generated method stub") - } - -} diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java index 085228c966..e34ee28a31 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/DelegateProxy.java @@ -1,3 +1,10 @@ +/* + * 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.binding.spi; public interface DelegateProxy { diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRouter.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRouter.java index 360f039366..b7a42eda1f 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRouter.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRouter.java @@ -1,3 +1,10 @@ +/* + * 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.binding.spi; import org.opendaylight.yangtools.yang.binding.BaseIdentity; @@ -44,7 +51,7 @@ public interface RpcRouter { * @return instance of RpcService which is responsible for processing * particular path. */ - T getService(Class context, InstanceIdentifier path); + T getService(Class context, InstanceIdentifier path); /** * Returns a default fallback instance of RpcService which is responsible diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingTable.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingTable.java index f2d38256c9..4d9d51b133 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingTable.java +++ b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/RpcRoutingTable.java @@ -1,38 +1,52 @@ +/* + * 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.binding.spi; import java.util.Map; +import org.opendaylight.controller.md.sal.common.api.routing.MutableRoutingTable; import org.opendaylight.yangtools.yang.binding.BaseIdentity; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.RpcService; -public interface RpcRoutingTable { +public interface RpcRoutingTable extends + MutableRoutingTable, InstanceIdentifier, S> { + + Class getIdentifier(); - Class getContextIdentifier(); - /** - * Updates route for particular path to specified instance of {@link RpcService}. + * Updates route for particular path to specified instance of + * {@link RpcService}. * - * @param path Path for which RpcService routing is to be updated - * @param service Instance of RpcService which is responsible for processing Rpc Requests. + * @param path + * Path for which RpcService routing is to be updated + * @param service + * Instance of RpcService which is responsible for processing Rpc + * Requests. */ - void updateRoute(InstanceIdentifier path,S service); - + void updateRoute(InstanceIdentifier path, S service); + /** * Deletes a route for particular path * - * @param path Path for which + * @param path + * Path for which */ - void deleteRoute(InstanceIdentifier path); - + void removeRoute(InstanceIdentifier path); + /** * */ - S getService(InstanceIdentifier nodeInstance); - + S getRoute(InstanceIdentifier nodeInstance); + /** * * @return */ - Map getRoutes(); + Map, S> getRoutes(); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/package-info.java b/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/package-info.java deleted file mode 100644 index 774571b545..0000000000 --- a/opendaylight/md-sal/sal-binding-broker/src/main/java/org/opendaylight/controller/sal/binding/spi/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -/** - * - */ -/** - * @author ttkacik - * - */ -package org.opendaylight.controller.sal.binding.spi; \ No newline at end of file diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java index 5dddd1ab9d..b483d35739 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java @@ -9,7 +9,9 @@ import javassist.ClassPool; import org.junit.Before; import org.junit.Test; + import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*; + import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator; import org.opendaylight.controller.sal.binding.test.mock.FooService; import org.opendaylight.controller.sal.binding.test.mock.ReferencableObject; @@ -17,6 +19,7 @@ import org.opendaylight.controller.sal.binding.test.mock.ReferencableObjectKey; import org.opendaylight.controller.sal.binding.test.mock.SimpleInput; import org.opendaylight.yangtools.yang.binding.Augmentation; import org.opendaylight.yangtools.yang.binding.BaseIdentity; +import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; @@ -51,7 +54,7 @@ public class RuntimeCodeGeneratorTest { } private void verifyRouting(FooService product) { - Map routingTable = new HashMap<>(); + Map,FooService> routingTable = new HashMap<>(); setRoutingTable(product, BaseIdentity.class, routingTable); assertSame("Returned routing table should be same instance",routingTable,getRoutingTable(product, BaseIdentity.class)); @@ -59,14 +62,14 @@ public class RuntimeCodeGeneratorTest { int servicesCount = 2; int instancesPerService = 3; - InstanceIdentifier[][] identifiers = identifiers(servicesCount,instancesPerService); + InstanceIdentifier[][] identifiers = identifiers(servicesCount,instancesPerService); FooService service[] = new FooService[] { mock(FooService.class, "Instance 0"), mock(FooService.class,"Instance 1") }; for(int i = 0;i instance : identifiers[i]) { routingTable.put(instance, service[i]); } } @@ -100,12 +103,12 @@ public class RuntimeCodeGeneratorTest { verify(service[1]).simple(instance_1_input[0]); } - private InstanceIdentifier[][] identifiers(int serviceSize, int instancesPerService) { - InstanceIdentifier[][] ret = new InstanceIdentifier[serviceSize][]; + private InstanceIdentifier[][] identifiers(int serviceSize, int instancesPerService) { + InstanceIdentifier[][] ret = new InstanceIdentifier[serviceSize][]; int service = 0; for (int i = 0;i[] instanceIdentifiers = new InstanceIdentifier[instancesPerService]; ret[i] = instanceIdentifiers; for(int id = 0;id referencableIdentifier(int i) { ReferencableObjectKey key = new ReferencableObjectKey(i); IdentifiableItem pathArg = new IdentifiableItem<>(ReferencableObject.class,key); - return new InstanceIdentifier(Arrays.asList(pathArg), ReferencableObject.class); + return new InstanceIdentifier(Arrays.asList(pathArg), ReferencableObject.class); } private static class SimpleInputImpl implements SimpleInput { - private final InstanceIdentifier identifier; + private final InstanceIdentifier identifier; - public SimpleInputImpl(InstanceIdentifier _identifier) { + public SimpleInputImpl(InstanceIdentifier _identifier) { this.identifier = _identifier; } @@ -135,7 +138,7 @@ public class RuntimeCodeGeneratorTest { } @Override - public InstanceIdentifier getIdentifier() { + public InstanceIdentifier getIdentifier() { return this.identifier; } } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java index 86624e0732..2fa89ab7f8 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/Grouping.java @@ -7,5 +7,5 @@ import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext; public interface Grouping { @RoutingContext(BaseIdentity.class) - InstanceIdentifier getInheritedIdentifier(); + InstanceIdentifier getInheritedIdentifier(); } diff --git a/opendaylight/md-sal/sal-common-api/pom.xml b/opendaylight/md-sal/sal-common-api/pom.xml index 280d5ec188..0ce8520824 100644 --- a/opendaylight/md-sal/sal-common-api/pom.xml +++ b/opendaylight/md-sal/sal-common-api/pom.xml @@ -14,11 +14,6 @@ - - org.opendaylight.yangtools - concepts - 0.1.0 - org.opendaylight.controller sal-common @@ -28,10 +23,16 @@ org.opendaylight.yangtools yang-common + + org.opendaylight.yangtools + concepts + 0.1.1-SNAPSHOT + org.osgi org.osgi.core 5.0.0 + bundle diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/TransactionStatus.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/TransactionStatus.java new file mode 100644 index 0000000000..92ff55175c --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/TransactionStatus.java @@ -0,0 +1,16 @@ +/* + * 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.md.sal.common.api; + +public enum TransactionStatus { + NEW, + SUBMITED, + COMMITED, + FAILED, + CANCELED +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChange.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChange.java new file mode 100644 index 0000000000..0fea50b777 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChange.java @@ -0,0 +1,31 @@ +/* + * 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.md.sal.common.api.data; + +import java.util.Map; +import java.util.Set; + +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; + + +public interface DataChange

    */,D> { + + Map getCreatedOperationalData(); + + Map getUpdatedOperationalData(); + + Set

    getRemovedOperationalData(); + + Map getCreatedConfigurationData(); + + Map getUpdatedConfigurationData(); + + Set

    getRemovedConfigurationData(); + +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangeEvent.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangeEvent.java new file mode 100644 index 0000000000..5905413745 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangeEvent.java @@ -0,0 +1,14 @@ +/* + * 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.md.sal.common.api.data; + +import org.opendaylight.yangtools.concepts.Immutable; + +public interface DataChangeEvent extends DataChange, Immutable { + +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangeListener.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangeListener.java new file mode 100644 index 0000000000..8b87139c7f --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangeListener.java @@ -0,0 +1,18 @@ +/* + * 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.md.sal.common.api.data; + +import java.util.EventListener; + +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; + +public interface DataChangeListener

    */,D> extends EventListener { + + void onDataChanged(DataChangeEvent change); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangePublisher.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangePublisher.java new file mode 100644 index 0000000000..1700411df8 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataChangePublisher.java @@ -0,0 +1,20 @@ +/* + * 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.md.sal.common.api.data; + + +import org.opendaylight.yangtools.concepts.ListenerRegistration; +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; +import org.opendaylight.yangtools.concepts.Registration; + +public interface DataChangePublisher

    */,D, L extends DataChangeListener> { + + ListenerRegistration registerDataChangeListener(P path, L listener); + +} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataCommitHandler.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataCommitHandler.java similarity index 60% rename from opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataCommitHandler.java rename to opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataCommitHandler.java index fc1894a3d9..85e3d8f57c 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataCommitHandler.java +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataCommitHandler.java @@ -5,15 +5,12 @@ * 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.data; - -import java.util.Set; +package org.opendaylight.controller.md.sal.common.api.data; import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.core.api.Provider; +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; import org.opendaylight.yangtools.yang.common.RpcResult; - - /** * Two phase commit handler (cohort) of the two-phase commit protocol of data. * @@ -37,7 +34,7 @@ import org.opendaylight.yangtools.yang.common.RpcResult; * *

      *
    1. Consumer edits data by invocation of - * DataBrokerService.editCandidateData(DataStoreIdentifier, CompositeNodeModification) + * DataBrokerService.editCandidateData(DataStoreIdentifier, DataRoot) *
    2. Consumer starts a commit by invoking * DataBrokerService.commit(DataStoreIdentifier) *
    3. Broker retrieves a list of all registered @@ -74,77 +71,35 @@ import org.opendaylight.yangtools.yang.common.RpcResult; *
    * *

    Commit Rollback Phase

    - *
  • For each CommitTransaction from Commit Request phase + *
  • For each DataCommitTransaction from Commit Request phase *
      *
    1. Broker - * - * broker invokes a {@link CommitTransaction#finish()} + * broker invokes a {@link DataCommitTransaction#finish()} *
    2. The provider rollbacks a commit and returns an {@link RpcResult} of * rollback.
    *
  • Broker returns a error result to the consumer. * - * - *

    Registration of functionality

    - * The registration could be done by : - *
      - *
    • returning an instance of implementation in the return value of - * {@link Provider#getProviderFunctionality()} - *
    • passing an instance of implementation and {@link DataStoreIdentifier} of - * rpc as arguments to the - * {@link DataProviderService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)} - *
    - * - * + * @param

    Class representing a path + * @param Superclass from which all data objects are derived from. */ -public interface DataCommitHandler extends Provider.ProviderFunctionality { +public interface DataCommitHandler

    */,D> { - /** - * A set of Data Stores supported by implementation. - * - * The set of {@link DataStoreIdentifier}s which identifies target data - * stores which are supported by this commit handler. This set is used, when - * {@link Provider} is registered to the SAL, to register and expose the - * commit handler functionality to affected data stores. - * - * @return Set of Data Store identifiers - */ - Set getSupportedDataStores(); - /** - * The provider (commit handler) starts a commit transaction. - * - *

    - * The commit handler (provider) prepares an commit scenario, rollback - * scenario and validates data. - * - *

    - * If the provider is aware that at this point the commit would not be - * successful, the transaction is not created, but list of errors which - * prevented the start of transaction are returned. - * - * @param store - * @return Transaction object representing this commit, errors otherwise. - */ - RpcResult requestCommit(DataStoreIdentifier store); + DataCommitTransaction requestCommit(DataModification modification); - public interface CommitTransaction { - /** - * - * @return Data store affected by the transaction - */ - DataStoreIdentifier getDataStore(); + public interface DataCommitTransaction

    */,D> { - /** - * Returns the handler associated with this transaction. - * - * @return Handler - */ - DataCommitHandler getHandler(); + DataModification getModification(); /** * * Finishes a commit. * + * This callback is invoked by commit coordinator to finish commit action. + * + * The implementation is required to finish transaction or return unsuccessful + * rpc result if something went wrong. + * * The provider (commit handler) should apply all changes to its state * which are a result of data change- * @@ -155,10 +110,16 @@ public interface DataCommitHandler extends Provider.ProviderFunctionality { /** * Rollbacks a commit. * + * This callback is invoked by commit coordinator to finish commit action. + * + * The provider (commit handler) should rollback all changes to its state + * which were a result of previous request commit. + * * @return * @throws IllegalStateException * If the method is invoked after {@link #finish()} */ RpcResult rollback() throws IllegalStateException; } + } diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataModification.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataModification.java new file mode 100644 index 0000000000..1ab7c34589 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataModification.java @@ -0,0 +1,71 @@ +/* + * 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.md.sal.common.api.data; + +import java.util.Map; +import java.util.Set; +import java.util.concurrent.Future; + +import org.opendaylight.controller.md.sal.common.api.TransactionStatus; +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; +import org.opendaylight.yangtools.yang.common.RpcResult; + +public interface DataModification

    */, D> extends DataReader { + + /** + * Returns transaction identifier + * + * @return Transaction identifier + */ + Object getIdentifier(); + + TransactionStatus getStatus(); + + void putRuntimeData(P path, D data); + + void putConfigurationData(P path, D data); + + void removeRuntimeData(P path); + + void removeConfigurationData(P path); + + public Map getUpdatedConfigurationData(); + + public Map getUpdatedOperationalData(); + + public Set

    getRemovedConfigurationData(); + + public Set

    getRemovedOperationalData(); + + /** + * Initiates a two-phase commit of modification. + * + *

    + * The successful commit changes the state of the system and may affect + * several components. + * + *

    + * The effects of successful commit of data are described in the + * specifications and YANG models describing the Provider components of + * controller. It is assumed that Consumer has an understanding of this + * changes. + * + * + * @see DataCommitHandler for further information how two-phase commit is + * processed. + * @param store + * Identifier of the store, where commit should occur. + * @return Result of the Commit, containing success information or list of + * encountered errors, if commit was not successful. The Future + * blocks until {@link TransactionStatus#COMMITED} or + * {@link TransactionStatus#FAILED} is reached. + */ + Future> commit(); + +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataModificationTransactionFactory.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataModificationTransactionFactory.java new file mode 100644 index 0000000000..64d90f6fd5 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataModificationTransactionFactory.java @@ -0,0 +1,16 @@ +/* + * 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.md.sal.common.api.data; + +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; + +public interface DataModificationTransactionFactory

    */,D> { + + DataModification beginTransaction(); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvider.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvider.java new file mode 100644 index 0000000000..6c108bf5e4 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvider.java @@ -0,0 +1,15 @@ +/* + * 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.md.sal.common.api.data; + +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; + +public interface DataProvider

    */,D> extends DataReader { + +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvisionService.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvisionService.java new file mode 100644 index 0000000000..264d076b69 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataProvisionService.java @@ -0,0 +1,19 @@ +/* + * 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.md.sal.common.api.data; + +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; +import org.opendaylight.yangtools.concepts.Registration; + + +public interface DataProvisionService

    */, D> { + + public Registration> registerCommitHandler(P path, DataCommitHandler commitHandler); + +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataReader.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataReader.java new file mode 100644 index 0000000000..ff1703f181 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/data/DataReader.java @@ -0,0 +1,24 @@ +/* + * 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.md.sal.common.api.data; + +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; + +public interface DataReader

    */,D> { + + /** + * Reads data from Operational data store located at provided path + * + * @param path Path to data + * @return + */ + D readOperationalData(P path); + + D readConfigurationData(P path); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java new file mode 100644 index 0000000000..6a906c5b88 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationPublishService.java @@ -0,0 +1,17 @@ +/* + * 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.md.sal.common.api.notify; + +import java.util.concurrent.ExecutorService; + +public interface NotificationPublishService { + + void publish(N notification); + + void publish(N notification,ExecutorService executor); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationSubscriptionService.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationSubscriptionService.java new file mode 100644 index 0000000000..bfca8f8bcc --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/notify/NotificationSubscriptionService.java @@ -0,0 +1,15 @@ +/* + * 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.md.sal.common.api.notify; + +import org.opendaylight.yangtools.concepts.Registration; + +public interface NotificationSubscriptionService { + + Registration registerNotificationListener(T type,L listener); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/MutableRoutingTable.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/MutableRoutingTable.java new file mode 100644 index 0000000000..1139d03357 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/MutableRoutingTable.java @@ -0,0 +1,19 @@ +/* + * 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.md.sal.common.api.routing; + +import org.opendaylight.yangtools.concepts.Mutable; +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; + +public interface MutableRoutingTable */,T> extends RoutingTable, Mutable { + + void setDefaultRoute(T target); + void updateRoute(P path,T target); + void removeRoute(P path); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChange.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChange.java new file mode 100644 index 0000000000..5f84ec579d --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RouteChange.java @@ -0,0 +1,17 @@ +/* + * 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.md.sal.common.api.routing; + +import java.util.Map; +import java.util.Set; + +public interface RouteChange { + + Map> getRemovals(); + Map> getAnnouncements(); +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java new file mode 100644 index 0000000000..37ec2f6f1f --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutedRegistration.java @@ -0,0 +1,19 @@ +/* + * 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.md.sal.common.api.routing; + +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; +import org.opendaylight.yangtools.concepts.Registration; + +public interface RoutedRegistration */,S> extends Registration { + + void registerPath(C context, P path); + void unregisterPath(C context, P path); + +} diff --git a/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java new file mode 100644 index 0000000000..211cf18879 --- /dev/null +++ b/opendaylight/md-sal/sal-common-api/src/main/java/org/opendaylight/controller/md/sal/common/api/routing/RoutingTable.java @@ -0,0 +1,24 @@ +/* + * 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.md.sal.common.api.routing; + +import java.util.Map; + +// FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments. +// import org.opendaylight.yangtools.concepts.Path; + +public interface RoutingTable */,T> { + + C getIdentifier(); + + T getDefaultRoute(); + + Map getRoutes(); + + T getRoute(P path); +} diff --git a/opendaylight/md-sal/sal-common-impl/pom.xml b/opendaylight/md-sal/sal-common-impl/pom.xml new file mode 100644 index 0000000000..8da8f24655 --- /dev/null +++ b/opendaylight/md-sal/sal-common-impl/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.0-SNAPSHOT + + sal-common-impl + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + + + + + org.opendaylight.controller + sal-common-api + 1.0-SNAPSHOT + + + com.google.guava + guava + + + bundle + diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractDataChange.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractDataChange.java new file mode 100644 index 0000000000..f0e8624eb9 --- /dev/null +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractDataChange.java @@ -0,0 +1,58 @@ +package org.opendaylight.controller.md.sal.common.impl; + +import java.util.Map; +import java.util.Set; + +import org.opendaylight.controller.md.sal.common.api.data.DataChange; +import org.opendaylight.yangtools.concepts.Path; + +public abstract class AbstractDataChange

    , D> implements DataChange { + + private final Map createdCfg; + private final Map createdOperational; + private final Set

    removedCfg; + private final Set

    removedOperational; + private final Map updatedCfg; + private final Map updatedOperational; + + public AbstractDataChange(Map createdCfg, Map createdOperational, Set

    removedCfg, + Set

    removedOperational, Map updatedCfg, Map updatedOperational) { + this.createdCfg = createdCfg; + this.createdOperational = createdOperational; + this.removedCfg = (removedCfg); + this.removedOperational = (removedOperational); + this.updatedCfg = (updatedCfg); + this.updatedOperational = (updatedOperational); + } + + @Override + public final Map getCreatedConfigurationData() { + return this.createdCfg; + } + + @Override + public final Map getCreatedOperationalData() { + return this.createdOperational; + } + + @Override + public final Set

    getRemovedConfigurationData() { + return this.removedCfg; + } + + @Override + public final Set

    getRemovedOperationalData() { + return this.removedOperational; + } + + @Override + public final Map getUpdatedConfigurationData() { + return this.updatedCfg; + } + + @Override + public final Map getUpdatedOperationalData() { + return this.updatedOperational; + } + +} diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractDataModification.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractDataModification.java new file mode 100644 index 0000000000..e786b7443b --- /dev/null +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractDataModification.java @@ -0,0 +1,99 @@ +package org.opendaylight.controller.md.sal.common.impl; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import org.opendaylight.controller.md.sal.common.api.data.DataModification; +import org.opendaylight.yangtools.concepts.Path; + +import static org.opendaylight.controller.md.sal.common.api.TransactionStatus.NEW; + +public abstract class AbstractDataModification

    , D> implements DataModification { + + private final Map configurationUpdate; + private final Map operationalUpdate; + + private final Set

    configurationRemove; + private final Set

    operationalRemove; + + private final Map unmodifiable_configurationUpdate; + private final Map unmodifiable_operationalUpdate; + private final Set

    unmodifiable_configurationRemove; + private final Set

    unmodifiable_OperationalRemove; + + + + public AbstractDataModification(Map configurationUpdate, Map operationalUpdate, + Set

    configurationRemove, Set

    operationalRemove) { + this.configurationUpdate = configurationUpdate; + this.operationalUpdate = operationalUpdate; + this.configurationRemove = configurationRemove; + this.operationalRemove = operationalRemove; + + unmodifiable_configurationUpdate = Collections.unmodifiableMap(configurationUpdate); + unmodifiable_operationalUpdate = Collections.unmodifiableMap(operationalUpdate); + unmodifiable_configurationRemove = Collections.unmodifiableSet(configurationRemove); + unmodifiable_OperationalRemove = Collections.unmodifiableSet(operationalRemove); + } + + public AbstractDataModification() { + this(new HashMap(), new HashMap(), new HashSet

    (), new HashSet

    ()); + } + + @Override + public final void putConfigurationData(P path, D data) { + checkMutable(); + configurationUpdate.put(path, data); + configurationRemove.remove(path); + } + + @Override + public final void putRuntimeData(P path, D data) { + checkMutable(); + operationalUpdate.put(path, data); + operationalRemove.remove(path); + } + + @Override + public final void removeRuntimeData(P path) { + checkMutable(); + operationalUpdate.remove(path); + operationalRemove.add(path); + } + + @Override + public final void removeConfigurationData(P path) { + checkMutable(); + configurationUpdate.remove(path); + configurationRemove.add(path); + } + + private final void checkMutable() { + if(!NEW.equals(this.getStatus())) throw new IllegalStateException("Transaction was already submitted"); + } + + @Override + public Map getUpdatedConfigurationData() { + + return unmodifiable_configurationUpdate; + } + + @Override + public Map getUpdatedOperationalData() { + return unmodifiable_operationalUpdate; + } + + @Override + public Set

    getRemovedConfigurationData() { + return unmodifiable_configurationRemove; + } + + @Override + public Set

    getRemovedOperationalData() { + return unmodifiable_OperationalRemove; + } + +} diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractRegistration.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractRegistration.java new file mode 100644 index 0000000000..4bda399d8b --- /dev/null +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractRegistration.java @@ -0,0 +1,20 @@ +package org.opendaylight.controller.md.sal.common.impl; + +import org.opendaylight.yangtools.concepts.Registration; + +public abstract class AbstractRegistration implements Registration { + + + private final T instance; + + public AbstractRegistration(T instance) { + super(); + this.instance = instance; + } + + @Override + public final T getInstance() { + return instance; + } + +} diff --git a/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractRoutedRegistration.java b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractRoutedRegistration.java new file mode 100644 index 0000000000..4fe1566a58 --- /dev/null +++ b/opendaylight/md-sal/sal-common-impl/src/main/java/org/opendaylight/controller/md/sal/common/impl/AbstractRoutedRegistration.java @@ -0,0 +1,12 @@ +package org.opendaylight.controller.md.sal.common.impl; + +import org.opendaylight.controller.md.sal.common.api.routing.RoutedRegistration; +import org.opendaylight.yangtools.concepts.Path; + +public abstract class AbstractRoutedRegistration, S> extends AbstractRegistration implements + RoutedRegistration { + + public AbstractRoutedRegistration(S instance) { + super(instance); + } +} diff --git a/opendaylight/md-sal/sal-compability/pom.xml b/opendaylight/md-sal/sal-compability/pom.xml index 3d1679425c..3f70e66350 100644 --- a/opendaylight/md-sal/sal-compability/pom.xml +++ b/opendaylight/md-sal/sal-compability/pom.xml @@ -54,4 +54,5 @@ test + bundle diff --git a/opendaylight/md-sal/sal-dom-api/pom.xml b/opendaylight/md-sal/sal-dom-api/pom.xml index b9aedbe96a..ca923f6baa 100644 --- a/opendaylight/md-sal/sal-dom-api/pom.xml +++ b/opendaylight/md-sal/sal-dom-api/pom.xml @@ -23,6 +23,12 @@ org.opendaylight.yangtools yang-data-api + 0.5.9-SNAPSHOT + + + org.opendaylight.controller + sal-common-api + ${project.version} org.opendaylight.yangtools @@ -34,4 +40,5 @@ 5.0.0 + bundle diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java index 5e13aad499..1fb73bc9a9 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractConsumer.java @@ -1,3 +1,10 @@ +/* + * 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.core.api; import java.util.Collection; @@ -13,25 +20,30 @@ public abstract class AbstractConsumer implements Consumer, BundleActivator { ServiceReference brokerRef; @Override public final void start(BundleContext context) throws Exception { + this.startImpl(context); brokerRef = context.getServiceReference(Broker.class); broker = context.getService(brokerRef); - - this.startImpl(context); - broker.registerConsumer(this,context); } - public abstract void startImpl(BundleContext context); + @Override public final void stop(BundleContext context) throws Exception { + stopImpl(context); broker = null; if(brokerRef != null) { context.ungetService(brokerRef); } } - + protected void startImpl(BundleContext context) { + // NOOP + } + protected void stopImpl(BundleContext context) { + // NOOP + } + @Override public Collection getConsumerFunctionality() { return Collections.emptySet(); diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractProvider.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractProvider.java index c25b2f9cad..621ef92132 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractProvider.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/AbstractProvider.java @@ -1,3 +1,10 @@ +/* + * 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.core.api; import java.util.Collection; @@ -28,12 +35,16 @@ public abstract class AbstractProvider implements BundleActivator, Provider { broker.registerProvider(this,context); } - public abstract void startImpl(BundleContext context); + protected void startImpl(BundleContext context) { + // NOOP + } + protected void stopImpl(BundleContext context) { + // NOOP + } @Override public final void stop(BundleContext context) throws Exception { - // TODO Auto-generated method stub - + stopImpl(context); } } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java index b2c3550783..632a8742a0 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java @@ -9,16 +9,18 @@ package org.opendaylight.controller.sal.core.api; import java.util.concurrent.Future; +import org.opendaylight.controller.md.sal.common.api.routing.RoutedRegistration; 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.notify.NotificationProviderService; +import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; import org.opendaylight.controller.sal.core.api.notify.NotificationService; +import org.opendaylight.yangtools.concepts.Registration; 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.InstanceIdentifier; import org.osgi.framework.BundleContext; - /** * Core component of the SAL layer responsible for wiring the SAL consumers. * @@ -36,7 +38,7 @@ import org.osgi.framework.BundleContext; * {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and * {@link RpcImplementation} *

  • Notification Service - see {@link NotificationService} and - * {@link NotificationProviderService} + * {@link NotificationPublishService} *
  • Functionality and Data model *
  • Data Store access and modification - see {@link DataBrokerService} and * {@link DataProviderService} @@ -78,7 +80,7 @@ public interface Broker { * * @param cons * Consumer to be registered. - * @param context + * @param context * @return a session specific to consumer registration * @throws IllegalArgumentException * If the consumer is null. @@ -110,7 +112,7 @@ public interface Broker { * * @param prov * Provider to be registered. - * @param context + * @param context * @return a session unique to the provider registration. * @throws IllegalArgumentException * If the provider is null. @@ -132,7 +134,7 @@ public interface Broker { * infrastructure services and other functionality provided by * {@link Provider}s. * - + * * */ public interface ConsumerSession { @@ -208,22 +210,12 @@ public interface Broker { * @throws IllegalArgumentException * If the name of RPC is invalid */ - void addRpcImplementation(QName rpcType, - RpcImplementation implementation) + RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation) throws IllegalArgumentException; - /** - * Unregisters an Rpc implementation - * - * @param rpcType - * Name of Rpc - * @param implementation - * Registered Implementation of the Rpc functionality - * @throws IllegalArgumentException - */ - void removeRpcImplementation(QName rpcType, - RpcImplementation implementation) - throws IllegalArgumentException; + RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation); + + RoutedRpcRegistration addMountedRpcImplementation(QName rpcType, RpcImplementation implementation); /** * Closes a session between provider and SAL. @@ -238,4 +230,12 @@ public interface Broker { @Override boolean isClosed(); } + + public interface RpcRegistration extends Registration { + QName getType(); + } + + public interface RoutedRpcRegistration extends RpcRegistration, + RoutedRegistration { + } } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java index b425368052..c1518b1ec6 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/BrokerService.java @@ -35,5 +35,4 @@ import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; */ public interface BrokerService { - void closeSession(); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java index fef894ba5c..2d5f4b2a55 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataBrokerService.java @@ -7,17 +7,12 @@ */ package org.opendaylight.controller.sal.core.api.data; -import java.util.Set; -import java.util.concurrent.Future; - -import org.opendaylight.controller.sal.common.DataStoreIdentifier; +import org.opendaylight.controller.md.sal.common.api.data.DataChangePublisher; +import org.opendaylight.controller.md.sal.common.api.data.DataModificationTransactionFactory; +import org.opendaylight.controller.md.sal.common.api.data.DataReader; import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.Consumer; -import org.opendaylight.controller.sal.core.api.Provider; -import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode; -import org.opendaylight.yangtools.yang.data.api.Node; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; /** @@ -28,109 +23,18 @@ import org.opendaylight.yangtools.yang.data.api.Node; * @see DataProviderService * */ -public interface DataBrokerService extends BrokerService { - - - Set getDataStores(); - - /** - * Returns a data from specified Data Store. - * - * Returns all the data visible to the consumer from specified Data Store. - * - * @param store - * Identifier of the store, from which will be data retrieved - * @return data visible to the consumer - */ - CompositeNode getData(DataStoreIdentifier store); - - /** - * Returns a filtered subset of data from specified Data Store. - * - *

    - * The filter is modeled as an hierarchy of {@link Node} starting with - * {@link CompositeNode} representing data root. The semantics of the filter - * tree is the same as filter semantics defined in the NETCONF protocol for - * rpc operations get and get-config in Section 6 - * of RFC6241. - * - * - * @see http://tools.ietf.org/html/rfc6241#section-6 - * @param store - * Identifier of the store, from which will be data retrieved - * @param filter - * Data tree filter similar to the NETCONF filter - * @return - */ - CompositeNode getData(DataStoreIdentifier store, CompositeNode filter); +public interface DataBrokerService extends + BrokerService, // + DataReader, // + DataModificationTransactionFactory, // + DataChangePublisher { - /** - * Returns a candidate data which are not yet commited. - * - * - * @param store - * Identifier of the store, from which will be data retrieved - * @return - */ - CompositeNode getCandidateData(DataStoreIdentifier store); - /** - * Returns a filtered subset of candidate data from specified Data Store. - * - *

    - * The filter is modeled as an hierarchy of {@link Node} starting with - * {@link CompositeNode} representing data root. The semantics of the filter - * tree is the same as filter semantics defined in the NETCONF protocol for - * rpc operations get and get-config in Section 6 - * of RFC6241. - * - * - * @see http://tools.ietf.org/html/rfc6241#section-6 - * @param store - * Identifier of the store, from which will be data retrieved - * @param filter - * A CompositeNode filter - * @return - */ - CompositeNode getCandidateData(DataStoreIdentifier store, - CompositeNode filter); + @Override + public CompositeNode readConfigurationData(InstanceIdentifier path); - /** - * - * @param store - * Identifier of the store, in which will be the candidate data - * modified - * @param changeSet - * Modification of data tree. - * @return Result object containing the modified data tree if the operation - * was successful, otherwise list of the encountered errors. - */ - RpcResult editCandidateData(DataStoreIdentifier store, - MutableCompositeNode changeSet); + @Override + public CompositeNode readOperationalData(InstanceIdentifier path); - /** - * Initiates a two-phase commit of candidate data. - * - *

    - * The {@link Consumer} could initiate a commit of candidate data - * - *

    - * The successful commit changes the state of the system and may affect - * several components. - * - *

    - * The effects of successful commit of data are described in the - * specifications and YANG models describing the {@link Provider} components - * of controller. It is assumed that {@link Consumer} has an understanding - * of this changes. - * - * - * @see DataCommitHandler for further information how two-phase commit is - * processed. - * @param store - * Identifier of the store, where commit should occur. - * @return Result of the commit, containing success information or list of - * encountered errors, if commit was not successful. - */ - Future> commit(DataStoreIdentifier store); + DataModificationTransaction beginTransaction(); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java new file mode 100644 index 0000000000..944ccc5b33 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataChangeListener.java @@ -0,0 +1,20 @@ +/* + * 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.core.api.data; + +import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; + +public interface DataChangeListener + extends + org.opendaylight.controller.md.sal.common.api.data.DataChangeListener { + + @Override + public void onDataChanged(DataChangeEvent change); +} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java new file mode 100644 index 0000000000..774de271af --- /dev/null +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataModificationTransaction.java @@ -0,0 +1,53 @@ +/* + * 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.core.api.data; + +import java.util.EventListener; +import java.util.Map; +import java.util.Set; +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.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; + +public interface DataModificationTransaction extends DataModification{ + + /** + * Returns transaction identifier + * + * @return Transaction identifier + */ + Object getIdentifier(); + + TransactionStatus getStatus(); + + /** + * Commits transaction to be stored in global data repository. + * + * + * @return Future object which returns RpcResult with TransactionStatus + * when transaction is processed by store. + */ + Future> commit(); + + ListenerRegistration registerListener(DataTransactionListener listener); + + + public interface DataTransactionListener extends EventListener { + + void onStatusUpdated(DataModificationTransaction transaction,TransactionStatus status); + + } + + + +} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java index 32035ea489..3024c89d61 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/data/DataProviderService.java @@ -7,10 +7,16 @@ */ package org.opendaylight.controller.sal.core.api.data; +import org.opendaylight.controller.md.sal.common.api.data.DataProvisionService; import org.opendaylight.controller.sal.common.DataStoreIdentifier; import org.opendaylight.controller.sal.core.api.Provider; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; -public interface DataProviderService extends DataBrokerService { +public interface DataProviderService extends + DataBrokerService, // + DataProvisionService + { /** * Adds {@link DataValidator} for specified Data Store @@ -32,23 +38,6 @@ public interface DataProviderService extends DataBrokerService { public void removeValidator(DataStoreIdentifier store, DataValidator validator); - /** - * Adds {@link DataCommitHandler} for specified data store - * - * @param store - * @param provider - */ - void addCommitHandler(DataStoreIdentifier store, DataCommitHandler provider); - - /** - * Removes {@link DataCommitHandler} from specified data store - * - * @param store - * @param provider - */ - void removeCommitHandler(DataStoreIdentifier store, - DataCommitHandler provider); - /** * Adds {@link DataRefresher} for specified data store * diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountInstance.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountInstance.java new file mode 100644 index 0000000000..1596165601 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountInstance.java @@ -0,0 +1,23 @@ +/* + * 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.core.api.mount; + +import java.util.concurrent.Future; + +import org.opendaylight.controller.sal.core.api.data.DataBrokerService; +import org.opendaylight.controller.sal.core.api.notify.NotificationService; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.data.api.CompositeNode; + +public interface MountInstance extends NotificationService, DataBrokerService { + + Future> rpc(QName type, CompositeNode input); +} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java new file mode 100644 index 0000000000..530b02b733 --- /dev/null +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/mount/MountService.java @@ -0,0 +1,16 @@ +/* + * 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.core.api.mount; + +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; + + +public interface MountService { + + MountInstance getMountPoint(InstanceIdentifier path); +} diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java index 5b0c992a00..f87fee5bce 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationListener.java @@ -7,6 +7,7 @@ */ package org.opendaylight.controller.sal.core.api.notify; +import java.util.EventListener; import java.util.Set; import org.opendaylight.controller.sal.core.api.Consumer; @@ -17,7 +18,7 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; /** * Notification listener for SAL notifications. */ -public interface NotificationListener extends Consumer.ConsumerFunctionality { +public interface NotificationListener extends Consumer.ConsumerFunctionality, EventListener { /** * A set of notification types supported by listeners. * diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationProviderService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java similarity index 90% rename from opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationProviderService.java rename to opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java index 51871a770b..652eab10a7 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationProviderService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationPublishService.java @@ -29,7 +29,7 @@ import org.opendaylight.yangtools.yang.data.api.CompositeNode; * * */ -public interface NotificationProviderService extends NotificationService { +public interface NotificationPublishService extends NotificationService { /** * Publishes a notification. @@ -41,6 +41,8 @@ public interface NotificationProviderService extends NotificationService { * @param notification * Notification to publish */ + @Deprecated void sendNotification(CompositeNode notification); + void publish(CompositeNode notification); } diff --git a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java index 3bf10546e5..f654ca9ad6 100644 --- a/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java +++ b/opendaylight/md-sal/sal-dom-api/src/main/java/org/opendaylight/controller/sal/core/api/notify/NotificationService.java @@ -11,6 +11,7 @@ import org.opendaylight.controller.sal.core.api.BrokerService; import org.opendaylight.controller.sal.core.api.Provider; import org.opendaylight.controller.sal.core.api.RpcImplementation; import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; +import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.common.QName; @@ -40,15 +41,6 @@ public interface NotificationService extends BrokerService { * @param notification * @param listener */ - void addNotificationListener(QName notification, - NotificationListener listener); - - /** - * Removes a notification listener for supplied notification type. - * - * @param notification - * @param listener - */ - void removeNotificationListener(QName notification, + Registration addNotificationListener(QName notification, NotificationListener listener); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.xtend index d79eeee0e7..6d57a4e224 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.xtend +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ConsumerContextImpl.xtend @@ -49,7 +49,7 @@ class ConsumerContextImpl implements ConsumerSession { val toStop = instantiatedServices.values(); this.closed = true; for (BrokerService brokerService : toStop) { - brokerService.closeSession(); + //brokerService.closeSession(); } broker.consumerSessionClosed(this); } diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerModule.java deleted file mode 100644 index 7fa20d7bea..0000000000 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataBrokerModule.java +++ /dev/null @@ -1,419 +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; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Future; - -import org.opendaylight.controller.sal.common.DataStoreIdentifier; -import org.opendaylight.controller.sal.common.util.Rpcs; -import org.opendaylight.controller.sal.core.api.BrokerService; -import org.opendaylight.controller.sal.core.api.Broker.ConsumerSession; -import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; -import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality; -import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality; -import org.opendaylight.controller.sal.core.api.data.DataBrokerService; -import org.opendaylight.controller.sal.core.api.data.DataCommitHandler; -import org.opendaylight.controller.sal.core.api.data.DataProviderService; -import org.opendaylight.controller.sal.core.api.data.DataValidator; -import org.opendaylight.controller.sal.core.api.data.DataCommitHandler.CommitTransaction; -import org.opendaylight.controller.sal.core.api.data.DataProviderService.DataRefresher; -import org.opendaylight.controller.sal.core.spi.BrokerModule; -import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResult; -import org.opendaylight.yangtools.yang.data.api.CompositeNode; -import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.collect.ImmutableSet; - -public class DataBrokerModule implements BrokerModule { - - private static final Logger log = LoggerFactory - .getLogger(DataBrokerModule.class); - - private static final Set> SUPPORTED_PROVIDER_FUNCTIONALITY = ImmutableSet - .of((Class) DataValidator.class, - DataRefresher.class, DataCommitHandler.class); - - private static final Set> PROVIDED_SESSION_SERVICES = ImmutableSet - .of((Class) DataBrokerService.class, - DataProviderService.class); - - private Map storeContext; - - private ExecutorService executor; - - private SequentialCommitHandlerCoordinator coordinator = new SequentialCommitHandlerCoordinator(); - - @Override - public Set> getProvidedServices() { - return PROVIDED_SESSION_SERVICES; - } - - @Override - public Set> getSupportedProviderFunctionality() { - return SUPPORTED_PROVIDER_FUNCTIONALITY; - } - - @Override - public Set> getSupportedConsumerFunctionality() { - return Collections.emptySet(); - } - - @Override - public T getServiceForSession(Class service, - ConsumerSession session) { - if (DataProviderService.class.equals(service) - && session instanceof ProviderSession) { - @SuppressWarnings("unchecked") - T ret = (T) newDataProviderService(session); - return ret; - } else if (DataBrokerService.class.equals(service)) { - - @SuppressWarnings("unchecked") - T ret = (T) newDataConsumerService(session); - return ret; - } - - throw new IllegalArgumentException( - "The requested session-specific service is not provided by this module."); - } - - private DataProviderService newDataProviderService(ConsumerSession session) { - return new DataProviderSession(); - } - - private DataBrokerService newDataConsumerService(ConsumerSession session) { - return new DataConsumerSession(); - } - - private StoreContext context(DataStoreIdentifier store) { - return storeContext.get(store); - } - - private static class StoreContext { - private Set commitHandlers = Collections - .synchronizedSet(new HashSet()); - private Set validators = Collections - .synchronizedSet(new HashSet()); - private Set refreshers = Collections - .synchronizedSet(new HashSet()); - } - - private class DataConsumerSession implements DataBrokerService { - - @Override - public CompositeNode getData(DataStoreIdentifier store) { - // TODO Implement this method - throw new UnsupportedOperationException("Not implemented"); - } - - @Override - public CompositeNode getData(DataStoreIdentifier store, - CompositeNode filter) { - // TODO Implement this method - throw new UnsupportedOperationException("Not implemented"); - } - - @Override - public CompositeNode getCandidateData(DataStoreIdentifier store) { - // TODO Implement this method - throw new UnsupportedOperationException("Not implemented"); - } - - @Override - public CompositeNode getCandidateData(DataStoreIdentifier store, - CompositeNode filter) { - // TODO Implement this method - throw new UnsupportedOperationException("Not implemented"); - } - - @Override - public RpcResult editCandidateData( - DataStoreIdentifier store, MutableCompositeNode changeSet) { - // TODO Implement this method - throw new UnsupportedOperationException("Not implemented"); - } - - @Override - public Future> commit(DataStoreIdentifier store) { - // TODO Implement this method - throw new UnsupportedOperationException("Not implemented"); - } - - @Override - public void closeSession() { - // TODO Implement this method - throw new UnsupportedOperationException("Not implemented"); - } - - @Override - public Set getDataStores() { - // TODO Auto-generated method stub - return null; - } - - } - - private class DataProviderSession extends DataConsumerSession implements - DataProviderService { - - private Set providerCommitHandlers = new HashSet(); - private Set providerValidators = new HashSet(); - private Set providerRefreshers = new HashSet(); - - @Override - public void addValidator(DataStoreIdentifier store, - DataValidator validator) { - if (validator == null) - throw new IllegalArgumentException( - "Validator should not be null"); - - providerValidators.add(validator); - context(store).validators.add(validator); - } - - @Override - public void removeValidator(DataStoreIdentifier store, - DataValidator validator) { - if (validator == null) - throw new IllegalArgumentException( - "Validator should not be null"); - - providerValidators.remove(validator); - context(store).validators.remove(validator); - } - - @Override - public void addCommitHandler(DataStoreIdentifier store, - DataCommitHandler provider) { - if (provider == null) - throw new IllegalArgumentException( - "CommitHandler should not be null"); - - providerCommitHandlers.add(provider); - context(store).commitHandlers.add(provider); - } - - @Override - public void removeCommitHandler(DataStoreIdentifier store, - DataCommitHandler provider) { - if (provider == null) - throw new IllegalArgumentException( - "CommitHandler should not be null"); - - providerCommitHandlers.remove(provider); - context(store).commitHandlers.remove(provider); - } - - @Override - public void addRefresher(DataStoreIdentifier store, - DataRefresher provider) { - if (provider == null) - throw new IllegalArgumentException( - "Refresher should not be null"); - - providerRefreshers.add(provider); - context(store).refreshers.add(provider); - } - - @Override - public void removeRefresher(DataStoreIdentifier store, - DataRefresher provider) { - if (provider == null) - throw new IllegalArgumentException( - "Refresher should not be null"); - - providerRefreshers.remove(provider); - context(store).refreshers.remove(provider); - } - - } - - private class SequentialCommitHandlerCoordinator implements - DataCommitHandler { - - @Override - public RpcResult requestCommit( - DataStoreIdentifier store) { - List errors = new ArrayList(); - Set transactions = new HashSet(); - boolean successful = true; - - for (DataCommitHandler commitHandler : context(store).commitHandlers) { - try { - RpcResult partialResult = commitHandler - .requestCommit(store); - successful = partialResult.isSuccessful() & successful; - if (partialResult.isSuccessful()) { - transactions.add(partialResult.getResult()); - } - - errors.addAll(partialResult.getErrors()); - } catch (Exception e) { - log.error("Uncaught exception prevented commit request." - + e.getMessage(), e); - successful = false; - // FIXME: Add RPC Error with exception. - } - if (successful == false) - break; - } - CommitTransaction transaction = new SequentialCommitTransaction( - store, transactions); - return Rpcs.getRpcResult(successful, transaction, errors); - } - - @Override - public Set getSupportedDataStores() { - return Collections.emptySet(); - } - } - - private class SequentialCommitTransaction implements CommitTransaction { - - final Set transactions; - final DataStoreIdentifier store; - - public SequentialCommitTransaction(DataStoreIdentifier s, - Set t) { - transactions = t; - store = s; - } - - @Override - public RpcResult finish() { - List errors = new ArrayList(); - boolean successful = true; - - for (CommitTransaction commitHandler : transactions) { - try { - RpcResult partialResult = commitHandler.finish(); - successful = partialResult.isSuccessful() & successful; - errors.addAll(partialResult.getErrors()); - } catch (Exception e) { - log.error( - "Uncaught exception prevented finishing of commit." - + e.getMessage(), e); - successful = false; - // FIXME: Add RPC Error with exception. - } - if (successful == false) - break; - } - - return Rpcs.getRpcResult(successful, null, errors); - } - - @Override - public RpcResult rollback() { - List errors = new ArrayList(); - boolean successful = true; - - for (CommitTransaction commitHandler : transactions) { - try { - RpcResult partialResult = commitHandler.rollback(); - successful = partialResult.isSuccessful() & successful; - errors.addAll(partialResult.getErrors()); - } catch (Exception e) { - log.error( - "Uncaught exception prevented rollback of commit." - + e.getMessage(), e); - successful = false; - // FIXME: Add RPC Error with exception. - } - if (successful == false) - break; - } - - return Rpcs.getRpcResult(successful, null, errors); - } - - @Override - public DataStoreIdentifier getDataStore() { - return this.store; - } - - @Override - public DataCommitHandler getHandler() { - return coordinator; - } - } - - private class ValidationCoordinator implements DataValidator { - - private final DataStoreIdentifier store; - - ValidationCoordinator(DataStoreIdentifier store) { - this.store = store; - } - - @Override - public RpcResult validate(CompositeNode toValidate) { - List errors = new ArrayList(); - boolean successful = true; - - for (DataValidator validator : context(store).validators) { - try { - RpcResult partialResult = validator - .validate(toValidate); - successful = partialResult.isSuccessful() & successful; - errors.addAll(partialResult.getErrors()); - } catch (Exception e) { - log.error( - "Uncaught exception prevented validation." - + e.getMessage(), e); - successful = false; - // FIXME: Add RPC Error with exception. - } - if (successful == false) - break; - } - - return Rpcs.getRpcResult(successful, null, errors); - } - - @Override - public Set getSupportedDataStores() { - return Collections.emptySet(); - } - - } - - private class DataRefreshCoordinator implements DataRefresher { - - private final DataStoreIdentifier store; - - DataRefreshCoordinator(DataStoreIdentifier store) { - this.store = store; - } - - @Override - public void refreshData() { - - for (DataRefresher refresher : context(store).refreshers) { - try { - refresher.refreshData(); - } catch (Exception e) { - log.error( - "Uncaught exception during refresh of data: " - + e.getMessage(), e); - } - - } - } - } -} diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataConsumerServiceImpl.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataConsumerServiceImpl.xtend new file mode 100644 index 0000000000..3bccc4e64b --- /dev/null +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/DataConsumerServiceImpl.xtend @@ -0,0 +1,27 @@ +package org.opendaylight.controller.sal.dom.broker + +import org.opendaylight.controller.sal.core.api.data.DataBrokerService +import org.opendaylight.controller.sal.common.DataStoreIdentifier +import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode +import org.opendaylight.yangtools.yang.data.api.CompositeNode +import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier +import org.opendaylight.controller.sal.core.api.data.DataChangeListener + +class DataConsumerServiceImpl implements DataBrokerService { + + override beginTransaction() { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override readConfigurationData(InstanceIdentifier path) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override readOperationalData(InstanceIdentifier path) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override registerDataChangeListener(InstanceIdentifier path, DataChangeListener listener) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java index 9a002ec467..8c272e5a4c 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/NotificationModule.java @@ -20,9 +20,10 @@ import org.opendaylight.controller.sal.core.api.Broker.ProviderSession; import org.opendaylight.controller.sal.core.api.Consumer.ConsumerFunctionality; import org.opendaylight.controller.sal.core.api.Provider.ProviderFunctionality; import org.opendaylight.controller.sal.core.api.notify.NotificationListener; -import org.opendaylight.controller.sal.core.api.notify.NotificationProviderService; +import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService; import org.opendaylight.controller.sal.core.api.notify.NotificationService; import org.opendaylight.controller.sal.core.spi.BrokerModule; +import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.slf4j.Logger; @@ -40,8 +41,8 @@ public class NotificationModule implements BrokerModule { .create(); private static final Set> PROVIDED_SERVICE_TYPE = ImmutableSet - .of((Class) NotificationService.class, - NotificationProviderService.class); + .>of(NotificationService.class, + NotificationPublishService.class); private static final Set> SUPPORTED_CONSUMER_FUNCTIONALITY = ImmutableSet .of((Class) NotificationListener.class, @@ -63,10 +64,10 @@ public class NotificationModule implements BrokerModule { @Override public T getServiceForSession(Class service, ConsumerSession session) { - if (NotificationProviderService.class.equals(service) + if (NotificationPublishService.class.equals(service) && session instanceof ProviderSession) { @SuppressWarnings("unchecked") - T ret = (T) newNotificationProviderService(session); + T ret = (T) newNotificationPublishService(session); return ret; } else if (NotificationService.class.equals(service)) { @@ -105,7 +106,7 @@ public class NotificationModule implements BrokerModule { return new NotificationConsumerSessionImpl(); } - private NotificationProviderService newNotificationProviderService( + private NotificationPublishService newNotificationPublishService( ConsumerSession session) { return new NotificationProviderSessionImpl(); } @@ -117,8 +118,8 @@ public class NotificationModule implements BrokerModule { .create(); private boolean closed = false; - @Override - public void addNotificationListener(QName notification, + + public Registration addNotificationListener(QName notification, NotificationListener listener) { checkSessionState(); if (notification == null) { @@ -132,9 +133,9 @@ public class NotificationModule implements BrokerModule { consumerListeners.put(notification, listener); listeners.put(notification, listener); log.info("Registered listener for notification: " + notification); + return null; // Return registration Object. } - @Override public void removeNotificationListener(QName notification, NotificationListener listener) { checkSessionState(); @@ -149,7 +150,6 @@ public class NotificationModule implements BrokerModule { listeners.remove(notification, listener); } - @Override public void closeSession() { closed = true; Map> toRemove = consumerListeners @@ -168,7 +168,7 @@ public class NotificationModule implements BrokerModule { private class NotificationProviderSessionImpl extends NotificationConsumerSessionImpl implements - NotificationProviderService { + NotificationPublishService { @Override public void sendNotification(CompositeNode notification) { @@ -178,6 +178,11 @@ public class NotificationModule implements BrokerModule { "Notification must not be null."); NotificationModule.this.sendNotification(notification); } + + @Override + public void publish(CompositeNode notification) { + sendNotification(notification); + } } @Override diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.xtend b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.xtend index 8e402e2f36..11f68d6e04 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.xtend +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/ProviderContextImpl.xtend @@ -30,9 +30,11 @@ class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession } broker.addRpcImplementation(rpcType, implementation); rpcImpls.put(rpcType, implementation); + //FIXME: Return registration + return null; } - override removeRpcImplementation(QName rpcType, RpcImplementation implToRemove) throws IllegalArgumentException { + def removeRpcImplementation(QName rpcType, RpcImplementation implToRemove) throws IllegalArgumentException { val localImpl = rpcImpls.get(rpcType); if(localImpl != implToRemove) { throw new IllegalStateException( @@ -42,5 +44,13 @@ class ProviderContextImpl extends ConsumerContextImpl implements ProviderSession broker.removeRpcImplementation(rpcType, implToRemove); rpcImpls.remove(rpcType); } - + + override addMountedRpcImplementation(QName rpcType, RpcImplementation implementation) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + + override addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation) { + throw new UnsupportedOperationException("TODO: auto-generated method stub") + } + } diff --git a/opendaylight/md-sal/sal-dom-spi/pom.xml b/opendaylight/md-sal/sal-dom-spi/pom.xml index 7b9bcf0896..01dca0110b 100644 --- a/opendaylight/md-sal/sal-dom-spi/pom.xml +++ b/opendaylight/md-sal/sal-dom-spi/pom.xml @@ -20,4 +20,5 @@ 1.0-SNAPSHOT + bundle diff --git a/opendaylight/md-sal/samples/toaster-it/pom.xml b/opendaylight/md-sal/samples/toaster-it/pom.xml index 97bbdc4522..996f257713 100644 --- a/opendaylight/md-sal/samples/toaster-it/pom.xml +++ b/opendaylight/md-sal/samples/toaster-it/pom.xml @@ -1,138 +1,138 @@ - 4.0.0 - - sal-samples - org.opendaylight.controller.samples - 1.0-SNAPSHOT - - sample-toaster-it + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + sal-samples + org.opendaylight.controller.samples + 1.0-SNAPSHOT + + sample-toaster-it - scm:git:ssh://git.opendaylight.org:29418/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - 3.0.0 - 1.5.0 - + + 3.0.0 + 1.5.0 + - - - - org.ops4j.pax.exam - maven-paxexam-plugin - 1.2.4 - - - generate-config - - generate-depends-file - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.ops4j.pax.exam - - - maven-paxexam-plugin - - - [1.2.4,) - - - - generate-depends-file - - - - - - - - - - - - - - + + + + org.ops4j.pax.exam + maven-paxexam-plugin + 1.2.4 + + + generate-config + + generate-depends-file + + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.ops4j.pax.exam + + + maven-paxexam-plugin + + + [1.2.4,) + + + + generate-depends-file + + + + + + + + + + + + + + - - - org.opendaylight.controller.samples - sample-toaster - 1.0-SNAPSHOT - - - org.opendaylight.controller.samples - sample-toaster-consumer - 1.0-SNAPSHOT - - - org.opendaylight.controller.samples - sample-toaster-provider - 1.0-SNAPSHOT - - - org.opendaylight.controller - sal-binding-broker-impl - 1.0-SNAPSHOT - - - org.ops4j.pax.exam - pax-exam-container-native - ${exam.version} - test - - - org.ops4j.pax.exam - pax-exam-junit4 - ${exam.version} - test - - - org.ops4j.pax.exam - pax-exam-link-mvn - ${exam.version} - test - - - equinoxSDK381 - org.eclipse.osgi - 3.8.1.v20120830-144521 - test - - - org.slf4j - log4j-over-slf4j - 1.7.2 - - - ch.qos.logback - logback-core - 1.0.9 - - - ch.qos.logback - logback-classic - 1.0.9 - - + + + org.opendaylight.controller.samples + sample-toaster + 1.0-SNAPSHOT + + + org.opendaylight.controller.samples + sample-toaster-consumer + 1.0-SNAPSHOT + + + org.opendaylight.controller.samples + sample-toaster-provider + 1.0-SNAPSHOT + + + org.opendaylight.controller + sal-binding-broker-impl + 1.0-SNAPSHOT + + + org.ops4j.pax.exam + pax-exam-container-native + ${exam.version} + test + + + org.ops4j.pax.exam + pax-exam-junit4 + ${exam.version} + test + + + org.ops4j.pax.exam + pax-exam-link-mvn + ${exam.version} + test + + + equinoxSDK381 + org.eclipse.osgi + 3.8.1.v20120830-144521 + test + + + org.slf4j + log4j-over-slf4j + 1.7.2 + + + ch.qos.logback + logback-core + 1.0.9 + + + ch.qos.logback + logback-classic + 1.0.9 + + diff --git a/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java b/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java index 0561a360c8..4b4cb48b63 100644 --- a/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java +++ b/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java @@ -30,55 +30,51 @@ import org.osgi.framework.ServiceReference; @RunWith(PaxExam.class) public class ToasterTest { - public static final String ODL = "org.opendaylight.controller"; - public static final String YANG = "org.opendaylight.yangtools"; - public static final String SAMPLE = "org.opendaylight.controller.samples"; + public static final String ODL = "org.opendaylight.controller"; + public static final String YANG = "org.opendaylight.yangtools"; + public static final String SAMPLE = "org.opendaylight.controller.samples"; - @Test - public void properInitialized() throws Exception { + @Test + public void properInitialized() throws Exception { - Collection> references = ctx - .getServiceReferences(ToasterService.class, null); - assertEquals(2, references.size()); - - consumer.createToast(WhiteBread.class, 5); - - } + Collection> references = ctx.getServiceReferences(ToasterService.class, null); + assertEquals(2, references.size()); - @Inject - BindingAwareBroker broker; + consumer.createToast(WhiteBread.class, 5); - @Inject - ToastConsumer consumer; + } - @Inject - BundleContext ctx; + @Inject + BindingAwareBroker broker; - @Configuration - public Option[] config() { - return options(systemProperty("osgi.console").value("2401"), - mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), - mavenBundle("org.slf4j", "log4j-over-slf4j") - .versionAsInProject(), - mavenBundle("ch.qos.logback", "logback-core") - .versionAsInProject(), - mavenBundle("ch.qos.logback", "logback-classic") - .versionAsInProject(), - mavenBundle(ODL, "sal-binding-api").versionAsInProject(), - mavenBundle(ODL, "sal-binding-broker-impl") - .versionAsInProject(), mavenBundle(ODL, "sal-common") - .versionAsInProject(), - mavenBundle(ODL, "sal-common-util").versionAsInProject(), - mavenBundle(SAMPLE, "sample-toaster").versionAsInProject(), - mavenBundle(SAMPLE, "sample-toaster-consumer") - .versionAsInProject(), - mavenBundle(SAMPLE, "sample-toaster-provider") - .versionAsInProject(), - mavenBundle(YANG, "yang-binding").versionAsInProject(), - mavenBundle(YANG, "yang-common").versionAsInProject(), - mavenBundle("com.google.guava", "guava").versionAsInProject(), - junitBundles(), mavenBundle("org.javassist", "javassist") - .versionAsInProject()); - } + @Inject + ToastConsumer consumer; + + @Inject + BundleContext ctx; + + @Configuration + public Option[] config() { + return options(systemProperty("osgi.console").value("2401"), + mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(), // + mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(), // + mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(), // + mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(), // + mavenBundle(ODL, "sal-binding-api").versionAsInProject(), // + mavenBundle(ODL, "sal-binding-broker-impl").versionAsInProject(), // + mavenBundle(ODL, "sal-common").versionAsInProject(), // + mavenBundle(ODL, "sal-common-api").versionAsInProject(), + mavenBundle(ODL, "sal-common-util").versionAsInProject(), // + mavenBundle(SAMPLE, "sample-toaster").versionAsInProject(), // + mavenBundle(SAMPLE, "sample-toaster-consumer").versionAsInProject(), // + mavenBundle(SAMPLE, "sample-toaster-provider").versionAsInProject(), // + mavenBundle(YANG, "concepts").versionAsInProject(), + mavenBundle(YANG, "yang-binding").versionAsInProject(), // + mavenBundle(YANG, "yang-common").versionAsInProject(), // + mavenBundle("com.google.guava", "guava").versionAsInProject(), // + mavenBundle("org.javassist", "javassist").versionAsInProject(), + junitBundles() + ); + } } diff --git a/opendaylight/md-sal/samples/toaster-provider/pom.xml b/opendaylight/md-sal/samples/toaster-provider/pom.xml index 92c836a54e..510f316d8f 100644 --- a/opendaylight/md-sal/samples/toaster-provider/pom.xml +++ b/opendaylight/md-sal/samples/toaster-provider/pom.xml @@ -1,49 +1,49 @@ - 4.0.0 - - sal-samples - org.opendaylight.controller.samples - 1.0-SNAPSHOT - - sample-toaster-provider - bundle + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 + + sal-samples + org.opendaylight.controller.samples + 1.0-SNAPSHOT + + sample-toaster-provider + bundle - scm:git:ssh://git.opendaylight.org:29418/controller.git - scm:git:ssh://git.opendaylight.org:29418/controller.git - https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL - - - - org.apache.felix - maven-bundle-plugin - - - org.opendaylight.controller.sample.toaster.provider.ToasterProvider - - - - - + + + + org.apache.felix + maven-bundle-plugin + + + org.opendaylight.controller.sample.toaster.provider.ToasterProvider + + + + + - - - ${project.groupId} - sample-toaster - ${project.version} - - - org.opendaylight.controller - sal-binding-api - 1.0-SNAPSHOT - - - org.opendaylight.controller - sal-common-util - 1.0-SNAPSHOT - - + + + ${project.groupId} + sample-toaster + ${project.version} + + + org.opendaylight.controller + sal-binding-api + 1.0-SNAPSHOT + + + org.opendaylight.controller + sal-common-util + 1.0-SNAPSHOT + + diff --git a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/ToasterProvider.java b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/ToasterProvider.java index 64f2787456..3762740fca 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/ToasterProvider.java +++ b/opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/ToasterProvider.java @@ -1,8 +1,8 @@ package org.opendaylight.controller.sample.toaster.provider; + import java.util.Collection; import java.util.Collections; - import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; @@ -17,50 +17,32 @@ import org.osgi.framework.ServiceReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - public class ToasterProvider extends AbstractBindingAwareProvider { private static final Logger log = LoggerFactory.getLogger(ToasterProvider.class); - private ConsumerContext consumerContext; - private ProviderContext providerContext; - private OpendaylightToaster toaster; - - - public ToasterProvider() { - toaster = new OpendaylightToaster(); - } - - @Override - public void onSessionInitialized(ConsumerContext session) { - log.info("Consumer Session initialized"); - this.consumerContext = session; + private ProviderContext providerContext; + private OpendaylightToaster toaster; + + public ToasterProvider() { + toaster = new OpendaylightToaster(); + } + + @Override + public void onSessionInitiated(ProviderContext session) { + log.info("Provider Session initialized"); - } + this.providerContext = session; + toaster.setNotificationProvider(session.getSALService(NotificationProviderService.class)); + providerContext.addRpcImplementation(ToasterService.class, toaster); + } - @Override - public void onSessionInitiated(ProviderContext session) { - log.info("Provider Session initialized"); - - this.providerContext = session; - toaster.setNotificationProvider(session.getSALService(NotificationProviderService.class)); - providerContext.addRpcImplementation(ToasterService.class, toaster); - } - - - @Override - public Collection getImplementations() { - return Collections.emptySet(); - } + @Override + public Collection getImplementations() { + return Collections.emptySet(); + } - @Override - public Collection getFunctionality() { - return Collections.emptySet(); - } - - @Override - @Deprecated - protected void startImpl(BundleContext context) { - // TODO Auto-generated method stub - - } + @Override + public Collection getFunctionality() { + return Collections.emptySet(); + } }