<version>1.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
+/*
+ * 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;
@Override
public final void start(BundleContext context) throws Exception {
+ startImpl(context);
ServiceReference<BindingAwareBroker> 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.
+ *
+ * <p>
+ * 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.
+ *
+ * <p>
+ * 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);
}
}
+/*
+ * 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;
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:
+ * <ol>
+ * <li>{@link #startImpl(BundleContext)}
+ * <li>{@link #onSessionInitiated(ProviderContext)}
+ * <li>Registration of global {@link RpcService} implementations returned by
+ * {@link #getImplementations()}
+ * <li>Registration of {@link ProviderFunctionality} implementations
+ * returned by {@link #getFunctionality()}
+ * </ol>
+ *
+ */
@Override
public final void start(BundleContext context) throws Exception {
- ServiceReference<BindingAwareBroker> 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<BindingAwareBroker> 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<? extends ProviderFunctionality> 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<? extends RpcService> 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.
+ *
+ * <p>
+ * 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.
+ *
+ * <p>
+ * 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<? extends ProviderFunctionality> getFunctionality() {
- return null;
+ return Collections.emptySet();
}
-
+
@Override
public Collection<? extends RpcService> 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
}
}
*/
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;
<T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
throws IllegalStateException;
- <T extends RpcService> RpcRegistration<T> addMountRpcImplementation(Class<T> type,
- InstanceIdentifier mount, T implementation) throws IllegalStateException;
+ <T extends RpcService> RpcRegistration<T> addMountRpcImplementation(Class<T> type, InstanceIdentifier<?> mount,
+ T implementation) throws IllegalStateException;
<T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
throws IllegalStateException;
-
+
void registerFunctionality(ProviderFunctionality functionality);
+
void unregisterFunctionality(ProviderFunctionality functionality);
}
- public interface RpcRegistration<T extends RpcService> {
+ public interface RpcRegistration<T extends RpcService> extends Registration<T> {
/**
*
* @return instance for which registration does exists.
*/
+ @Deprecated
T getService();
-
- /**
- * Unregister an RpcService from broker.
- *
- */
- void unregister();
}
- public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T> {
+ public interface RoutedRpcRegistration<T extends RpcService> extends RpcRegistration<T>,
+ RoutedRegistration<Class<? extends BaseIdentity>, 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<? extends BaseIdentity> context, InstanceIdentifier instance);
+ @Deprecated
+ void registerInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
- void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier instance);
+ @Deprecated
+ void unregisterInstance(Class<? extends BaseIdentity> context, InstanceIdentifier<?> instance);
}
}
*/
public interface BindingAwareProvider {
- void onSessionInitialized(ConsumerContext session);
-
/**
* Returns a set of provided implementations of YANG modules and their rpcs.
*
void onSessionInitiated(ProviderContext session);
+ void onSessionInitialized(ConsumerContext session);
+
}
+/*
+ * 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<T> {
+import java.util.EventListener;
+
+import org.opendaylight.yangtools.yang.binding.Notification;
+
+public interface NotificationListener<T extends Notification> extends EventListener {
void onNotification(T notification);
}
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<Notification> {
+ @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 <T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(
+ Class<T> notificationType, NotificationListener<T> listener);
+
+ @Override
+ public Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
+ org.opendaylight.yangtools.yang.binding.NotificationListener listener);
}
*/
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
<T extends Notification> void addNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
+
+ @Deprecated
void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener);
+
+ @Deprecated
void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener);
+
+ @Deprecated
<T extends Notification> void removeNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
+
+ <T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(
+ Class<T> notificationType, NotificationListener<T> listener);
+
+
+ Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
+ org.opendaylight.yangtools.yang.binding.NotificationListener listener);
}
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;
*
* @see DataProviderService
*/
-public interface DataBrokerService extends BindingAwareService {
+public interface DataBrokerService extends //
+ BindingAwareService, //
+ DataModificationTransactionFactory<InstanceIdentifier<? extends DataObject>, DataObject>, //
+ DataReader<InstanceIdentifier<? extends DataObject>, DataObject>, //
+ DataChangePublisher<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> {
/**
* Returns a data from specified Data Store.
* Identifier of the store, from which will be data retrieved
* @return data visible to the consumer
*/
+ @Deprecated
<T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType);
/**
@Deprecated
Future<RpcResult<Void>> commit(DataStoreIdentifier store);
-
- DataObject getData(InstanceIdentifier data);
-
- DataObject getConfigurationData(InstanceIdentifier data);
+ @Deprecated
+ DataObject getData(InstanceIdentifier<? extends DataObject> 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<? extends DataObject> path, DataChangeListener changeListener);
+
+ @Deprecated
+ public void unregisterChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener);
}
+++ /dev/null
-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<InstanceIdentifier, DataObject> getCreated();
-
- Map<InstanceIdentifier, DataObject> getUpdated();
-
- Set<InstanceIdentifier> getRemoved();
-}
+/*
+ * 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<InstanceIdentifier<? extends DataObject>, DataObject> {
+
+ @Override
+ public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change);
}
+++ /dev/null
-/*
- * 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.
- *
- * <p>
- * 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.
- *
- * <p>
- * 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.
- *
- * <h3>Two-phase commit</h3>
- *
- * <h4>Commit Request Phase</h4>
- *
- * <ol>
- * <li> <code>Consumer</code> edits data by invocation of
- * <code>DataBrokerService.editCandidateData(DataStoreIdentifier, DataRoot)</code>
- * <li> <code>Consumer</code> starts a commit by invoking
- * <code>DataBrokerService.commit(DataStoreIdentifier)</code>
- * <li> <code>Broker</code> retrieves a list of all registered
- * <code>DataCommitHandlers</code>
- * <li>For each <code>DataCommitHandler</code>
- * <ol>
- * <li><code>Broker</code> invokes a
- * <code>DataCommitHandler.requestCommit(DataStoreIdentifier)</code> operation.
- * <li><code>DataCommitHandler</code> returns a <code>RpcResult</code> with
- * <code>CommitTransaction</code>
- * <li>If the result was successful, broker adds <code>CommitTransaction</code>
- * to the list of opened transactions. If not, brokers stops a commit request
- * phase and starts a rollback phase.
- * </ol>
- * <li><code>Broker</code> starts a commit finish phase
- * </ol>
- *
- * <h4>Commit Finish Phase</h4>
- *
- * <ol>
- * <li>For each <code>CommitTransaction</code> from Commit Request phase
- * <ol>
- * <li><code>Broker</code> broker invokes a
- * <code>CommitTransaction.finish()</code>
- * <li>The provider finishes a commit (applies the change) and returns an
- * <code>RpcResult</code>.
- * </ol>
- * <li>
- * <ul>
- * <li>If all returned results means successful, the brokers end two-phase
- * commit by returning a success commit result to the Consumer.
- * <li>If error occured, the broker starts a commit rollback phase.
- * </ul>
- * </ol>
- *
- * <h4>Commit Rollback Phase</h4>
- * <li>For each <code>CommitTransaction</code> from Commit Request phase
- * <ol>
- * <li><code>Broker</code>
- * broker invokes a {@link CommitTransaction#finish()}
- * <li>The provider rollbacks a commit and returns an {@link RpcResult} of
- * rollback. </ol>
- * <li>Broker returns a error result to the consumer.
- *
- *
- * <h3>Registration of functionality</h3>
- * The registration could be done by :
- * <ul>
- * <li>returning an instance of implementation in the return value of
- * {@link Provider#getProviderFunctionality()}
- * <li>passing an instance of implementation and {@link DataStoreIdentifier} of
- * rpc as arguments to the
- * {@link DataProviderService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)}
- * </ul>
- *
- *
- *
- */
-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<DataStoreIdentifier> getSupportedDataStores();
-
- /**
- * The provider (commit handler) starts a commit transaction.
- *
- * <p>
- * The commit handler (provider) prepares an commit scenario, rollback
- * scenario and validates data.
- *
- * <p>
- * 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<CommitTransaction> requestCommit(DataStoreIdentifier store);
-
-
- RpcResult<CommitTransaction> 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<Void> finish() throws IllegalStateException;
-
- /**
- * Rollbacks a commit.
- *
- * @return
- * @throws IllegalStateException
- * If the method is invoked after {@link #finish()}
- */
- RpcResult<Void> rollback() throws IllegalStateException;
- }
-
-}
+++ /dev/null
-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<InstanceIdentifier,DataObject> getRuntimeDataUpdates();
- Map<InstanceIdentifier,DataObject> getConfigurationDataUpdates();
- Set<InstanceIdentifier> getRemovals();
- Set<InstanceIdentifier> 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<RpcResult<TransactionStatus>> 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);
-
- }
-}
--- /dev/null
+/*
+ * 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<InstanceIdentifier<? extends DataObject>, DataObject> {
+
+ ListenerRegistration<DataTransactionListener> registerListener(DataTransactionListener listener);
+
+
+ //FIXME: After 0.6 Release of YANG-Binding
+ //public <T extends DataObject> T readOperationalData(InstanceIdentifier<T> path);
+ //public <T extends DataObject> T readConfigurationData(InstanceIdentifier<T> path);
+
+ public interface DataTransactionListener extends EventListener {
+ void onStatusUpdated(DataModificationTransaction transaction,TransactionStatus status);
+ }
+}
*/
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<InstanceIdentifier<? extends DataObject>, DataObject> {
}
+++ /dev/null
-/*
- * 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<Void> validate(DataRoot data);
-}
+/*
+ * 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<DataStoreIdentifier> getSupportedStores();
-
-
- Set<Class<? extends DataRoot>> getProvidedDataRoots();
+public interface RuntimeDataProvider extends ProviderFunctionality,DataReader<InstanceIdentifier<? extends DataObject>, DataObject> {
- /**
- * Returns a data from specified Data Store.
- *
- * Returns all the data visible to the consumer from specified Data Store.
- *
- * @param <T>
- * 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 extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType);
- /**
- * Returns a filtered subset of data from specified Data Store.
- *
- * <p>
- * 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 <code>get</code> and <code>get-config</code>
- * in Section 6 of RFC6241.
- *
- *
- * @see http://tools.ietf.org/html/rfc6241#section-6
- * @param <T>
- * 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 extends DataRoot> T getData(DataStoreIdentifier store, T filter);
-
-
- <T extends DataObject> T getData(Class<T> dataType, InstanceIdentifier identifier);
}
public interface MountInstance extends NotificationService, DataBrokerService {
<T extends RpcService> T getRpcService(Class<T> rpcService);
-
+
}
public interface MountService extends BindingAwareService {
- MountInstance getMountPoint(InstanceIdentifier path);
+ MountInstance getMountPoint(InstanceIdentifier<?> path);
}
<artifactId>sal-common-util</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-impl</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-api</artifactId>
+/*
+ * 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;
throw new IllegalArgumentException("delegate class is not assignable to proxy");
}
- public static def Map<InstanceIdentifier, ? extends RpcService> getRoutingTable(RpcService target,
+ public static def Map<InstanceIdentifier<?>, ? extends RpcService> getRoutingTable(RpcService target,
Class<? extends BaseIdentity> 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<InstanceIdentifier, ? extends RpcService>;
+ return field.get(target) as Map<InstanceIdentifier<? extends Object>, ? extends RpcService>;
}
public static def void setRoutingTable(RpcService target, Class<? extends BaseIdentity> tableClass,
- Map<InstanceIdentifier, ? extends RpcService> routingTable) {
+ Map<InstanceIdentifier<?>, ? 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");
+/*
+ * 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
private var RuntimeCodeGenerator generator;
private Map<Class<? extends RpcService>, RpcProxyContext> managedProxies = new HashMap();
private var NotificationBrokerImpl notifyBroker
+ private var DataBrokerImpl dataBroker
private var ServiceRegistration<NotificationProviderService> notifyBrokerRegistration
@Property
return new RpcServiceRegistrationImpl<T>(type, service, osgiReg);
}
- def <T extends RpcService> RpcRegistration<T> registerMountedRpcImplementation(Class<T> tyoe, T service, InstanceIdentifier identifier,
+ def <T extends RpcService> RpcRegistration<T> registerMountedRpcImplementation(Class<T> tyoe, T service, InstanceIdentifier<?> identifier,
OsgiProviderContext context, Hashtable<String, String> properties) {
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}
public class BrokerActivator implements BundleActivator {
- private static final Logger log = LoggerFactory.getLogger(BrokerActivator.class);
- private BindingAwareBrokerImpl baSal;
- private ServiceRegistration<BindingAwareBroker> 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<String, String> 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<BindingAwareBroker> 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<String, String> 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();
+ }
}
--- /dev/null
+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 <T extends DataRoot> getCandidateData(DataStoreIdentifier store, Class<T> rootType) {
+ throw new UnsupportedOperationException("Deprecated")
+ }
+
+ override <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {
+ throw new UnsupportedOperationException("Deprecated")
+ }
+
+ override getConfigurationData(InstanceIdentifier<?> data) {
+ throw new UnsupportedOperationException("Deprecated")
+ }
+
+ override <T extends DataRoot> getData(DataStoreIdentifier store, Class<T> rootType) {
+ throw new UnsupportedOperationException("Deprecated")
+ }
+
+ override <T extends DataRoot> T getData(DataStoreIdentifier store, T filter) {
+ throw new UnsupportedOperationException("Deprecated")
+ }
+
+ override getData(InstanceIdentifier<? extends DataObject> path) {
+ return readOperationalData(path);
+ }
+
+ override readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
+ }
+
+ override readOperationalData(InstanceIdentifier<? extends DataObject> path) {
+ }
+
+ override registerChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {
+ }
+
+ override registerCommitHandler(InstanceIdentifier<? extends DataObject> path,
+ DataCommitHandler<InstanceIdentifier<? extends DataObject>, DataObject> commitHandler) {
+ }
+
+ override registerDataChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener listener) {
+ }
+
+ override unregisterChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {
+ }
+
+}
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 {
}
override notify(Notification notification) {
- notification.notificationTypes.forEach [
- listeners.get(it as Class<? extends Notification>)?.notifyAll(notification)
- ]
+ publish(notification)
}
def getNotificationTypes(Notification notification) {
def notifyAll(Collection<NotificationListener<?>> 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<? extends Notification>)?.notifyAll(notification)
+ ]
+ }
+
+ override publish(Notification notification, ExecutorService service) {
+ publish(notification)
+ }
+
+ override <T extends Notification> registerNotificationListener(Class<T> notificationType,
+ NotificationListener<T> listener) {
+ val reg = new GenericNotificationRegistration<T>(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<T extends Notification> implements Registration<NotificationListener<T>> {
+
+ @Property
+ var NotificationListener<T> instance;
+
+ @Property
+ val Class<T> type;
+
+
+ val NotificationBrokerImpl notificationBroker;
+
+ public new(Class<T> type, NotificationListener<T> instance,NotificationBrokerImpl broker) {
+ _instance = instance;
+ _type = type;
+ notificationBroker = broker;
+ }
+
+ override close() {
+ notificationBroker.unregisterListener(this);
}
}
return salReg;
}
- override <T extends RpcService> addMountRpcImplementation(Class<T> type, InstanceIdentifier mount, T implementation) throws IllegalStateException {
+ override <T extends RpcService> addMountRpcImplementation(Class<T> type, InstanceIdentifier<?> mount, T implementation) throws IllegalStateException {
val properties = new Hashtable<String, String>();
properties.salServiceType = SAL_SERVICE_TYPE_PROVIDER
override getService() {
this.service
}
+
+ override getInstance() {
+ this.service
+ }
- override unregister() {
+ override close() {
throw new UnsupportedOperationException("TODO: auto-generated method stub")
}
}
+++ /dev/null
-/*
- * 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<DataStoreIdentifier, DataProviderContext> dataProviders;
- var DataProviderContext defaultDataProvider;
-
- override <T extends DataRoot> getData(DataStoreIdentifier store, Class<T> rootType) {
- val dataStore = resolveProvider(store, rootType);
- return dataStore.provider.getData(store, rootType);
- }
-
- override <T extends DataRoot> getData(DataStoreIdentifier store, T filter) {
- }
-
- override <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {
- throw new UnsupportedOperationException("TODO: auto-generated method stub");
- }
-
- override <T extends DataRoot> 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<? extends DataRoot> 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")
- }
-
-}
+/*
+ * 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<T> {
+/*
+ * 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;
* @return instance of RpcService which is responsible for processing
* particular path.
*/
- T getService(Class<? extends BaseIdentity> context, InstanceIdentifier path);
+ T getService(Class<? extends BaseIdentity> context, InstanceIdentifier<?> path);
/**
* Returns a default fallback instance of RpcService which is responsible
+/*
+ * 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<C extends BaseIdentity,S extends RpcService> {
+public interface RpcRoutingTable<C extends BaseIdentity, S extends RpcService> extends
+ MutableRoutingTable<Class<? extends C>, InstanceIdentifier<?>, S> {
+
+ Class<C> getIdentifier();
- Class<C> 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<InstanceIdentifier,S> getRoutes();
+ Map<InstanceIdentifier<?>, S> getRoutes();
}
+++ /dev/null
-/**
- *
- */
-/**
- * @author ttkacik
- *
- */
-package org.opendaylight.controller.sal.binding.spi;
\ No newline at end of file
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;
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;
}
private void verifyRouting(FooService product) {
- Map<InstanceIdentifier,FooService> routingTable = new HashMap<>();
+ Map<InstanceIdentifier<? extends Object>,FooService> routingTable = new HashMap<>();
setRoutingTable(product, BaseIdentity.class, routingTable);
assertSame("Returned routing table should be same instance",routingTable,getRoutingTable(product, BaseIdentity.class));
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<service.length;i++) {
- for (InstanceIdentifier instance : identifiers[i]) {
+ for (InstanceIdentifier<?> instance : identifiers[i]) {
routingTable.put(instance, service[i]);
}
}
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<serviceSize;i++) {
- InstanceIdentifier[] instanceIdentifiers = new InstanceIdentifier[instancesPerService];
+ InstanceIdentifier<?>[] instanceIdentifiers = new InstanceIdentifier[instancesPerService];
ret[i] = instanceIdentifiers;
for(int id = 0;id<instancesPerService;id++) {
instanceIdentifiers[id] = referencableIdentifier(service*instancesPerService+id);
return ret;
}
- private InstanceIdentifier referencableIdentifier(int i) {
+ private InstanceIdentifier<?> referencableIdentifier(int i) {
ReferencableObjectKey key = new ReferencableObjectKey(i);
IdentifiableItem<ReferencableObject,ReferencableObjectKey> pathArg = new IdentifiableItem<>(ReferencableObject.class,key);
- return new InstanceIdentifier(Arrays.<PathArgument>asList(pathArg), ReferencableObject.class);
+ return new InstanceIdentifier<ReferencableObject>(Arrays.<PathArgument>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;
}
}
@Override
- public InstanceIdentifier getIdentifier() {
+ public InstanceIdentifier<?> getIdentifier() {
return this.identifier;
}
}
public interface Grouping {
@RoutingContext(BaseIdentity.class)
- InstanceIdentifier getInheritedIdentifier();
+ InstanceIdentifier<?> getInheritedIdentifier();
}
</scm>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>concepts</artifactId>
- <version>0.1.0</version>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-common</artifactId>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-common</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>concepts</artifactId>
+ <version>0.1.1-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>5.0.0</version>
</dependency>
</dependencies>
+ <packaging>bundle</packaging>
</project>
--- /dev/null
+/*
+ * 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
+}
--- /dev/null
+/*
+ * 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<P/* extends Path<P> */,D> {
+
+ Map<P,D> getCreatedOperationalData();
+
+ Map<P,D> getUpdatedOperationalData();
+
+ Set<P> getRemovedOperationalData();
+
+ Map<P,D> getCreatedConfigurationData();
+
+ Map<P,D> getUpdatedConfigurationData();
+
+ Set<P> getRemovedConfigurationData();
+
+}
--- /dev/null
+/*
+ * 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<P,D> extends DataChange<P, D>, Immutable {
+
+}
--- /dev/null
+/*
+ * 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<P/* extends Path<P> */,D> extends EventListener {
+
+ void onDataChanged(DataChangeEvent<P, D> change);
+}
--- /dev/null
+/*
+ * 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<P/* extends Path<P> */,D, L extends DataChangeListener<P,D>> {
+
+ ListenerRegistration<L> registerDataChangeListener(P path, L listener);
+
+}
* 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.
*
*
* <ol>
* <li> <code>Consumer</code> edits data by invocation of
- * <code>DataBrokerService.editCandidateData(DataStoreIdentifier, CompositeNodeModification)</code>
+ * <code>DataBrokerService.editCandidateData(DataStoreIdentifier, DataRoot)</code>
* <li> <code>Consumer</code> starts a commit by invoking
* <code>DataBrokerService.commit(DataStoreIdentifier)</code>
* <li> <code>Broker</code> retrieves a list of all registered
* </ol>
*
* <h4>Commit Rollback Phase</h4>
- * <li>For each <code>CommitTransaction</code> from Commit Request phase
+ * <li>For each <code>DataCommitTransaction</code> from Commit Request phase
* <ol>
* <li><code>Broker</code>
- *
- * broker invokes a {@link CommitTransaction#finish()}
+ * broker invokes a {@link DataCommitTransaction#finish()}
* <li>The provider rollbacks a commit and returns an {@link RpcResult} of
* rollback. </ol>
* <li>Broker returns a error result to the consumer.
*
- *
- * <h3>Registration of functionality</h3>
- * The registration could be done by :
- * <ul>
- * <li>returning an instance of implementation in the return value of
- * {@link Provider#getProviderFunctionality()}
- * <li>passing an instance of implementation and {@link DataStoreIdentifier} of
- * rpc as arguments to the
- * {@link DataProviderService#addCommitHandler(DataStoreIdentifier, DataCommitHandler)}
- * </ul>
- *
- *
+ * @param <P> Class representing a path
+ * @param <D> Superclass from which all data objects are derived from.
*/
-public interface DataCommitHandler extends Provider.ProviderFunctionality {
+public interface DataCommitHandler<P/* extends Path<P> */,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<DataStoreIdentifier> getSupportedDataStores();
- /**
- * The provider (commit handler) starts a commit transaction.
- *
- * <p>
- * The commit handler (provider) prepares an commit scenario, rollback
- * scenario and validates data.
- *
- * <p>
- * 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<CommitTransaction> requestCommit(DataStoreIdentifier store);
+ DataCommitTransaction<P, D> requestCommit(DataModification<P,D> modification);
- public interface CommitTransaction {
- /**
- *
- * @return Data store affected by the transaction
- */
- DataStoreIdentifier getDataStore();
+ public interface DataCommitTransaction<P/* extends Path<P> */,D> {
- /**
- * Returns the handler associated with this transaction.
- *
- * @return Handler
- */
- DataCommitHandler getHandler();
+ DataModification<P,D> 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-
*
/**
* 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<Void> rollback() throws IllegalStateException;
}
+
}
--- /dev/null
+/*
+ * 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<P/* extends Path<P> */, D> extends DataReader<P, D> {
+
+ /**
+ * 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<P, D> getUpdatedConfigurationData();
+
+ public Map<P, D> getUpdatedOperationalData();
+
+ public Set<P> getRemovedConfigurationData();
+
+ public Set<P> getRemovedOperationalData();
+
+ /**
+ * Initiates a two-phase commit of modification.
+ *
+ * <p>
+ * The successful commit changes the state of the system and may affect
+ * several components.
+ *
+ * <p>
+ * 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<RpcResult<TransactionStatus>> commit();
+
+}
--- /dev/null
+/*
+ * 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<P/* extends Path<P> */,D> {
+
+ DataModification<P, D> beginTransaction();
+}
--- /dev/null
+/*
+ * 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<P/* extends Path<P> */,D> extends DataReader<P, D> {
+
+}
--- /dev/null
+/*
+ * 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<P/* extends Path<P> */, D> {
+
+ public Registration<DataCommitHandler<P, D>> registerCommitHandler(P path, DataCommitHandler<P, D> commitHandler);
+
+}
--- /dev/null
+/*
+ * 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<P/* extends Path<P> */,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);
+}
--- /dev/null
+/*
+ * 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<N> {
+
+ void publish(N notification);
+
+ void publish(N notification,ExecutorService executor);
+}
--- /dev/null
+/*
+ * 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<T,N,L> {
+
+ Registration<L> registerNotificationListener(T type,L listener);
+}
--- /dev/null
+/*
+ * 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<C,P/* extends Path<P> */,T> extends RoutingTable<C,P,T>, Mutable {
+
+ void setDefaultRoute(T target);
+ void updateRoute(P path,T target);
+ void removeRoute(P path);
+}
--- /dev/null
+/*
+ * 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<C,P> {
+
+ Map<C,Set<P>> getRemovals();
+ Map<C,Set<P>> getAnnouncements();
+}
--- /dev/null
+/*
+ * 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<C,P/* extends Path<P> */,S> extends Registration<S> {
+
+ void registerPath(C context, P path);
+ void unregisterPath(C context, P path);
+
+}
--- /dev/null
+/*
+ * 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<C,P/* extends Path<P> */,T> {
+
+ C getIdentifier();
+
+ T getDefaultRoute();
+
+ Map<P,T> getRoutes();
+
+ T getRoute(P path);
+}
--- /dev/null
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>sal-common-impl</artifactId>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+ </scm>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ </dependencies>
+ <packaging>bundle</packaging>
+</project>
--- /dev/null
+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<P extends Path<P>, D> implements DataChange<P, D> {
+
+ private final Map<P, D> createdCfg;
+ private final Map<P, D> createdOperational;
+ private final Set<P> removedCfg;
+ private final Set<P> removedOperational;
+ private final Map<P, D> updatedCfg;
+ private final Map<P, D> updatedOperational;
+
+ public AbstractDataChange(Map<P, D> createdCfg, Map<P, D> createdOperational, Set<P> removedCfg,
+ Set<P> removedOperational, Map<P, D> updatedCfg, Map<P, D> updatedOperational) {
+ this.createdCfg = createdCfg;
+ this.createdOperational = createdOperational;
+ this.removedCfg = (removedCfg);
+ this.removedOperational = (removedOperational);
+ this.updatedCfg = (updatedCfg);
+ this.updatedOperational = (updatedOperational);
+ }
+
+ @Override
+ public final Map<P, D> getCreatedConfigurationData() {
+ return this.createdCfg;
+ }
+
+ @Override
+ public final Map<P, D> getCreatedOperationalData() {
+ return this.createdOperational;
+ }
+
+ @Override
+ public final Set<P> getRemovedConfigurationData() {
+ return this.removedCfg;
+ }
+
+ @Override
+ public final Set<P> getRemovedOperationalData() {
+ return this.removedOperational;
+ }
+
+ @Override
+ public final Map<P, D> getUpdatedConfigurationData() {
+ return this.updatedCfg;
+ }
+
+ @Override
+ public final Map<P, D> getUpdatedOperationalData() {
+ return this.updatedOperational;
+ }
+
+}
--- /dev/null
+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<P extends Path<P>, D> implements DataModification<P, D> {
+
+ private final Map<P,D> configurationUpdate;
+ private final Map<P,D> operationalUpdate;
+
+ private final Set<P> configurationRemove;
+ private final Set<P> operationalRemove;
+
+ private final Map<P, D> unmodifiable_configurationUpdate;
+ private final Map<P, D> unmodifiable_operationalUpdate;
+ private final Set<P> unmodifiable_configurationRemove;
+ private final Set<P> unmodifiable_OperationalRemove;
+
+
+
+ public AbstractDataModification(Map<P, D> configurationUpdate, Map<P, D> operationalUpdate,
+ Set<P> configurationRemove, Set<P> 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<P,D>(), new HashMap<P,D>(), new HashSet<P>(), new HashSet<P>());
+ }
+
+ @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<P, D> getUpdatedConfigurationData() {
+
+ return unmodifiable_configurationUpdate;
+ }
+
+ @Override
+ public Map<P, D> getUpdatedOperationalData() {
+ return unmodifiable_operationalUpdate;
+ }
+
+ @Override
+ public Set<P> getRemovedConfigurationData() {
+ return unmodifiable_configurationRemove;
+ }
+
+ @Override
+ public Set<P> getRemovedOperationalData() {
+ return unmodifiable_OperationalRemove;
+ }
+
+}
--- /dev/null
+package org.opendaylight.controller.md.sal.common.impl;
+
+import org.opendaylight.yangtools.concepts.Registration;
+
+public abstract class AbstractRegistration<T> implements Registration<T> {
+
+
+ private final T instance;
+
+ public AbstractRegistration(T instance) {
+ super();
+ this.instance = instance;
+ }
+
+ @Override
+ public final T getInstance() {
+ return instance;
+ }
+
+}
--- /dev/null
+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<C, P extends Path<P>, S> extends AbstractRegistration<S> implements
+ RoutedRegistration<C, P, S> {
+
+ public AbstractRoutedRegistration(S instance) {
+ super(instance);
+ }
+}
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-api</artifactId>
+ <version>0.5.9-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>sal-common-api</artifactId>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<version>5.0.0</version>
</dependency>
</dependencies>
+ <packaging>bundle</packaging>
</project>
+/*
+ * 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;
ServiceReference<Broker> 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<ConsumerFunctionality> getConsumerFunctionality() {
return Collections.emptySet();
+/*
+ * 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;
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);
}
}
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.
*
* {@link ProviderSession#addRpcImplementation(QName, RpcImplementation)} and
* {@link RpcImplementation}
* <li>Notification Service - see {@link NotificationService} and
- * {@link NotificationProviderService}
+ * {@link NotificationPublishService}
* <li>Functionality and Data model
* <li>Data Store access and modification - see {@link DataBrokerService} and
* {@link DataProviderService}
*
* @param cons
* Consumer to be registered.
- * @param context
+ * @param context
* @return a session specific to consumer registration
* @throws IllegalArgumentException
* If the consumer is <code>null</code>.
*
* @param prov
* Provider to be registered.
- * @param context
+ * @param context
* @return a session unique to the provider registration.
* @throws IllegalArgumentException
* If the provider is <code>null</code>.
* infrastructure services and other functionality provided by
* {@link Provider}s.
*
-
+ *
*
*/
public interface ConsumerSession {
* @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.
@Override
boolean isClosed();
}
+
+ public interface RpcRegistration extends Registration<RpcImplementation> {
+ QName getType();
+ }
+
+ public interface RoutedRpcRegistration extends RpcRegistration,
+ RoutedRegistration<QName, InstanceIdentifier, RpcImplementation> {
+ }
}
*/
public interface BrokerService {
- void closeSession();
}
*/
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;
/**
* @see DataProviderService
*
*/
-public interface DataBrokerService extends BrokerService {
-
-
- Set<DataStoreIdentifier> 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.
- *
- * <p>
- * 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 <code>get</code> and <code>get-config</code> 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<InstanceIdentifier, CompositeNode>, //
+ DataModificationTransactionFactory<InstanceIdentifier, CompositeNode>, //
+ DataChangePublisher<InstanceIdentifier, CompositeNode, DataChangeListener> {
- /**
- * 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.
- *
- * <p>
- * 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 <code>get</code> and <code>get-config</code> 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<CompositeNode> editCandidateData(DataStoreIdentifier store,
- MutableCompositeNode changeSet);
+ @Override
+ public CompositeNode readOperationalData(InstanceIdentifier path);
- /**
- * Initiates a two-phase commit of candidate data.
- *
- * <p>
- * The {@link Consumer} could initiate a commit of candidate data
- *
- * <p>
- * The successful commit changes the state of the system and may affect
- * several components.
- *
- * <p>
- * 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<RpcResult<Void>> commit(DataStoreIdentifier store);
+ DataModificationTransaction beginTransaction();
}
--- /dev/null
+/*
+ * 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<InstanceIdentifier, CompositeNode> {
+
+ @Override
+ public void onDataChanged(DataChangeEvent<InstanceIdentifier, CompositeNode> change);
+}
--- /dev/null
+/*
+ * 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<InstanceIdentifier, CompositeNode>{
+
+ /**
+ * 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<RpcResult<TransactionStatus>> commit();
+
+ ListenerRegistration<DataTransactionListener> registerListener(DataTransactionListener listener);
+
+
+ public interface DataTransactionListener extends EventListener {
+
+ void onStatusUpdated(DataModificationTransaction transaction,TransactionStatus status);
+
+ }
+
+
+
+}
*/
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<InstanceIdentifier, CompositeNode>
+ {
/**
* Adds {@link DataValidator} for specified Data Store
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
*
--- /dev/null
+/*
+ * 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<RpcResult<CompositeNode>> rpc(QName type, CompositeNode input);
+}
--- /dev/null
+/*
+ * 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);
+}
*/
package org.opendaylight.controller.sal.core.api.notify;
+import java.util.EventListener;
import java.util.Set;
import org.opendaylight.controller.sal.core.api.Consumer;
/**
* 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.
*
*
*
*/
-public interface NotificationProviderService extends NotificationService {
+public interface NotificationPublishService extends NotificationService {
/**
* Publishes a notification.
* @param notification
* Notification to publish
*/
+ @Deprecated
void sendNotification(CompositeNode notification);
+ void publish(CompositeNode notification);
}
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;
* @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<NotificationListener> addNotificationListener(QName notification,
NotificationListener listener);
}
val toStop = instantiatedServices.values();
this.closed = true;
for (BrokerService brokerService : toStop) {
- brokerService.closeSession();
+ //brokerService.closeSession();
}
broker.consumerSessionClosed(this);
}
+++ /dev/null
-/*
- * 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<Class<? extends ProviderFunctionality>> SUPPORTED_PROVIDER_FUNCTIONALITY = ImmutableSet
- .of((Class<? extends ProviderFunctionality>) DataValidator.class,
- DataRefresher.class, DataCommitHandler.class);
-
- private static final Set<Class<? extends BrokerService>> PROVIDED_SESSION_SERVICES = ImmutableSet
- .of((Class<? extends BrokerService>) DataBrokerService.class,
- DataProviderService.class);
-
- private Map<DataStoreIdentifier, StoreContext> storeContext;
-
- private ExecutorService executor;
-
- private SequentialCommitHandlerCoordinator coordinator = new SequentialCommitHandlerCoordinator();
-
- @Override
- public Set<Class<? extends BrokerService>> getProvidedServices() {
- return PROVIDED_SESSION_SERVICES;
- }
-
- @Override
- public Set<Class<? extends ProviderFunctionality>> getSupportedProviderFunctionality() {
- return SUPPORTED_PROVIDER_FUNCTIONALITY;
- }
-
- @Override
- public Set<Class<? extends ConsumerFunctionality>> getSupportedConsumerFunctionality() {
- return Collections.emptySet();
- }
-
- @Override
- public <T extends BrokerService> T getServiceForSession(Class<T> 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<DataCommitHandler> commitHandlers = Collections
- .synchronizedSet(new HashSet<DataCommitHandler>());
- private Set<DataValidator> validators = Collections
- .synchronizedSet(new HashSet<DataValidator>());
- private Set<DataRefresher> refreshers = Collections
- .synchronizedSet(new HashSet<DataRefresher>());
- }
-
- 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<CompositeNode> editCandidateData(
- DataStoreIdentifier store, MutableCompositeNode changeSet) {
- // TODO Implement this method
- throw new UnsupportedOperationException("Not implemented");
- }
-
- @Override
- public Future<RpcResult<Void>> 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<DataStoreIdentifier> getDataStores() {
- // TODO Auto-generated method stub
- return null;
- }
-
- }
-
- private class DataProviderSession extends DataConsumerSession implements
- DataProviderService {
-
- private Set<DataCommitHandler> providerCommitHandlers = new HashSet<DataCommitHandler>();
- private Set<DataValidator> providerValidators = new HashSet<DataValidator>();
- private Set<DataRefresher> providerRefreshers = new HashSet<DataRefresher>();
-
- @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<CommitTransaction> requestCommit(
- DataStoreIdentifier store) {
- List<RpcError> errors = new ArrayList<RpcError>();
- Set<CommitTransaction> transactions = new HashSet<DataCommitHandler.CommitTransaction>();
- boolean successful = true;
-
- for (DataCommitHandler commitHandler : context(store).commitHandlers) {
- try {
- RpcResult<CommitTransaction> 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<DataStoreIdentifier> getSupportedDataStores() {
- return Collections.emptySet();
- }
- }
-
- private class SequentialCommitTransaction implements CommitTransaction {
-
- final Set<CommitTransaction> transactions;
- final DataStoreIdentifier store;
-
- public SequentialCommitTransaction(DataStoreIdentifier s,
- Set<CommitTransaction> t) {
- transactions = t;
- store = s;
- }
-
- @Override
- public RpcResult<Void> finish() {
- List<RpcError> errors = new ArrayList<RpcError>();
- boolean successful = true;
-
- for (CommitTransaction commitHandler : transactions) {
- try {
- RpcResult<Void> 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<Void> rollback() {
- List<RpcError> errors = new ArrayList<RpcError>();
- boolean successful = true;
-
- for (CommitTransaction commitHandler : transactions) {
- try {
- RpcResult<Void> 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<Void> validate(CompositeNode toValidate) {
- List<RpcError> errors = new ArrayList<RpcError>();
- boolean successful = true;
-
- for (DataValidator validator : context(store).validators) {
- try {
- RpcResult<Void> 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<DataStoreIdentifier> 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);
- }
-
- }
- }
- }
-}
--- /dev/null
+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
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;
.create();
private static final Set<Class<? extends BrokerService>> PROVIDED_SERVICE_TYPE = ImmutableSet
- .of((Class<? extends BrokerService>) NotificationService.class,
- NotificationProviderService.class);
+ .<Class<? extends BrokerService>>of(NotificationService.class,
+ NotificationPublishService.class);
private static final Set<Class<? extends ConsumerFunctionality>> SUPPORTED_CONSUMER_FUNCTIONALITY = ImmutableSet
.of((Class<? extends ConsumerFunctionality>) NotificationListener.class,
@Override
public <T extends BrokerService> T getServiceForSession(Class<T> 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)) {
return new NotificationConsumerSessionImpl();
}
- private NotificationProviderService newNotificationProviderService(
+ private NotificationPublishService newNotificationPublishService(
ConsumerSession session) {
return new NotificationProviderSessionImpl();
}
.create();
private boolean closed = false;
- @Override
- public void addNotificationListener(QName notification,
+
+ public Registration<NotificationListener> addNotificationListener(QName notification,
NotificationListener listener) {
checkSessionState();
if (notification == null) {
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();
listeners.remove(notification, listener);
}
- @Override
public void closeSession() {
closed = true;
Map<QName, Collection<NotificationListener>> toRemove = consumerListeners
private class NotificationProviderSessionImpl extends
NotificationConsumerSessionImpl implements
- NotificationProviderService {
+ NotificationPublishService {
@Override
public void sendNotification(CompositeNode notification) {
"Notification must not be null.");
NotificationModule.this.sendNotification(notification);
}
+
+ @Override
+ public void publish(CompositeNode notification) {
+ sendNotification(notification);
+ }
}
@Override
}
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(
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")
+ }
+
}
<version>1.0-SNAPSHOT</version>\r
</dependency>\r
</dependencies>\r
+ <packaging>bundle</packaging>\r
</project>\r