<prerequisites>
<maven>3.0</maven>
</prerequisites>
- <groupId>org.opendaylight.controller</groupId>
<artifactId>commons.opendaylight</artifactId>
<version>1.4.2-SNAPSHOT</version>
<packaging>pom</packaging>
<artifactId>yang-model-api</artifactId>
<version>${yangtools.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-model-util</artifactId>
+ <version>${yangtools.version}</version>
+ </dependency>
+
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>hosttracker</artifactId>
}
in.discardReadBytes();
}
+
}
+
import org.opendaylight.yangtools.concepts.Identifier;
public class TransactionIdentifier implements Identifier {
-
+ private static final long serialVersionUID = 1L;
private final String name;
public TransactionIdentifier(String name) {
package org.opendaylight.controller.config.persist.storage.file.xml.model;
final class PersistException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
public PersistException(String s, Exception e) {
super(s, e);
import org.opendaylight.yangtools.yang.common.QName;
public class NameConflictException extends RuntimeException {
-
+ private static final long serialVersionUID = 1L;
private static final String messageBlueprint = "Name conflict for name: %s, first defined in: %s, then defined in: %s";
private final String conflictingName;
private final QName secondParentQName;
@Test
public void testReadingIdentities_threadsJavaModule() {
- Map<String /* identity name */, Optional<QName>> expectedIdentitiesToBases = new HashMap(){{
+ Map<String /* identity name */, Optional<QName>> expectedIdentitiesToBases = new HashMap<String, Optional<QName>>(){
+ private static final long serialVersionUID = 1L;
+
+ {
put(ModuleMXBeanEntryTest.EVENTBUS_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
put(ModuleMXBeanEntryTest.ASYNC_EVENTBUS_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
put(ModuleMXBeanEntryTest.THREADFACTORY_NAMING_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
put(ModuleMXBeanEntryTest.THREADPOOL_DYNAMIC_MXB_NAME, Optional.of(MODULE_TYPE_Q_NAME));
- put("thread-rpc-context", Optional.absent());
+ put("thread-rpc-context", Optional.<QName>absent());
put(ModuleMXBeanEntryTest.THREADPOOL_REGISTRY_IMPL_NAME, Optional.of(MODULE_TYPE_Q_NAME));
}};
import org.opendaylight.controller.sal.common.util.Futures;
import org.opendaylight.controller.sal.common.util.Rpcs;
import org.opendaylight.controller.sal.compatibility.InventoryMapping;
-import org.opendaylight.controller.sal.compatibility.NodeMapping;
import org.opendaylight.controller.sal.compatibility.ToSalConversionsUtils;
-import org.opendaylight.controller.sal.core.ConstructionException;
import org.opendaylight.controller.sal.flowprogrammer.Flow;
import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerListener;
import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
import yang-ext {prefix ext; revision-date "2013-07-09";}
import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
- import opendaylight-flow-types {prefix types;revision-date "2013-10-26";}
+ import opendaylight-flow-types {prefix types;revision-date "2013-10-26";}
+ import opendaylight-group-types {prefix group-type;revision-date 2013-10-18;}
+ import opendaylight-meter-types {prefix meter-type;revision-date "2013-09-18";}
import flow-capable-transaction {prefix tr;}
import flow-errors {prefix error;}
uses error:error-message;
uses tr:transaction-aware;
uses tr:transaction-metadata;
+ choice object-reference {
+ case flow-ref{
+ leaf flow-ref {
+ type types:flow-ref;
+ }
+ }
+ case group-ref{
+ leaf group-ref {
+ type group-type:group-ref;
+ }
+ }
+ case meter-ref{
+ leaf meter-ref {
+ type meter-type:meter-ref;
+ }
+ }
+ }
+ leaf node {
+ ext:context-reference "inv:node-context";
+ type inv:node-ref;
+ }
+
}
notification node-experimenter-error-notification {
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
- <!-- Java Versions -->
- <maven.compiler.source>1.7</maven.compiler.source>
- <maven.compiler.target>1.7</maven.compiler.target>
<!-- Plugin Versions -->
<bundle.plugin.version>2.4.0</bundle.plugin.version>
- <releaseplugin.version>2.3.2</releaseplugin.version>
+ <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
<!-- Dependency Versions -->
- <slf4j.version>1.7.2</slf4j.version>
- <guava.version>14.0.1</guava.version>
- <osgi.core.version>5.0.0</osgi.core.version>
- <junit.version>4.8.1</junit.version>
<mockito.version>1.9.5</mockito.version>
<xtend.version>2.4.3</xtend.version>
- <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
- <jacoco.version>0.5.3.201107060350</jacoco.version>
<!-- Sonar properties using jacoco to retrieve integration test results -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sal.version>0.7.1-SNAPSHOT</sal.version>
</properties>
- <pluginRepositories>
- <!-- OpenDayLight Repo Mirror -->
- <pluginRepository>
- <id>opendaylight-mirror</id>
- <name>opendaylight-mirror</name>
- <url>${nexusproxy}/groups/public/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </releases>
- </pluginRepository>
- <!-- OpenDayLight Snapshot artifact -->
- <pluginRepository>
- <id>opendaylight-snapshot</id>
- <name>opendaylight-snapshot</name>
- <url> ${nexusproxy}/repositories/opendaylight.snapshot/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </pluginRepository>
- </pluginRepositories>
-
-
- <repositories>
- <!-- OpenDayLight Repo Mirror -->
- <repository>
- <id>opendaylight-mirror</id>
- <name>opendaylight-mirror</name>
- <url>${nexusproxy}/groups/public/</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- <releases>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </releases>
- </repository>
- <!-- OpenDayLight Snapshot artifact -->
- <repository>
- <id>opendaylight-snapshot</id>
- <name>opendaylight-snapshot</name>
- <url> ${nexusproxy}/repositories/opendaylight.snapshot/</url>
- <snapshots>
- <enabled>true</enabled>
- </snapshots>
- <releases>
- <enabled>false</enabled>
- </releases>
- </repository>
- </repositories>
-
- <distributionManagement>
- <!-- OpenDayLight Released artifact -->
- <repository>
- <id>opendaylight-release</id>
- <url>${nexusproxy}/repositories/opendaylight.release/</url>
- </repository>
- <!-- OpenDayLight Snapshot artifact -->
- <snapshotRepository>
- <id>opendaylight-snapshot</id>
- <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
- </snapshotRepository>
- <!-- Site deployment -->
- <site>
- <id>website</id>
- <url>${sitedeploy}</url>
- </site>
- </distributionManagement>
-
-
<dependencyManagement>
<dependencies>
<dependency>
<version>1.4.01</version>
</dependency>
- <!-- YANG Tools Dependencies -->
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-binding</artifactId>
- <version>${yangtools.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-util</artifactId>
- <version>${yangtools.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-common</artifactId>
- <version>${yangtools.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-api</artifactId>
- <version>${yangtools.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-impl</artifactId>
- <version>${yangtools.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-model-api</artifactId>
- <version>${yangtools.version}</version>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yang-data-util</artifactId>
- <version>${yangtools.version}</version>
- </dependency>
<!-- SAL Dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>${guava.version}</version>
- </dependency>
<dependency>
<groupId>org.eclipse.xtend</groupId>
<artifactId>org.eclipse.xtend.lib</artifactId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.core.version}</version>
</dependency>
- <!-- Testing Dependencies -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>${junit.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.mockito</groupId>
- <artifactId>mockito-all</artifactId>
- <version>${mockito.version}</version>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>binding-generator-impl</artifactId>
<artifactId>yang-parser-impl</artifactId>
<version>${yangtools.version}</version>
</dependency>
+
+ <!-- Testing Dependencies -->
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-release-plugin</artifactId>
- <version>${releaseplugin.version}</version>
- </plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
*/
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;
public abstract class AbstractBindingAwareConsumer extends AbstractBrokerAwareActivator implements BindingAwareConsumer {
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;
import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
public abstract class AbstractBindingAwareProvider extends AbstractBrokerAwareActivator implements BindingAwareProvider {
-
+
@Override
protected final void onBrokerAvailable(BindingAwareBroker broker, BundleContext context) {
ProviderContext ctx = broker.registerProvider(this, context);
public Collection<? extends RpcService> getImplementations() {
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
import org.opendaylight.controller.md.sal.common.api.notify.NotificationPublishService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.Notification;
public interface NotificationProviderService extends NotificationService, NotificationPublishService<Notification> {
/**
* Deprecated. Use {@link #publish(Notification)}.
- *
+ *
* @param notification
*/
@Deprecated
/**
* Deprecated. Use {@link #publish(Notification,ExecutorService)}.
- *
+ *
* @param notification
*/
@Deprecated
/**
* Publishes a notification.
- *
+ *
* @param Notification
* notification to publish.
- *
+ *
*/
@Override
void publish(Notification notification);
/**
* Publishes a notification, listener calls are done in provided executor.
- *
+ *
*/
@Override
void publish(Notification notification, ExecutorService service);
*/
package org.opendaylight.controller.sal.binding.api;
-import org.opendaylight.controller.md.sal.common.api.notify.NotificationSubscriptionService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.Notification;
public interface NotificationService extends BindingAwareService {
/**
- *
+ *
* Deprecated: use {@link #addNotificationListener(Class, NotificationListener)} istead.
- *
+ *
* @param listener
*/
@Deprecated
<T extends Notification> void addNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
/**
- *
+ *
* Deprecated: use {@link #addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)} istead.
- *
+ *
* @param listener
*/
@Deprecated
@Deprecated
<T extends Notification> void removeNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
-
+
/**
* Register a generic listener for specified notification type only.
- *
+ *
* @param notificationType
* @param listener
* @return Registration for listener. To unregister listener invoke {@link Registration#close()} method.
* Register a listener which implements generated notification interfaces derived from
* {@link org.opendaylight.yangtools.yang.binding.NotificationListener}.
* Listener is registered for all notifications present in implemented interfaces.
- *
+ *
* @param listener
* @return Registration for listener. To unregister listener invoke {@link Registration#close()} method.
*/
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcService;
/**
* Interface defining provider's access to the Rpc Registry which could be used
* to register their implementations of service to the MD-SAL.
- *
+ *
* @author ttkacik
- *
+ *
*/
public interface RpcProviderRegistry extends //
RpcConsumerRegistry, //
RouteChangePublisher<RpcContextIdentifier, InstanceIdentifier<?>> {
/**
* Registers an global RpcService implementation.
- *
+ *
* @param type
* @param implementation
* @return
throws IllegalStateException;
/**
- *
+ *
* Register an Routed RpcService where routing is determined on annotated
* (in YANG model) context-reference and value of annotated leaf.
- *
+ *
* @param type
* Type of RpcService, use generated interface class, not your
* implementation clas
* Implementation of RpcService
* @return Registration object for routed Rpc which could be used to close
* an
- *
+ *
* @throws IllegalStateException
*/
<T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type, T implementation)
import java.util.concurrent.Future;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
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;
import org.opendaylight.yangtools.yang.common.RpcResult;
/**
* Returns an unique identifier for transaction
- *
+ *
*/
@Override
public Object getIdentifier();
-
+
/**
* 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
*/
@Override
public Future<RpcResult<TransactionStatus>> commit();
-
-
-
+
+
+
/**
* Register a listener for transaction
- *
+ *
* @param listener
* @return
*/
/**
* Listener for transaction state changes
- *
+ *
*
*/
public interface DataTransactionListener extends EventListener {
/**
* Callback is invoked after each transaction status change.
- *
+ *
* @param transaction Transaction
* @param status New status
*/
import org.opendaylight.controller.md.sal.common.api.data.DataProvisionService;
import org.opendaylight.controller.md.sal.common.api.data.DataReader;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.controller.sal.common.DataStoreIdentifier;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
*/
public interface DataProviderService extends DataBrokerService, DataProvisionService<InstanceIdentifier<? extends DataObject>, DataObject> {
-
+
/**
* Registers a data reader for particular subtree of overal YANG data tree.
- *
- * Registered data reader is called if anyone tries to read data from
+ *
+ * Registered data reader is called if anyone tries to read data from
* paths which are nested to provided path.
- *
+ *
* @param path Subpath which is handled by registered data reader
- * @param reader Instance of reader which
+ * @param reader Instance of reader which
* @return Registration object for reader. Invoking {@link Registration#close()} will unregister reader.
*/
Registration<DataReader<InstanceIdentifier<? extends DataObject>,DataObject>> registerDataReader(InstanceIdentifier<? extends DataObject> path,DataReader<InstanceIdentifier<? extends DataObject>,DataObject> reader);
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;
/**
* Trigger for refreshing of the data exposed by the {@link Provider}
- *
- *
- *
+ *
+ *
+ *
*/
public interface DataRefresher extends BindingAwareProvider.ProviderFunctionality {
/**
* Fired when some component explicitly requested the data refresh.
- *
+ *
* The provider which exposed the {@link DataRefresher} should republish its
* provided data by editing the data in all affected data stores.
*/
*/
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;
/**
- * Utility interface which does type capture for BindingAware DataReader.
- *
- * @author
+ * Utility interface which does type capture for BindingAware DataReader.
+ *
+ * @author
*
*/
public interface RuntimeDataProvider extends ProviderFunctionality,DataReader<InstanceIdentifier<? extends DataObject>, DataObject> {
-
-
+
+
}
import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcService;
public interface MountInstance //
extends //
import java.util.EventListener;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
* Provider MountProviderService, this version allows access to MD-SAL services
* specific for this mountpoint and registration / provision of interfaces for
* mount point.
- *
+ *
* @author ttkacik
- *
+ *
*/
public interface MountProviderService extends MountService {
-
+
@Override
public MountProviderInstance getMountPoint(InstanceIdentifier<?> path);
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.RpcImplementation;
import org.opendaylight.yangtools.yang.binding.RpcService;
/**
* RpcRouter is responsible for selecting RpcService based on provided routing
* context identifier {@link RpcRoutingTable#getContextIdentifier()} and path in
* overal data tree (@link {@link InstanceIdentifier}.
- *
- *
+ *
+ *
* @author Tony Tkacik <ttkacik@cisco.com>
- *
+ *
* @param <T>
* Type of RpcService for which router provides routing information
* and route selection.
/**
* Returns a type of RpcService which is served by this instance of router.
- *
+ *
* @return type of RpcService which is served by this instance of router.
*/
Class<T> getServiceType();
-
-
+
+
/**
* Returns a instance of T which is associated with this router instance
* and routes messages based on routing tables.
- *
+ *
* @return type of RpcService which is served by this instance of router.
*/
T getInvocationProxy();
/**
* Returns a routing table for particular route context
- *
+ *
* @param routeContext
* @return Routing Table for particular route context.
*/
/**
* Returns an instance of RpcService which is responsible for processing
* particular path.
- *
+ *
* @param context
* Rpc Routing Context
* @param path
/**
* Returns a default fallback instance of RpcService which is responsible
* for handling all unknown imports.
- *
+ *
* @return default instance responsible for processing RPCs.
*/
T getDefaultService();
Set<Class<? extends BaseIdentity>> getContexts();
-
+
RoutedRpcRegistration<T> addRoutedRpcImplementation(T service);
-
+
RpcRegistration<T> registerDefaultService(T service);
}
import org.opendaylight.controller.sal.binding.impl.forward.DomForwardingUtils;\r
import org.osgi.framework.BundleContext;\r
\r
-import com.google.common.util.concurrent.MoreExecutors;\r
-\r
/**\r
*\r
*/\r
*/
package org.opendaylight.controller.config.yang.md.sal.binding.impl;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-
import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
import org.opendaylight.controller.sal.binding.impl.NotificationBrokerImpl;
import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
/**
*
import java.util.Map.Entry;
import java.util.Set;
-import javassist.ClassPool;
-
import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
this.delegate = Preconditions.checkNotNull(delegate);
}
+ @Override
public CodecRegistry getCodecRegistry() {
return delegate.getCodecRegistry();
}
+ @Override
public CompositeNode toDataDom(DataObject data) {
return delegate.toDataDom(data);
}
+ @Override
public Entry<InstanceIdentifier, CompositeNode> toDataDom(
Entry<org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject>, DataObject> entry) {
return delegate.toDataDom(entry);
}
+ @Override
public InstanceIdentifier toDataDom(
org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> path) {
return delegate.toDataDom(path);
}
+ @Override
public DataObject dataObjectFromDataDom(
org.opendaylight.yangtools.yang.binding.InstanceIdentifier<? extends DataObject> path,
CompositeNode result) throws DeserializationException {
return delegate.dataObjectFromDataDom(path, result);
}
+ @Override
public org.opendaylight.yangtools.yang.binding.InstanceIdentifier<?> fromDataDom(InstanceIdentifier entry)
throws DeserializationException {
return delegate.fromDataDom(entry);
}
+ @Override
public Set<QName> getRpcQNamesFor(Class<? extends RpcService> service) {
return delegate.getRpcQNamesFor(service);
}
+ @Override
public DataContainer dataObjectFromDataDom(Class<? extends DataContainer> inputClass, CompositeNode domInput) {
return delegate.dataObjectFromDataDom(inputClass, domInput);
}
*/
package org.opendaylight.controller.sal.binding.codegen.impl;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
-import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*;
+import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.setRoutingTable;
+import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-import java.util.HashMap;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.opendaylight.yangtools.yang.binding.RpcImplementation;
-import org.opendaylight.controller.md.sal.common.api.routing.MutableRoutingTable;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
+import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Map<Class<? extends BaseIdentity>, RpcRoutingTableImpl<? extends BaseIdentity, T>> mutableRoutingTables = new HashMap<>();
for (Class<? extends BaseIdentity> ctx : contexts) {
RpcRoutingTableImpl<? extends BaseIdentity, T> table = new RpcRoutingTableImpl<>(name,ctx,type);
-
+
@SuppressWarnings("rawtypes")
Map invokerView = table.getRoutes();
-
- setRoutingTable((RpcService) invocationProxy, ctx, invokerView);
+
+ setRoutingTable(invocationProxy, ctx, invokerView);
mutableRoutingTables.put(ctx, table);
table.registerRouteChangeListener(this);
}
*/
package org.opendaylight.controller.sal.binding.codegen.impl;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
-import org.opendaylight.yangtools.yang.binding.BaseIdentity;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
+import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Mutable;
+import org.opendaylight.yangtools.yang.binding.BaseIdentity;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.RpcService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private RouteChangeListener<Class<? extends BaseIdentity>, InstanceIdentifier<?>> listener;
private S defaultRoute;
-
+
public RpcRoutingTableImpl(String routerName,Class<C> contextType, Class<S> serviceType) {
super();
this.routerName = routerName;
@Override
public <L extends RouteChangeListener<Class<? extends BaseIdentity>, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
L listener) {
- return (ListenerRegistration<L>) new SingletonListenerRegistration<L>(listener);
+ return new SingletonListenerRegistration<L>(listener);
}
-
+
@Override
public Class<C> getIdentifier() {
return contextType;
@SuppressWarnings("unchecked")
public void updateRoute(InstanceIdentifier<?> path, S service) {
S previous = this.routes.put(path, service);
-
+
LOGGER.debug("Route {} updated to {} in routing table {}",path,service,this);
@SuppressWarnings("rawtypes")
RouteChangeListener listenerCapture = listener;
}
}
-
+
@Override
@SuppressWarnings("unchecked")
public void removeRoute(InstanceIdentifier<?> path) {
listenerCapture.onRouteChange(RoutingUtils.removalChange(contextType, path));
}
}
-
+
public void removeRoute(InstanceIdentifier<?> path, S service) {
@SuppressWarnings("rawtypes")
RouteChangeListener listenerCapture = listener;
public Map<InstanceIdentifier<?>, S> getRoutes() {
return unmodifiableRoutes;
}
-
+
protected void removeAllReferences(S service) {
-
+
}
-
-
+
+
@Override
public String toString() {
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
+import javassist.ClassPool;
+
import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator;
import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import javassist.ClassPool;
-
public class SingletonHolder {
public static final ClassPool CLASS_POOL = new ClassPool();
package org.opendaylight.controller.sal.binding.impl;\r
\r
import java.util.Set;
-import java.util.concurrent.Future;\r
-import java.util.concurrent.atomic.AtomicLong;\r
-\r
-import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;\r
-import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;\r
-import org.opendaylight.controller.sal.binding.api.data.DataProviderService;\r
-import org.opendaylight.controller.sal.binding.impl.util.BindingAwareDataReaderRouter;\r
-import org.opendaylight.controller.sal.common.DataStoreIdentifier;\r
-import org.opendaylight.yangtools.yang.binding.DataObject;\r
-import org.opendaylight.yangtools.yang.binding.DataRoot;\r
-import org.opendaylight.yangtools.yang.binding.Identifiable;\r
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;\r
-import org.opendaylight.yangtools.yang.common.RpcResult;\r
+import java.util.concurrent.Future;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;
+import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
+import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
+import org.opendaylight.controller.sal.binding.impl.util.BindingAwareDataReaderRouter;
+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;
+import org.opendaylight.yangtools.yang.common.RpcResult;
\r
\r
public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier<? extends DataObject>, DataObject, DataChangeListener> //\r
\r
private final AtomicLong nextTransaction = new AtomicLong();\r
private final AtomicLong createdTransactionsCount = new AtomicLong();\r
- \r
+\r
public AtomicLong getCreatedTransactionsCount() {\r
return createdTransactionsCount;\r
}\r
DataChangeListener changeListener) {\r
throw new UnsupportedOperationException("Deprecated");\r
}\r
- \r
+\r
@Override\r
public void close() throws Exception {\r
- \r
+\r
}
-
-
+
@Override
protected boolean isAffectedBy(InstanceIdentifier<? extends DataObject> key,
Set<InstanceIdentifier<? extends DataObject>> paths) {
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataTransaction;
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction.DataTransactionListener;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class DataTransactionImpl extends AbstractDataTransaction<InstanceIdentifier<? extends DataObject>, DataObject>
+public class DataTransactionImpl extends AbstractDataTransaction<InstanceIdentifier<? extends DataObject>, DataObject>
implements DataModificationTransaction {
private final ListenerRegistry<DataTransactionListener> listeners = new ListenerRegistry<DataTransactionListener>();
-
-
-
+
+
+
public DataTransactionImpl(Object identifier,DataBrokerImpl dataBroker) {
super(identifier,dataBroker);
}
return listeners.register(listener);
}
+ @Override
protected void onStatusChange(TransactionStatus status) {
for (ListenerRegistration<DataTransactionListener> listenerRegistration : listeners) {
listenerRegistration.getInstance().onStatusUpdated(this, status);
*/
package org.opendaylight.controller.sal.binding.impl;
+import static com.google.common.base.Preconditions.checkState;
+
import java.util.EventListener;
+import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.HashMap;
import java.util.Set;
import java.util.WeakHashMap;
-import javax.swing.tree.ExpandVetoException;
-
import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
import org.opendaylight.controller.md.sal.common.impl.routing.RoutingUtils;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeGenerator;
import org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper;
import org.opendaylight.controller.sal.binding.codegen.impl.SingletonHolder;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.util.ListenerRegistry;
import org.opendaylight.yangtools.yang.binding.BaseIdentity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static com.google.common.base.Preconditions.*;
-
public class RpcProviderRegistryImpl implements //
RpcProviderRegistry, //
RouteChangePublisher<RpcContextIdentifier, InstanceIdentifier<?>> {
private final String name;
- private ListenerRegistry<GlobalRpcRegistrationListener> globalRpcListeners = ListenerRegistry.create();
+ private final ListenerRegistry<GlobalRpcRegistrationListener> globalRpcListeners = ListenerRegistry.create();
public String getName() {
return name;
@Override
public final <T extends RpcService> T getRpcService(Class<T> type) {
- @SuppressWarnings("unchecked")
T potentialProxy = (T) publicProxies.get(type);
if (potentialProxy != null) {
return potentialProxy;
potentialProxy = (T) publicProxies.get(type);
if (potentialProxy != null) {
- return (T) potentialProxy;
+ return potentialProxy;
}
T proxy = rpcFactory.getDirectProxyFor(type);
LOG.debug("Created {} as public proxy for {} in {}", proxy, type.getSimpleName(), this);
LOG.error("Unhandled exception during invoking listener {}", e);
}
}
-
+
}
- private void notifyListenersRoutedCreated(RpcRouter router) {
+ private void notifyListenersRoutedCreated(RpcRouter<?> router) {
for (ListenerRegistration<RouterInstantiationListener> listener : routerInstantiationListener) {
try {
public interface RouterInstantiationListener extends EventListener {
void onRpcRouterCreated(RpcRouter<?> router);
}
-
+
public ListenerRegistration<GlobalRpcRegistrationListener> registerGlobalRpcRegistrationListener(GlobalRpcRegistrationListener listener) {
return globalRpcListeners.register(listener);
}
public interface GlobalRpcRegistrationListener extends EventListener {
void onGlobalRpcRegistered(Class<? extends RpcService> cls);
void onGlobalRpcUnregistered(Class<? extends RpcService> cls);
-
+
}
private class RouteChangeForwarder<T extends RpcService> implements
import org.opendaylight.controller.md.sal.common.api.data.DataModification;
import org.opendaylight.yangtools.concepts.Path;
-import com.google.common.util.concurrent.JdkFutureAdapters;
-
public final class DataModificationTracker<P extends Path<P>,D> {
-
ConcurrentMap<Object, DataModification<P,D>> trackedTransactions = new ConcurrentHashMap<>();
-
-
+
public void startTrackingModification(DataModification<P,D> modification) {
trackedTransactions.putIfAbsent(modification.getIdentifier(), modification);
-
-
}
-
+
public boolean containsIdentifier(Object identifier) {
return trackedTransactions.containsKey(identifier);
}
import org.junit.After;
import org.junit.Before;
import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
import org.opendaylight.controller.sal.core.api.data.DataStore;
import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
-import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
+import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
package org.opendaylight.controller.sal.binding.test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import javassist.ClassPool;
import org.junit.Before;
import org.junit.Test;
-
-import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*;
-
-import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter;
import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable;
import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator;
import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker;
import org.opendaylight.controller.sal.binding.test.mock.BarListener;
import org.opendaylight.controller.sal.binding.test.mock.BarUpdate;
-import org.opendaylight.controller.sal.binding.test.mock.CompositeListener;
import org.opendaylight.controller.sal.binding.test.mock.FlowDelete;
import org.opendaylight.controller.sal.binding.test.mock.FooListener;
import org.opendaylight.controller.sal.binding.test.mock.FooService;
import org.opendaylight.controller.sal.binding.test.mock.FooUpdate;
-import org.opendaylight.controller.sal.binding.test.mock.InheritedContextInput;
import org.opendaylight.controller.sal.binding.test.mock.ReferencableObject;
import org.opendaylight.controller.sal.binding.test.mock.ReferencableObjectKey;
import org.opendaylight.controller.sal.binding.test.mock.SimpleInput;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
-import static org.mockito.Mockito.*;
-
public class RuntimeCodeGeneratorTest {
private RuntimeCodeGenerator codeGenerator;
NotificationInvoker invokerFoo = invokerFactory.invokerFor(fooListener);
-
+
assertSame(fooListener,invokerFoo.getDelegate());
assertNotNull(invokerFoo.getSupportedNotifications());
assertEquals(1, invokerFoo.getSupportedNotifications().size());
import org.opendaylight.yangtools.yang.binding.Identifier;
public class ReferencableObjectKey implements Identifier<ReferencableObject> {
-
+ private static final long serialVersionUID = 1L;
final Integer value;
-
+
public ReferencableObjectKey(Integer _value) {
this.value = _value;
}
public String toString() {
return "ReferencableObjectKey [value=" + value + "]";
}
-
-
+
+
}
import javassist.ClassPool;
-import org.opendaylight.controller.sal.core.api.data.DataStore;
-import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
-import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
-import org.opendaylight.controller.sal.dom.broker.impl.SchemaAwareDataStoreAdapter;
-
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
private ExecutorService executor;
private ClassPool classPool;
-
+
public boolean isStartWithParsedSchema() {
return startWithParsedSchema;
}
if(classPool == null) {
return CLASS_POOL;
}
-
+
return classPool;
}
*/
package org.opendaylight.controller.sal.binding.test.bugfix;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-
-
-
-
-
-
-
import org.junit.Test;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
import org.opendaylight.yangtools.yang.binding.DataObject;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-import static org.junit.Assert.*;
-
public class DOMCodecBug01Test extends AbstractDataServiceTest {
private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
flow.setNode(NODE_REF);
InstructionsBuilder instructions = new InstructionsBuilder();
InstructionBuilder instruction = new InstructionBuilder();
-
+
instruction.setOrder(10);
ApplyActionsBuilder applyActions = new ApplyActionsBuilder();
List<Action> actionList = new ArrayList<>();
assertNotNull(ret);
assertEquals(TransactionStatus.COMMITED, ret.getResult());
}
-
+
private void createFlow2() throws Exception {
DataModificationTransaction modification = baDataService.beginTransaction();
long id = 123;
MatchBuilder match = new MatchBuilder();
match.setLayer4Match(new TcpMatchBuilder().build());
flow.setMatch(match.build());
-
+
path1 = InstanceIdentifier.builder(Flows.class).child(Flow.class, key).toInstance();
// DataObject cls = (DataObject) modification.readConfigurationData(path1);
modification.putConfigurationData(path1, flow.build());
*/
package org.opendaylight.controller.sal.binding.test.bugfix;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.util.Collections;
import java.util.Map;
import java.util.concurrent.Callable;
import javassist.ClassPool;
-import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
-import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.config.rev130819.flows.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
-import static org.junit.Assert.*;
-
public class DOMCodecBug02Test extends AbstractDataServiceTest {
private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
/**
* This test is ignored, till found out better way to test generation
* of classes without leaking of instances from previous run
- *
+ *
* @throws Exception
*/
-
+
+ @Override
public void setUp() {
ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
factory.setStartWithParsedSchema(getStartWithSchema());
testContext = factory.getTestContext();
testContext.start();
-
+
baDataService = testContext.getBindingDataBroker();
biDataService = testContext.getDomDataBroker();
dataStore = testContext.getDomDataStore();
mappingService = testContext.getBindingToDomMappingService();
};
-
+
@Test
public void testSchemaContextNotAvailable() throws Exception {
return transaction.commit();
}
});
-
-
+
+
RpcResult<TransactionStatus> result = future.get().get();
assertEquals(TransactionStatus.COMMITED, result.getResult());
-
+
Nodes nodes = checkForNodes();
assertNotNull(nodes);
return (Nodes) baDataService.readOperationalData(NODES_INSTANCE_ID_BA);
}
-
+
@Override
protected boolean getStartWithSchema() {
return false;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.controller.sal.binding.test.bugfix;
-import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SupportedActions;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SupportedActionsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.supported.actions.ActionType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.supported.actions.ActionTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.SupportType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.SupportType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import static org.junit.Assert.*;
-
public class DOMCodecBug03Test extends AbstractDataServiceTest implements DataChangeListener {
private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier//
.builder(NODES_INSTANCE_ID_BA) //
.child(Node.class, NODE_KEY).toInstance();
-
-
+
+
private static final InstanceIdentifier<SupportedActions> SUPPORTED_ACTIONS_INSTANCE_ID_BA = InstanceIdentifier//
.builder(NODES_INSTANCE_ID_BA) //
.child(Node.class, NODE_KEY) //
.augmentation(FlowCapableNode.class) //
.child(SupportedActions.class)
.toInstance();
-
+
private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
.toInstance();
private static final QName SUPPORTED_ACTIONS_QNAME = QName.create(FlowCapableNode.QNAME, SupportedActions.QNAME.getLocalName());
-
+
private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BI = //
org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
.node(Nodes.QNAME) //
.nodeWithKey(Node.QNAME, NODE_KEY_BI) //
.node(SUPPORTED_ACTIONS_QNAME) //
.toInstance();
-
+
private DataChangeEvent<InstanceIdentifier<?>, DataObject> receivedChangeEvent;
-
-
+
+
/**
* Test for Bug 148
- *
+ *
* @throws Exception
*/
@Test
public void testAugmentSerialization() throws Exception {
-
+
baDataService.registerDataChangeListener(NODES_INSTANCE_ID_BA, this);
-
+
NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setId(new NodeId(NODE_ID));
nodeBuilder.setKey(NODE_KEY);
DataModificationTransaction transaction = baDataService.beginTransaction();
-
-
+
+
FlowCapableNodeBuilder fnub = new FlowCapableNodeBuilder();
fnub.setHardware("Hardware Foo");
fnub.setManufacturer("Manufacturer Foo");
nodeBuilder.addAugmentation(FlowCapableNode.class, fnu);
Node original = nodeBuilder.build();
transaction.putOperationalData(NODE_INSTANCE_ID_BA, original);
-
+
RpcResult<TransactionStatus> result = transaction.commit().get();
assertEquals(TransactionStatus.COMMITED, result.getResult());
-
+
assertNotNull(receivedChangeEvent);
-
+
verifyNodes((Nodes) receivedChangeEvent.getUpdatedOperationalSubtree(),original);
assertBindingIndependentVersion(NODE_INSTANCE_ID_BI);
Nodes nodes = checkForNodes();
verifyNodes(nodes,original);
-
+
testAddingNodeConnector();
testNodeRemove();
}
-
+
@Test
public void testAugmentNestedSerialization() throws Exception {
DataModificationTransaction transaction = baDataService.beginTransaction();
-
+
SupportedActionsBuilder actions = new SupportedActionsBuilder();
ActionTypeBuilder action = new ActionTypeBuilder();
action.setAction("foo-action");
action.setSupportState(SupportType.Native);
List<ActionType> actionTypes = Collections.singletonList(action.build());
actions.setActionType(actionTypes );
-
+
transaction.putOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BA, actions.build());
RpcResult<TransactionStatus> putResult = transaction.commit().get();
assertNotNull(putResult);
assertEquals(TransactionStatus.COMMITED, putResult.getResult());
SupportedActions readedTable = (SupportedActions) baDataService.readOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BA);
assertNotNull(readedTable);
-
+
CompositeNode biSupportedActions = biDataService.readOperationalData(SUPPORTED_ACTIONS_INSTANCE_ID_BI);
assertNotNull(biSupportedActions);
-
+
}
private void testAddingNodeConnector() throws Exception {
-
+
NodeConnectorId ncId = new NodeConnectorId("openflow:1:bar");
NodeConnectorKey nodeKey = new NodeConnectorKey(ncId );
InstanceIdentifier<NodeConnector> ncInstanceId = InstanceIdentifier.builder(NODE_INSTANCE_ID_BA).child(NodeConnector.class, nodeKey).toInstance();
transaction.removeOperationalData(NODE_INSTANCE_ID_BA);
RpcResult<TransactionStatus> result = transaction.commit().get();
assertEquals(TransactionStatus.COMMITED, result.getResult());
-
+
Node node = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA);
assertNull(node);
}
Node readedNode = nodes.getNode().get(0);
assertEquals(original.getId(), readedNode.getId());
assertEquals(original.getKey(), readedNode.getKey());
-
+
FlowCapableNode fnu = original.getAugmentation(FlowCapableNode.class);
FlowCapableNode readedAugment = readedNode.getAugmentation(FlowCapableNode.class);
assertNotNull(fnu);
assertEquals(fnu.getDescription(), readedAugment.getDescription());
assertEquals(fnu.getSerialNumber(), readedAugment.getSerialNumber());
-
+
}
private void assertBindingIndependentVersion(
private Nodes checkForNodes() {
return (Nodes) baDataService.readOperationalData(NODES_INSTANCE_ID_BA);
}
-
+
@Override
public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
receivedChangeEvent = change;
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.controller.sal.binding.test.bugfix;
-import java.util.Arrays;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
import java.util.Collections;
-import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.DataChangeEvent;
-import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
+import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SupportedActions;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.SupportedActionsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.supported.actions.ActionType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.flow.node.supported.actions.ActionTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.SupportType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeaturesKey;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-import static org.junit.Assert.*;
-
public class PutAugmentationTest extends AbstractDataServiceTest implements DataChangeListener {
private static final QName NODE_ID_QNAME = QName.create(Node.QNAME, "id");
private static final InstanceIdentifier<Node> NODE_INSTANCE_ID_BA = InstanceIdentifier//
.builder(NODES_INSTANCE_ID_BA) //
.child(Node.class, NODE_KEY).toInstance();
-
-
+
+
private static final InstanceIdentifier<SupportedActions> SUPPORTED_ACTIONS_INSTANCE_ID_BA = InstanceIdentifier//
.builder(NODES_INSTANCE_ID_BA) //
.child(Node.class, NODE_KEY) //
.augmentation(FlowCapableNode.class) //
.child(SupportedActions.class)
.toInstance();
-
+
private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier NODE_INSTANCE_ID_BI = //
org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
.toInstance();
private static final QName SUPPORTED_ACTIONS_QNAME = QName.create(FlowCapableNode.QNAME, SupportedActions.QNAME.getLocalName());
-
+
private static final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier SUPPORTED_ACTIONS_INSTANCE_ID_BI = //
org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.builder() //
.node(Nodes.QNAME) //
.nodeWithKey(Node.QNAME, NODE_KEY_BI) //
.node(SUPPORTED_ACTIONS_QNAME) //
.toInstance();
-
+
private DataChangeEvent<InstanceIdentifier<?>, DataObject> receivedChangeEvent;
-
-
+
+
/**
* Test for Bug 148
- *
+ *
* @throws Exception
*/
@Test
public void putNodeAndAugmentation() throws Exception {
baDataService.registerDataChangeListener(NODES_INSTANCE_ID_BA, this);
-
+
NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setId(new NodeId(NODE_ID));
nodeBuilder.setKey(NODE_KEY);
Node node = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA);
assertNotNull(node);
assertEquals(NODE_KEY, node.getKey());
-
+
FlowCapableNodeBuilder fnub = new FlowCapableNodeBuilder();
fnub.setHardware("Hardware Foo");
fnub.setManufacturer("Manufacturer Foo");
InstanceIdentifier<FlowCapableNode> augmentIdentifier = InstanceIdentifier.builder(NODE_INSTANCE_ID_BA).augmentation(FlowCapableNode.class).toInstance();
DataModificationTransaction augmentedTransaction = baDataService.beginTransaction();
augmentedTransaction.putOperationalData(augmentIdentifier, fnu);
-
+
result = augmentedTransaction.commit().get();
assertEquals(TransactionStatus.COMMITED, result.getResult());
-
-
+
+
Node augmentedNode = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA);
assertNotNull(node);
assertEquals(NODE_KEY, augmentedNode.getKey());
assertBindingIndependentVersion(NODE_INSTANCE_ID_BI);
testNodeRemove();
}
-
+
@Test
public void putNodeWithAugmentation() throws Exception {
-
+
NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setId(new NodeId(NODE_ID));
nodeBuilder.setKey(NODE_KEY);
fnub.setDescription("Description Foo");
fnub.setSoftware("JUnit emulated");
FlowCapableNode fnu = fnub.build();
-
+
nodeBuilder.addAugmentation(FlowCapableNode.class, fnu);
DataModificationTransaction baseTransaction = baDataService.beginTransaction();
baseTransaction.putOperationalData(NODE_INSTANCE_ID_BA, nodeBuilder.build());
RpcResult<TransactionStatus> result = baseTransaction.commit().get();
assertEquals(TransactionStatus.COMMITED, result.getResult());
-
+
FlowCapableNode readedAugmentation = (FlowCapableNode) baDataService.readOperationalData(InstanceIdentifier.builder(NODE_INSTANCE_ID_BA).augmentation(FlowCapableNode.class).toInstance());
assertNotNull(readedAugmentation);
assertEquals(fnu.getHardware(), readedAugmentation.getHardware());
-
+
testPutNodeConnectorWithAugmentation();
testNodeRemove();
}
-
+
private void testPutNodeConnectorWithAugmentation() throws Exception {
NodeConnectorKey ncKey = new NodeConnectorKey(new NodeConnectorId("test:0:0"));
InstanceIdentifier<NodeConnector> ncPath = InstanceIdentifier.builder(NODE_INSTANCE_ID_BA)
.child(NodeConnector.class, ncKey).toInstance();
InstanceIdentifier<FlowCapableNodeConnector> ncAugmentPath = InstanceIdentifier.builder(ncPath)
.augmentation(FlowCapableNodeConnector.class).toInstance();
-
+
NodeConnectorBuilder nc = new NodeConnectorBuilder();
nc.setKey(ncKey);
-
+
FlowCapableNodeConnectorBuilder fncb = new FlowCapableNodeConnectorBuilder();
fncb.setName("Baz");
nc.addAugmentation(FlowCapableNodeConnector.class, fncb.build());
-
+
DataModificationTransaction baseTransaction = baDataService.beginTransaction();
baseTransaction.putOperationalData(ncPath, nc.build());
RpcResult<TransactionStatus> result = baseTransaction.commit().get();
assertEquals(TransactionStatus.COMMITED, result.getResult());
-
+
FlowCapableNodeConnector readedAugmentation = (FlowCapableNodeConnector) baDataService.readOperationalData(ncAugmentPath);
assertNotNull(readedAugmentation);
assertEquals(fncb.getName(), readedAugmentation.getName());
transaction.removeOperationalData(NODE_INSTANCE_ID_BA);
RpcResult<TransactionStatus> result = transaction.commit().get();
assertEquals(TransactionStatus.COMMITED, result.getResult());
-
+
Node node = (Node) baDataService.readOperationalData(NODE_INSTANCE_ID_BA);
assertNull(node);
}
Node readedNode = nodes.getNode().get(0);
assertEquals(original.getId(), readedNode.getId());
assertEquals(original.getKey(), readedNode.getKey());
-
+
FlowCapableNode fnu = original.getAugmentation(FlowCapableNode.class);
FlowCapableNode readedAugment = readedNode.getAugmentation(FlowCapableNode.class);
assertNotNull(fnu);
assertEquals(fnu.getDescription(), readedAugment.getDescription());
assertEquals(fnu.getSerialNumber(), readedAugment.getSerialNumber());
-
+
}
private void assertBindingIndependentVersion(
private Nodes checkForNodes() {
return (Nodes) baDataService.readOperationalData(NODES_INSTANCE_ID_BA);
}
-
+
@Override
public void onDataChanged(DataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
receivedChangeEvent = change;
import java.util.Collections;
import java.util.Map;
-import javax.management.Notification;
-
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
import org.opendaylight.controller.md.sal.common.api.data.DataReader;
import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
import org.opendaylight.controller.sal.binding.api.mount.MountProviderService;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.NodeGroupStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.group.statistics.GroupStatistics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import org.opendaylight.yangtools.yang.data.impl.ImmutableCompositeNode;
-import org.opendaylight.yangtools.yang.data.impl.util.CompositeNodeBuilder;
-import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.MoreExecutors;
public class CrossBrokerMountPointTest {
assertNotNull(bindingMountPoint);
final BigInteger packetCount = BigInteger.valueOf(500L);
-
-
+
+
DataReader<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> simpleReader = new DataReader<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode>() {
@Override
return null;
}
-
+
@Override
public CompositeNode readOperationalData(org.opendaylight.yangtools.yang.data.api.InstanceIdentifier arg0) {
if (arg0.equals(GROUP_STATISTICS_ID_BI)) {
};
domMountPoint.registerOperationalReader(NODE_INSTANCE_ID_BI, simpleReader);
-
+
GroupStatistics data = (GroupStatistics) bindingMountPoint.readOperationalData(GROUP_STATISTICS_ID_BA);
assertNotNull(data);
assertEquals(packetCount,data.getPacketCount().getValue());
import static org.ops4j.pax.exam.CoreOptions.frameworkProperty;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
-import static org.ops4j.pax.exam.CoreOptions.repository;
-import static org.ops4j.pax.exam.CoreOptions.repositories;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import org.ops4j.pax.exam.Option;
public static Option bindingAwareSalBundles() {
return new DefaultCompositeOption( //
mdSalCoreBundles(),
-
+
mavenBundle("org.javassist", "javassist").versionAsInProject(), // //
-
+
mavenBundle(YANGTOOLS, "yang-data-api").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-data-impl").versionAsInProject(), // //
mavenBundle(YANGTOOLS, "yang-model-api").versionAsInProject(), // //
"binding-generator-spi").versionAsInProject(), //
mavenBundle(YANGTOOLS, "binding-generator-impl").versionAsInProject(),
mavenBundle(YANGTOOLS + ".thirdparty", "antlr4-runtime-osgi-nohead").versionAsInProject(), // //
-
+
mavenBundle(CONTROLLER, "sal-core-api").versionAsInProject().update(), //
mavenBundle(CONTROLLER, "sal-binding-api").versionAsInProject(), // //
mavenBundle(CONTROLLER, "sal-binding-config").versionAsInProject(), //
mavenBundle(CONTROLLER, "sal-common-util").versionAsInProject(), // //
-
+
mavenBundle(CONTROLLER, "sal-broker-impl").versionAsInProject(), // //
mavenBundle(CONTROLLER, "sal-core-spi").versionAsInProject().update(), //
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.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.yangtools.yang.binding.RpcService;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
public class NoficationTest extends AbstractTest {
- private FlowListener listener1 = new FlowListener();
- private FlowListener listener2 = new FlowListener();
+ private final FlowListener listener1 = new FlowListener();
+ private final FlowListener listener2 = new FlowListener();
private Registration<NotificationListener> listener1Reg;
private Registration<NotificationListener> listener2Reg;
@Test
public void notificationTest() throws Exception {
/**
- *
+ *
* The registration of the Provider 1.
- *
+ *
*/
AbstractTestProvider provider1 = new AbstractTestProvider() {
@Override
assertNotNull(notifyProviderService);
/**
- *
+ *
* The registration of the Consumer 1. It retrieves Notification Service
* from MD-SAL and registers SalFlowListener as notification listener
- *
+ *
*/
BindingAwareConsumer consumer1 = new BindingAwareConsumer() {
@Override
/**
* Check that one notification was delivered and has correct cookie.
- *
+ *
*/
assertEquals(1, listener1.addedFlows.size());
assertEquals(0, listener1.addedFlows.get(0).getCookie().intValue());
* registered as notification listener.
*/
BindingAwareProvider provider = new BindingAwareProvider() {
-
+
@Override
public void onSessionInitiated(ProviderContext session) {
listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener(
listener2);
}
-
+
@Override
public void onSessionInitialized(ConsumerContext session) {
// TODO Auto-generated method stub
-
+
}
-
+
@Override
public Collection<? extends RpcService> getImplementations() {
// TODO Auto-generated method stub
return null;
}
-
+
@Override
public Collection<? extends ProviderFunctionality> getFunctionality() {
// TODO Auto-generated method stub
return null;
}
-
+
};
// registerConsumer method calls onSessionInitialized method above
/**
* Check that 3 notification was delivered to both listeners (first one
* received 4 in total, second 3 in total).
- *
+ *
*/
assertEquals(4, listener1.addedFlows.size());
assertEquals(3, listener2.addedFlows.size());
/**
* The second listener is closed (unregistered)
- *
+ *
*/
listener2Reg.close();
/**
- *
+ *
* The notification 5 is published
*/
notifyProviderService.publish(flowAdded(10));
* Check that first consumer received 5 notifications in total, second
* consumer received only three. Last notification was never received by
* second consumer because its listener was unregistered.
- *
+ *
*/
assertEquals(5, listener1.addedFlows.size());
assertEquals(3, listener2.addedFlows.size());
/**
* Creates instance of the type FlowAdded. Only cookie value is set. It is
* used only for testing purpose.
- *
+ *
* @param i
* cookie value
* @return instance of the type FlowAdded
}
/**
- *
+ *
* Implements
* {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener
* SalFlowListener} and contains attributes which keep lists of objects of
@Override
public void onFlowRemoved(FlowRemoved notification) {
removedFlows.add(notification);
- };
+ };
@Override
public void onFlowUpdated(FlowUpdated notification) {
@Override
public void onSwitchFlowRemoved(SwitchFlowRemoved notification) {
// TODO Auto-generated method stub
-
+
}
@Override
public void onNodeErrorNotification(NodeErrorNotification notification) {
// TODO Auto-generated method stub
-
+
}
@Override
public void onNodeExperimenterErrorNotification(
NodeExperimenterErrorNotification notification) {
// TODO Auto-generated method stub
-
+
}
}
import static org.mockito.Mockito.verify;
import java.math.BigInteger;
-import java.util.concurrent.Future;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowService;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
public class RoutedServiceTest extends AbstractTest {
/**
* Register provider 1 with first implementation of SalFlowService -
* service1
- *
+ *
*/
broker.registerProvider(provider1, getBundleContext());
assertNotNull("Registration should not be null", firstReg);
/**
* Register provider 2 with first implementation of SalFlowService -
* service2
- *
+ *
*/
broker.registerProvider(provider2, getBundleContext());
assertNotNull("Registration should not be null", firstReg);
/**
* Consumer creates addFlow message for node one and sends it to the
* MD-SAL
- *
+ *
*/
AddFlowInput addFlowFirstMessage = createSampleAddFlow(nodeOne, 1);
consumerService.addFlow(addFlowFirstMessage);
/**
* Verifies that implementation of the first provider received the same
* message from MD-SAL.
- *
+ *
*/
verify(salFlowService1).addFlow(addFlowFirstMessage);
/**
* Verifies that second instance was not invoked with first message
- *
+ *
*/
verify(salFlowService2, times(0)).addFlow(addFlowFirstMessage);
/**
* Provider 2 registers path of node 2
- *
+ *
*/
NodeRef nodeTwo = createNodeRef("foo:node:2");
secondReg.registerPath(NodeContext.class, nodeTwo.getValue());
/**
* Verifies that second instance was invoked 3 times with second message
* and first instance wasn't invoked.
- *
+ *
*/
verify(salFlowService2, times(3)).addFlow(AddFlowSecondMessage);
verify(salFlowService1, times(0)).addFlow(AddFlowSecondMessage);
/**
* Unregisteration of the path for the node one in the first provider
- *
+ *
*/
firstReg.unregisterPath(NodeContext.class, nodeOne.getValue());
/**
* Provider 2 registers path of node 1
- *
+ *
*/
secondReg.registerPath(NodeContext.class, nodeOne.getValue());
/**
* A consumer sends third message to node 1
- *
+ *
*/
AddFlowInput AddFlowThirdMessage = createSampleAddFlow(nodeOne, 3);
consumerService.addFlow(AddFlowThirdMessage);
/**
* Returns node reference from string which represents path
- *
+ *
* @param string
* string with key(path)
* @return instance of the type NodeRef
/**
* Creates flow AddFlowInput for which only node and cookie are set
- *
+ *
* @param node
* NodeRef value
* @param cookie
package org.opendaylight.controller.md.sal.binding.util;
import java.util.concurrent.Future;
-import java.util.zip.Checksum;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
import org.opendaylight.controller.sal.binding.api.data.DataChangeListener;
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
-import org.opendaylight.controller.sal.binding.api.mount.MountInstance;
import org.opendaylight.controller.sal.common.DataStoreIdentifier;
-import org.opendaylight.yangtools.concepts.Identifiable;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
protected final D getDataBroker() {
return dataBroker;
}
-
+
protected final R getRpcRegistryChecked() {
Preconditions.checkState(rpcRegistry != null,"Rpc Registry is not available.");
return rpcRegistry;
Preconditions.checkState(dataBroker != null, "Data Broker is not available");
return dataBroker;
}
-
+
protected AbstractBindingSalConsumerInstance(R rpcRegistry, N notificationBroker, D dataBroker) {
this.rpcRegistry = rpcRegistry;
this.dataBroker = dataBroker;
}
+ @Override
public <T extends RpcService> T getRpcService(Class<T> module) {
return getRpcRegistryChecked().getRpcService(module);
}
+ @Override
@Deprecated
public <T extends Notification> void addNotificationListener(Class<T> notificationType,
NotificationListener<T> listener) {
getNotificationBrokerChecked().addNotificationListener(notificationType, listener);
}
+ @Override
@Deprecated
public void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
getNotificationBrokerChecked().addNotificationListener(listener);
}
+ @Override
@Deprecated
public void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
getNotificationBrokerChecked().removeNotificationListener(listener);
}
+ @Override
@Deprecated
public <T extends Notification> void removeNotificationListener(Class<T> notificationType,
NotificationListener<T> listener) {
getNotificationBrokerChecked().removeNotificationListener(notificationType, listener);
}
+ @Override
public <T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(
Class<T> notificationType, NotificationListener<T> listener) {
return getNotificationBrokerChecked().registerNotificationListener(notificationType, listener);
}
+ @Override
public Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(
org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
return getNotificationBrokerChecked().registerNotificationListener(listener);
}
+ @Override
@Deprecated
public <T extends DataRoot> T getData(DataStoreIdentifier store, Class<T> rootType) {
return getDataBrokerChecked().getData(store, rootType);
}
+ @Override
@Deprecated
public <T extends DataRoot> T getData(DataStoreIdentifier store, T filter) {
return getDataBrokerChecked().getData(store, filter);
}
+ @Override
@Deprecated
public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, Class<T> rootType) {
return getDataBrokerChecked().getCandidateData(store, rootType);
}
+ @Override
@Deprecated
public <T extends DataRoot> T getCandidateData(DataStoreIdentifier store, T filter) {
return getDataBrokerChecked().getCandidateData(store, filter);
}
+ @Override
@Deprecated
public RpcResult<DataRoot> editCandidateData(DataStoreIdentifier store, DataRoot changeSet) {
return getDataBrokerChecked().editCandidateData(store, changeSet);
}
+ @Override
@Deprecated
public Future<RpcResult<Void>> commit(DataStoreIdentifier store) {
return getDataBrokerChecked().commit(store);
}
+ @Override
@Deprecated
public DataObject getData(InstanceIdentifier<? extends DataObject> data) {
return getDataBrokerChecked().getData(data);
}
+ @Override
@Deprecated
public DataObject getConfigurationData(InstanceIdentifier<?> data) {
return getDataBrokerChecked().getConfigurationData(data);
}
+ @Override
public DataModificationTransaction beginTransaction() {
return getDataBrokerChecked().beginTransaction();
}
+ @Override
@Deprecated
public void registerChangeListener(InstanceIdentifier<? extends DataObject> path, DataChangeListener changeListener) {
getDataBrokerChecked().registerChangeListener(path, changeListener);
}
+ @Override
@Deprecated
public void unregisterChangeListener(InstanceIdentifier<? extends DataObject> path,
DataChangeListener changeListener) {
getDataBrokerChecked().unregisterChangeListener(path, changeListener);
}
+ @Override
@Deprecated
public DataObject readConfigurationData(InstanceIdentifier<? extends DataObject> path) {
return getDataBrokerChecked().readConfigurationData(path);
}
+ @Override
public DataObject readOperationalData(InstanceIdentifier<? extends DataObject> path) {
return getDataBrokerChecked().readOperationalData(path);
}
+ @Override
@Deprecated
public ListenerRegistration<DataChangeListener> registerDataChangeListener(
InstanceIdentifier<? extends DataObject> path, DataChangeListener listener) {
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
-import org.opendaylight.controller.sal.binding.api.mount.MountProviderInstance;
import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.concepts.Registration;
L listener) {
return getRpcRegistryChecked().registerRouteChangeListener(listener);
}
-
+
@Override
public ListenerRegistration<NotificationInterestListener> registerInterestListener(
NotificationInterestListener interestListener) {
*/
package org.opendaylight.controller.md.sal.binding.util;
-import java.awt.image.SinglePixelPackedSampleModel;
+import static com.google.common.base.Preconditions.checkNotNull;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
-import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
-import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
import org.opendaylight.controller.sal.binding.api.BindingAwareService;
import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.controller.sal.binding.api.rpc.RpcContextIdentifier;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcService;
-import static com.google.common.base.Preconditions.*;
-
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.MutableClassToInstanceMap;
checkNotNull(serviceProvider,"Service map should not be null");
return new SingleConsumerContextImpl(serviceProvider);
}
-
+
public static ProviderContext createProviderContext(BindingAwareProvider provider,
ClassToInstanceMap<BindingAwareService> serviceProvider) {
checkNotNull(provider,"Provider should not be null");
consumer.onSessionInitialized(context);
return context;
}
-
+
public static ProviderContext createProviderContextAndInitialize(BindingAwareProvider provider,
ClassToInstanceMap<BindingAwareService> serviceProvider) {
ProviderContext context = createProviderContext(provider, serviceProvider);
// FIXME: Create Proxy
return instance;
}
-
+
private static class SingleConsumerContextImpl implements ConsumerContext, AutoCloseable {
-
+
private ClassToInstanceMap<BindingAwareService> alreadyRetrievedServices;
private ClassToInstanceMap<BindingAwareService> serviceProvider;
public final <T extends RpcService> T getRpcService(Class<T> module) {
return getSALService(RpcConsumerRegistry.class).getRpcService(module);
}
-
+
@Override
public final <T extends BindingAwareService> T getSALService(Class<T> service) {
checkNotNull(service,"Service class should not be null.");
}
return tryToRetrieveSalService(service);
}
-
+
private synchronized <T extends BindingAwareService> T tryToRetrieveSalService(Class<T> service) {
final T potential = alreadyRetrievedServices.getInstance(service);
if(potential != null) {
alreadyRetrievedServices.put(service, retrieved);
return retrieved;
}
-
+
@Override
public final void close() throws Exception {
alreadyRetrievedServices = null;
serviceProvider = null;
}
}
-
+
private static class SingleProviderContextImpl extends SingleConsumerContextImpl implements ProviderContext {
public SingleProviderContextImpl(ClassToInstanceMap<BindingAwareService> serviceProvider) {
super(serviceProvider);
}
-
+
@Override
public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
L listener) {
return getSALService(RpcProviderRegistry.class).registerRouteChangeListener(listener);
}
-
+
@Override
public <T extends RpcService> RoutedRpcRegistration<T> addRoutedRpcImplementation(Class<T> type,
T implementation) throws IllegalStateException {
return getSALService(RpcProviderRegistry.class).addRoutedRpcImplementation(type, implementation);
}
-
+
@Override
public <T extends RpcService> RpcRegistration<T> addRpcImplementation(Class<T> type, T implementation)
throws IllegalStateException {
return getSALService(RpcProviderRegistry.class).addRpcImplementation(type, implementation);
}
-
+
@Deprecated
@Override
public void registerFunctionality(ProviderFunctionality functionality) {
// NOOP
}
-
+
@Deprecated
@Override
public void unregisterFunctionality(ProviderFunctionality functionality) {
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);
*/
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;
+//FIXME: After 0.6 Release of YANGTools refactor to use Path marker interface for arguments.
+//import org.opendaylight.yangtools.concepts.Path;
public interface DataModification<P/* extends Path<P> */, D> extends DataChange<P, D>, DataReader<P, D> {
/**
* Returns transaction identifier
- *
+ *
* @return Transaction identifier
*/
Object getIdentifier();
TransactionStatus getStatus();
/**
- *
+ *
* @deprecated Use {@link #putOperationalData(Object, Object)} instead.
- *
+ *
* @param path
* @param data
*/
/**
* @deprecated Use {@link #removeOperationalData(Object)}
- *
+ *
* @param path
*/
@Deprecated
/**
* 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
*/
package org.opendaylight.controller.md.sal.common.impl;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.Collections;
import java.util.EventListener;
import java.util.HashSet;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import static com.google.common.base.Preconditions.*;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
return unmodifiableView;
}
-
+
public ListenerRegistration<T> register(T listener) {
checkNotNull(listener, "Listener should not be null.");
ListenerRegistrationImpl<T> ret = new ListenerRegistrationImpl<T>(listener);
listeners.add(ret);
return ret;
}
-
-
+
+
@SuppressWarnings("rawtypes")
private void remove(ListenerRegistrationImpl registration) {
listeners.remove(registration);
package org.opendaylight.controller.md.sal.common.impl.util;
import java.util.concurrent.locks.Lock;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock;
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
private final ReentrantReadWriteLock delegateLock = new ReentrantReadWriteLock();
private final ReadLock delegateReadLock = delegateLock.readLock();
private final WriteLock delegateWriteLock = delegateLock.writeLock();
-
-
+
+
protected Lock getDelegateReadLock() {
return delegateReadLock;
}
}
/**
- *
+ *
* @param newDelegate
* @return oldDelegate
*/
delegateWriteLock.unlock();
}
}
-
-
+
+
protected void onDelegateChanged(T oldDelegate, T newDelegate) {
// NOOP in abstract calss;
}
package org.opendaylight.controller.sal.common.util;
import java.io.Serializable;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import org.opendaylight.yangtools.concepts.Immutable;
import org.opendaylight.yangtools.yang.common.RpcError;
import com.google.common.collect.ImmutableList;
public class Rpcs {
-
+
public static <T> RpcResult<T> getRpcResult(boolean successful) {
RpcResult<T> ret = new RpcResultTO<T>(successful, null, ImmutableList.<RpcError>of());
return ret;
}
-
+
public static <T> RpcResult<T> getRpcResult(boolean successful, T result,
Collection<RpcError> errors) {
RpcResult<T> ret = new RpcResultTO<T>(successful, result, errors);
public static <T> RpcResult<T> getRpcResult(boolean successful, Collection<RpcError> errors) {
return new RpcResultTO<T>(successful, null, errors);
}
-
- private static class RpcResultTO<T> implements RpcResult<T>, Serializable, Immutable {
+ private static class RpcResultTO<T> implements RpcResult<T>, Serializable, Immutable {
+ private static final long serialVersionUID = 1L;
private final Collection<RpcError> errors;
private final T result;
private final boolean successful;
import java.util.Collection;
import java.util.Collections;
-import javax.naming.Context;
-
-import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
broker.registerProvider(this, context);
return broker;
}
-
+
return null;
}
-
+
@Override
public void modifiedService(ServiceReference<Broker> reference, Broker service) {
// NOOP
}
-
+
@Override
public void removedService(ServiceReference<Broker> reference, Broker service) {
stopImpl(context);
}
-
+
}
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;
/**
* Returns transaction identifier
- *
+ *
* @return Transaction identifier
*/
+ @Override
Object getIdentifier();
-
+
+ @Override
TransactionStatus getStatus();
-
+
/**
* Commits transaction to be stored in global data repository.
- *
- *
- * @return Future object which returns RpcResult with TransactionStatus
+ *
+ *
+ * @return Future object which returns RpcResult with TransactionStatus
* when transaction is processed by store.
*/
+ @Override
Future<RpcResult<TransactionStatus>> commit();
-
+
ListenerRegistration<DataTransactionListener> registerListener(DataTransactionListener listener);
-
-
+
public interface DataTransactionListener extends EventListener {
-
void onStatusUpdated(DataModificationTransaction transaction,TransactionStatus status);
-
}
-
-
-
}
import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
import org.opendaylight.controller.sal.core.api.data.DataProviderService;
import org.opendaylight.controller.sal.core.api.notify.NotificationPublishService;
-import com.google.common.base.Optional;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
public interface MountProvisionInstance extends //
import java.util.Collection;
import java.util.Collections;
-import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-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.BrokerService;
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;
private static Logger log = LoggerFactory
.getLogger(NotificationModule.class);
- private Multimap<QName, NotificationListener> listeners = HashMultimap
+ private final Multimap<QName, NotificationListener> listeners = HashMultimap
.create();
private static final Set<Class<? extends BrokerService>> PROVIDED_SERVICE_TYPE = ImmutableSet
private class NotificationConsumerSessionImpl implements
NotificationService {
- private Multimap<QName, NotificationListener> consumerListeners = HashMultimap
+ private final Multimap<QName, NotificationListener> consumerListeners = HashMultimap
.create();
private boolean closed = false;
+ @Override
public Registration<NotificationListener> addNotificationListener(QName notification,
NotificationListener listener) {
checkSessionState();
package org.opendaylight.controller.sal.dom.broker.impl;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-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.notify.NotificationListener;
-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.controller.sal.dom.broker.spi.NotificationRouter;
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.concepts.Registration;
import org.slf4j.LoggerFactory;
import com.google.common.collect.HashMultimap;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
public class NotificationRouterImpl implements NotificationRouter {
private static Logger log = LoggerFactory.getLogger(NotificationRouterImpl.class);
- private Multimap<QName, Registration<NotificationListener>> listeners = Multimaps.synchronizedSetMultimap(HashMultimap.<QName, Registration<NotificationListener>>create());
+ private final Multimap<QName, Registration<NotificationListener>> listeners = Multimaps.synchronizedSetMultimap(HashMultimap.<QName, Registration<NotificationListener>>create());
// private Registration<NotificationListener> defaultListener;
-
+
private void sendNotification(CompositeNode notification) {
final QName type = notification.getNodeType();
final Collection<Registration<NotificationListener>> toNotify = listeners.get(type);
public void publish(CompositeNode notification) {
sendNotification(notification);
}
-
+
@Override
public Registration<NotificationListener> addNotificationListener(QName notification, NotificationListener listener) {
ListenerRegistration ret = new ListenerRegistration(notification, listener);
*/
package org.opendaylight.controller.sal.dom.broker.osgi;
-import org.opendaylight.controller.sal.core.api.data.DataBrokerService;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionInstance;
import org.opendaylight.controller.sal.core.api.mount.MountProvisionService;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
public class MountProviderServiceProxy extends AbstractBrokerServiceProxy<MountProvisionService> implements MountProvisionService{
-
+
public MountProviderServiceProxy(ServiceReference<MountProvisionService> ref, MountProvisionService delegate) {
super(ref, delegate);
}
+ @Override
public MountProvisionInstance getMountPoint(InstanceIdentifier path) {
return getDelegate().getMountPoint(path);
}
+ @Override
public MountProvisionInstance createMountPoint(InstanceIdentifier path) {
return getDelegate().createMountPoint(path);
}
+ @Override
public MountProvisionInstance createOrGetMountPoint(InstanceIdentifier path) {
return getDelegate().createOrGetMountPoint(path);
}
-
+
@Override
public ListenerRegistration<MountProvisionListener> registerProvisionListener(MountProvisionListener listener) {
return getDelegate().registerProvisionListener(listener);
import java.util.Set;
-import org.opendaylight.controller.sal.core.api.RpcImplementation;
-import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
import org.opendaylight.controller.sal.core.api.Broker.RoutedRpcRegistration;
import org.opendaylight.controller.sal.core.api.Broker.RpcRegistration;
-import org.opendaylight.controller.sal.core.api.RpcRegistrationListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.controller.sal.core.api.RpcImplementation;
+import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
@Override
public RoutedRpcRegistration addRoutedRpcImplementation(QName rpcType, RpcImplementation implementation);
-
+
@Override
public RpcRegistration addRpcImplementation(QName rpcType, RpcImplementation implementation)
throws IllegalArgumentException;
-
+
@Override
public Set<QName> getSupportedRpcs();
-
+
@Override
public RpcResult<CompositeNode> invokeRpc(QName rpc, CompositeNode input);
}
*/
package org.opendaylight.controller.sal.connect.netconf;
+import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_ACTION_QNAME;
+import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_CANDIDATE_QNAME;
+import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_COMMIT_QNAME;
+import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_CONFIG_QNAME;
+import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_EDIT_CONFIG_QNAME;
+import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_RUNNING_QNAME;
+import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.NETCONF_TARGET_QNAME;
+
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
-import org.eclipse.xtext.xbase.lib.IterableExtensions;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
-import static org.opendaylight.controller.sal.connect.netconf.NetconfMapping.*;
-
public class NetconfDeviceTwoPhaseCommitTransaction implements DataCommitTransaction<InstanceIdentifier, CompositeNode> {
- private NetconfDevice device;
+ private final NetconfDevice device;
private final DataModification<InstanceIdentifier, CompositeNode> modification;
- private boolean candidateSupported = true;
+ private final boolean candidateSupported = true;
public NetconfDeviceTwoPhaseCommitTransaction(NetconfDevice device,
DataModification<InstanceIdentifier, CompositeNode> modification) {
CompositeNodeBuilder<ImmutableCompositeNode> builder = configurationRpcBuilder();
builder.setQName(NETCONF_EDIT_CONFIG_QNAME);
builder.add(editStructure);
-
+
RpcResult<CompositeNode> rpcResult = device.invokeRpc(NETCONF_EDIT_CONFIG_QNAME, builder.toInstance());
Preconditions.checkState(rpcResult.isSuccessful(),"Rpc Result was unsuccessful");
-
+
}
private CompositeNodeBuilder<ImmutableCompositeNode> configurationRpcBuilder() {
CompositeNodeBuilder<ImmutableCompositeNode> ret = ImmutableCompositeNode.builder();
-
+
Node<?> targetNode;
if(candidateSupported) {
targetNode = ImmutableCompositeNode.create(NETCONF_CANDIDATE_QNAME, ImmutableList.<Node<?>>of());
for (Entry<QName, Object> entry : predicates.entrySet()) {
builder.addLeaf(entry.getKey(), entry.getValue());
}
-
+
if (isLast) {
if (action.isPresent()) {
builder.setAttribute(NETCONF_ACTION_QNAME, action.get());
builder.add(child);
}
}
-
+
}
} else {
builder.add(previous);
import java.util.Set;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState;
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.model.util.repo.SchemaSourceProvider;
import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
class NetconfRemoteSchemaSourceProvider implements SchemaSourceProvider<String> {
import java.io.IOException;
import java.io.InputStream;
import java.io.StringBufferInputStream;
-import java.io.StringReader;
import org.opendaylight.yangtools.concepts.Delegator;
import org.opendaylight.yangtools.yang.common.QName;
/**
- *
+ *
*
*/
public class YangModelInputStreamAdapter extends InputStream implements Delegator<InputStream> {
final String source;
final QName moduleIdentifier;
final InputStream delegate;
-
-
-
+
+
+
private YangModelInputStreamAdapter(String source, QName moduleIdentifier, InputStream delegate) {
super();
this.source = source;
this.delegate = delegate;
}
+ @Override
public int read() throws IOException {
return delegate.read();
}
+ @Override
public int hashCode() {
return delegate.hashCode();
}
+ @Override
public int read(byte[] b) throws IOException {
return delegate.read(b);
}
+ @Override
public boolean equals(Object obj) {
return delegate.equals(obj);
}
+ @Override
public int read(byte[] b, int off, int len) throws IOException {
return delegate.read(b, off, len);
}
+ @Override
public long skip(long n) throws IOException {
return delegate.skip(n);
}
+ @Override
public int available() throws IOException {
return delegate.available();
}
+ @Override
public void close() throws IOException {
delegate.close();
}
+ @Override
public void mark(int readlimit) {
delegate.mark(readlimit);
}
+ @Override
public void reset() throws IOException {
delegate.reset();
}
+ @Override
public boolean markSupported() {
return delegate.markSupported();
}
Broker broker = getDomBrokerDependency();
-
-
final int port = getPort() != null ? getPort() : ZEROMQ_ROUTER_PORT;
ServerImpl serverImpl = new ServerImpl(port);
RoutingTableProvider provider = new RoutingTableProvider(bundleContext,serverImpl);
-
RemoteRpcProvider facade = new RemoteRpcProvider(serverImpl, clientImpl);
facade.setRoutingTableProvider(provider );
import java.util.concurrent.TimeUnit;
import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
/**
* ZeroMq based implementation of RpcRouter. It implements RouteChangeListener of RoutingTable
public ServerImpl(int port) {
this.port = port;
- this.serverAddress = new StringBuilder(findIpAddress()).
- append(":").
- append(port).
- toString();
}
public RoutingTableProvider getRoutingTableProvider() {
"Remote RPC Server is already running");
status = State.STARTING;
+ _logger.debug("Remote RPC Server is starting...");
+
+ String hostIpAddress = findIpAddress();
+
+ //Log and silently die as per discussion in the bug (bug-362)
+ //https://bugs.opendaylight.org/show_bug.cgi?id=362
+ //
+ // A tracking enhancement defect (bug-366) is created to properly fix this issue
+ //https://bugs.opendaylight.org/show_bug.cgi?id=366
+ //checkState(hostIpAddress != null, "Remote RPC Server could not acquire host ip address");
+
+ if (hostIpAddress == null) {
+ _logger.error("Remote RPC Server could not acquire host ip address. Stopping...");
+ stop();
+ return;
+ }
+
+ this.serverAddress = new StringBuilder(hostIpAddress).
+ append(":").
+ append(port).
+ toString();
+
context = ZMQ.context(1);
remoteServices = new HashSet<QName>();//
serverPool = Executors.newSingleThreadExecutor();//main server thread
* @return
*/
private String findIpAddress() {
- String hostAddress = null;
Enumeration e = null;
try {
e = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e1) {
- e1.printStackTrace();
+ _logger.error("Failed to get list of interfaces", e1);
+ //throw new RuntimeException("Failed to acquire list of interfaces", e1);
+ return null;
}
while (e.hasMoreElements()) {
Enumeration ee = n.getInetAddresses();
while (ee.hasMoreElements()) {
InetAddress i = (InetAddress) ee.nextElement();
- if ((i instanceof Inet4Address) && (i.isSiteLocalAddress()))
- hostAddress = i.getHostAddress();
+ _logger.debug("Trying address {}", i);
+ if ((i instanceof Inet4Address) && (i.isSiteLocalAddress())) {
+ String hostAddress = i.getHostAddress();
+ _logger.debug("Settled on host address {}", hostAddress);
+ return hostAddress;
+ }
}
}
- return hostAddress;
+ _logger.error("Failed to find a suitable host address");
+ return null;
}
/**
import java.io.IOException;
import java.util.Collections;
-import java.util.Set;
import javax.ws.rs.WebApplicationException;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToJsonProvider;
import org.opendaylight.controller.sal.restconf.impl.test.DummyType;
import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;
import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder;
import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder;
import org.slf4j.Logger;
String jsonOutput = null;
jsonOutput = TestUtils
.writeCompNodeWithSchemaContextToOutput(prepareCompositeNode(),
- (Set<Module>) Collections.EMPTY_SET, prepareDataSchemaNode(),
+ Collections.EMPTY_SET, prepareDataSchemaNode(),
StructuredDataToJsonProvider.INSTANCE);
assertNotNull(jsonOutput);
assertTrue(jsonOutput.contains("\"lf1\": \"\""));
*/
package org.opendaylight.controller.sal.restconf.impl.cnsn.to.xml.test;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.Collections;
-import java.util.Set;
import javax.ws.rs.WebApplicationException;
import org.opendaylight.controller.sal.rest.impl.StructuredDataToXmlProvider;
import org.opendaylight.controller.sal.restconf.impl.test.DummyType;
import org.opendaylight.controller.sal.restconf.impl.test.TestUtils;
-import org.opendaylight.yangtools.yang.data.api.*;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.ModifyAction;
+import org.opendaylight.yangtools.yang.data.api.MutableCompositeNode;
+import org.opendaylight.yangtools.yang.data.api.MutableSimpleNode;
import org.opendaylight.yangtools.yang.data.impl.NodeFactory;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.parser.builder.impl.ContainerSchemaNodeBuilder;
import org.opendaylight.yangtools.yang.parser.builder.impl.LeafSchemaNodeBuilder;
import org.slf4j.Logger;
boolean nullPointerExceptionRaised = false;
try {
TestUtils.writeCompNodeWithSchemaContextToOutput(prepareCompositeNode(),
- (Set<Module>) Collections.EMPTY_SET, prepareDataSchemaNode(), StructuredDataToXmlProvider.INSTANCE);
+ Collections.EMPTY_SET, prepareDataSchemaNode(), StructuredDataToXmlProvider.INSTANCE);
} catch (WebApplicationException | IOException e) {
LOG.error("WebApplicationException or IOException was raised");
} catch (NullPointerException e) {
*/
package org.opendaylight.controller.sal.restconf.impl.test;
-import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.mockito.Mockito.verify;
import static org.opendaylight.controller.sal.restconf.impl.test.RestOperationUtils.createUri;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.ws.rs.core.Response;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.opendaylight.controller.sal.core.api.mount.MountInstance;
import org.opendaylight.controller.sal.core.api.mount.MountService;
responseBody).find());
String[] split = responseBody.split("\"module\"");
assertEquals("\"module\" element is returned more then once",2,split.length);
-
+
response = target(uri).request("application/yang.api+xml").get();
assertEquals(200, response.getStatus());
.find());
split = responseBody.split("<module");
assertEquals("<module element is returned more then once",2,split.length);
-
-
-
+
+
+
}
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.websocketx.CloseWebSocketFrame;
import io.netty.handler.codec.http.websocketx.PongWebSocketFrame;
-import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import io.netty.handler.codec.http.websocketx.WebSocketClientHandshaker;
import io.netty.handler.codec.http.websocketx.WebSocketFrame;
import io.netty.util.CharsetUtil;
private static final Logger logger = LoggerFactory.getLogger(WebSocketClientHandler.class.toString());
private final WebSocketClientHandshaker handshaker;
private ChannelPromise handshakeFuture;
- private IClientMessageCallback messageListener;
+ private final IClientMessageCallback messageListener;
public WebSocketClientHandler(WebSocketClientHandshaker handshaker,IClientMessageCallback listener) {
import java.util.concurrent.ExecutionException;
import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareConsumer;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.controller.sal.binding.api.NotificationService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
-import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
-import org.opendaylight.controller.sal.common.GlobalDataStore;
import org.opendaylight.controller.sample.toaster.provider.api.ToastConsumer;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInputBuilder;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastDone;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToastType;
-import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster;
-import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterData;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.osgi.framework.BundleActivator;
public void onSessionInitialized(ConsumerContext session) {
this.session = session;
NotificationService notificationService = session.getSALService(NotificationService.class);
- notificationService.addNotificationListener(ToastDone.class, this);
+ notificationService.registerNotificationListener(ToastDone.class, this);
}
@Override
import java.util.Collections;
import org.opendaylight.controller.sal.binding.api.AbstractBindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
import org.opendaylight.yangtools.yang.binding.RpcService;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static final Logger log = LoggerFactory.getLogger(ToasterProvider.class);
private ProviderContext providerContext;
- private OpendaylightToaster toaster;
+ private final OpendaylightToaster toaster;
public ToasterProvider() {
toaster = new OpendaylightToaster();
<groupId>org.eclipse.xtend</groupId>
<artifactId>org.eclipse.xtend.lib</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
OpendaylightFlowTableStatisticsListener,
OpendaylightQueueStatisticsListener{
- public final static Logger sucLogger = LoggerFactory.getLogger(StatisticsUpdateCommiter.class);
+ private final static Logger sucLogger = LoggerFactory.getLogger(StatisticsUpdateCommiter.class);
private final StatisticsProvider statisticsManager;
private final MultipartMessageManager messageManager;
private int unaccountedFlowsCounter = 1;
+ /**
+ * default ctor
+ * @param manager
+ */
public StatisticsUpdateCommiter(final StatisticsProvider manager){
this.statisticsManager = manager;
}
- private NodeRef getNodeRef(NodeKey nodeKey){
+ private static NodeRef getNodeRef(NodeKey nodeKey){
InstanceIdentifierBuilder<?> builder = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey);
return new NodeRef(builder.toInstance());
}
return true;
}
- private boolean layer3MatchEquals(Layer3Match statsLayer3Match, Layer3Match storedLayer3Match){
-
+ protected static boolean layer3MatchEquals(Layer3Match statsLayer3Match, Layer3Match storedLayer3Match){
+ boolean verdict = true;
if(statsLayer3Match instanceof Ipv4Match && storedLayer3Match instanceof Ipv4Match){
Ipv4Match statsIpv4Match = (Ipv4Match)statsLayer3Match;
Ipv4Match storedIpv4Match = (Ipv4Match)storedLayer3Match;
-
- if (storedIpv4Match.getIpv4Destination()== null) {
- if (statsIpv4Match.getIpv4Destination()!= null) {
- return false;
- }
- } else if(!IpAddressEquals(statsIpv4Match.getIpv4Destination(),storedIpv4Match.getIpv4Destination())){
- return false;
+
+ if (verdict) {
+ verdict = compareNullSafe(
+ storedIpv4Match.getIpv4Destination(), statsIpv4Match.getIpv4Destination());
}
- if (storedIpv4Match.getIpv4Source() == null) {
- if (statsIpv4Match.getIpv4Source() != null) {
- return false;
- }
- } else if(!IpAddressEquals(statsIpv4Match.getIpv4Source(),storedIpv4Match.getIpv4Source())) {
- return false;
+ if (verdict) {
+ verdict = compareNullSafe(
+ statsIpv4Match.getIpv4Source(), storedIpv4Match.getIpv4Source());
+ }
+ } else {
+ Boolean nullCheckOut = checkNullValues(storedLayer3Match, statsLayer3Match);
+ if (nullCheckOut != null) {
+ verdict = nullCheckOut;
+ } else {
+ verdict = storedLayer3Match.equals(statsLayer3Match);
}
-
- return true;
- }else{
- return storedLayer3Match.equals(statsLayer3Match);
}
+
+ return verdict;
}
- private boolean IpAddressEquals(Ipv4Prefix statsIpAddress, Ipv4Prefix storedIpAddress) {
+ private static boolean compareNullSafe(Ipv4Prefix statsIpv4, Ipv4Prefix storedIpv4) {
+ boolean verdict = true;
+ Boolean checkDestNullValuesOut = checkNullValues(storedIpv4, statsIpv4);
+ if (checkDestNullValuesOut != null) {
+ verdict = checkDestNullValuesOut;
+ } else if(!IpAddressEquals(statsIpv4, storedIpv4)){
+ verdict = false;
+ }
+
+ return verdict;
+ }
+
+ private static Boolean checkNullValues(Object v1, Object v2) {
+ Boolean verdict = null;
+ if (v1 == null && v2 != null) {
+ verdict = Boolean.FALSE;
+ } else if (v1 != null && v2 == null) {
+ verdict = Boolean.FALSE;
+ } else if (v1 == null && v2 == null) {
+ verdict = Boolean.TRUE;
+ }
+
+ return verdict;
+ }
+
+ /**
+ * TODO: why don't we use the default Ipv4Prefix.equals()?
+ *
+ * @param statsIpAddress
+ * @param storedIpAddress
+ * @return true if IPv4prefixes equals
+ */
+ private static boolean IpAddressEquals(Ipv4Prefix statsIpAddress, Ipv4Prefix storedIpAddress) {
IntegerIpAddress statsIpAddressInt = StrIpToIntIp(statsIpAddress.getValue());
IntegerIpAddress storedIpAddressInt = StrIpToIntIp(storedIpAddress.getValue());
return false;
}
- private boolean IpAndMaskBasedMatch(IntegerIpAddress statsIpAddressInt,IntegerIpAddress storedIpAddressInt){
+ private static boolean IpAndMaskBasedMatch(IntegerIpAddress statsIpAddressInt,IntegerIpAddress storedIpAddressInt){
return ((statsIpAddressInt.getIp() & statsIpAddressInt.getMask()) == (storedIpAddressInt.getIp() & storedIpAddressInt.getMask()));
}
- private boolean IpBasedMatch(IntegerIpAddress statsIpAddressInt,IntegerIpAddress storedIpAddressInt){
+ private static boolean IpBasedMatch(IntegerIpAddress statsIpAddressInt,IntegerIpAddress storedIpAddressInt){
return (statsIpAddressInt.getIp() == storedIpAddressInt.getIp());
}
- /*
+ /**
* Method return integer version of ip address. Converted int will be mask if
* mask specified
*/
- private IntegerIpAddress StrIpToIntIp(String ipAddresss){
+ private static IntegerIpAddress StrIpToIntIp(String ipAddresss){
String[] parts = ipAddresss.split("/");
String ip = parts[0];
prefix = Integer.parseInt(parts[1]);
}
- Inet4Address addr =null;
+ IntegerIpAddress integerIpAddress = null;
try {
- addr = (Inet4Address) InetAddress.getByName(ip);
- } catch (UnknownHostException e){}
-
- byte[] addrBytes = addr.getAddress();
- int ipInt = ((addrBytes[0] & 0xFF) << 24) |
- ((addrBytes[1] & 0xFF) << 16) |
- ((addrBytes[2] & 0xFF) << 8) |
- ((addrBytes[3] & 0xFF) << 0);
-
- int mask = 0xffffffff << 32 - prefix;
+ Inet4Address addr = (Inet4Address) InetAddress.getByName(ip);
+ byte[] addrBytes = addr.getAddress();
+ int ipInt = ((addrBytes[0] & 0xFF) << 24) |
+ ((addrBytes[1] & 0xFF) << 16) |
+ ((addrBytes[2] & 0xFF) << 8) |
+ ((addrBytes[3] & 0xFF) << 0);
+
+ int mask = 0xffffffff << 32 - prefix;
+
+ integerIpAddress = new IntegerIpAddress(ipInt, mask);
+ } catch (UnknownHostException e){
+ sucLogger.error("Failed to determine host IP address by name: {}", e.getMessage(), e);
+ }
- return new IntegerIpAddress(ipInt, mask);
+ return integerIpAddress;
}
- class IntegerIpAddress{
+ static class IntegerIpAddress{
int ip;
int mask;
public IntegerIpAddress(int ip, int mask) {
--- /dev/null
+/**
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.md.statistics.manager;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class StatisticsUpdateCommiterTest {
+
+ private static final Logger LOG = LoggerFactory
+ .getLogger(StatisticsUpdateCommiterTest.class);
+
+ /**
+ * Test method for {@link org.opendaylight.controller.md.statistics.manager.StatisticsUpdateCommiter#layer3MatchEquals(org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match, org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Layer3Match)}.
+ */
+ @Test
+ public void testLayer3MatchEquals() {
+ String[][][] matchSeeds = new String[][][] {
+ {{"10.1.2.0/24", "10.1.2.0/24"}, {"10.1.2.0/24", "10.1.2.0/24"}},
+ {{"10.1.2.0/24", "10.1.2.0/24"}, {"10.1.2.0/24", "10.1.1.0/24"}},
+ {{"10.1.1.0/24", "10.1.2.0/24"}, {"10.1.2.0/24", "10.1.2.0/24"}},
+ {{"10.1.1.0/24", "10.1.1.0/24"}, {"10.1.2.0/24", "10.1.2.0/24"}},
+
+ {{"10.1.1.0/24", null}, {"10.1.1.0/24", "10.1.2.0/24"}},
+ {{"10.1.1.0/24", null}, {"10.1.2.0/24", "10.1.2.0/24"}},
+ {{"10.1.1.0/24", null}, {"10.1.2.0/24", null}},
+ {{"10.1.1.0/24", null}, {"10.1.1.0/24", null}},
+
+ {{null, "10.1.1.0/24"}, {"10.1.2.0/24", "10.1.1.0/24"}},
+ {{null, "10.1.1.0/24"}, {"10.1.2.0/24", "10.1.2.0/24"}},
+ {{null, "10.1.1.0/24"}, {null, "10.1.2.0/24"}},
+ {{null, "10.1.1.0/24"}, {null, "10.1.1.0/24"}},
+
+ {{null, null}, {null, "10.1.1.0/24"}},
+ {{null, null}, {null, null}},
+ };
+
+ boolean[] matches = new boolean[] {
+ true,
+ false,
+ false,
+ false,
+
+ false,
+ false,
+ false,
+ true,
+
+ false,
+ false,
+ false,
+ true,
+
+ false,
+ true
+ };
+
+ for (int i = 0; i < matches.length; i++) {
+ checkComparisonOfL3Match(
+ matchSeeds[i][0][0], matchSeeds[i][0][1],
+ matchSeeds[i][1][0], matchSeeds[i][1][1],
+ matches[i]);
+ }
+ }
+
+ /**
+ * @param m1Source match1 - src
+ * @param m1Destination match1 - dest
+ * @param m2Source match2 - src
+ * @param msDestination match2 - dest
+ * @param matches expected match output
+ *
+ */
+ private static void checkComparisonOfL3Match(String m1Source, String m1Destination,
+ String m2Source, String msDestination, boolean matches) {
+ Ipv4Match m1Layer3 = prepareIPv4Match(m1Source, m1Destination);
+ Ipv4Match m2Layer3 = prepareIPv4Match(m2Source, msDestination);
+ boolean comparisonResult;
+ try {
+ comparisonResult = StatisticsUpdateCommiter.layer3MatchEquals(m1Layer3, m2Layer3);
+ Assert.assertEquals("failed to compare: "+m1Layer3+" vs. "+m2Layer3,
+ matches, comparisonResult);
+ } catch (Exception e) {
+ LOG.error("failed to compare: {} vs. {}", m1Layer3, m2Layer3, e);
+ Assert.fail(e.getMessage());
+ }
+ }
+
+ private static Ipv4Match prepareIPv4Match(String source, String destination) {
+ Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
+ if (source != null) {
+ ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(source));
+ }
+ if (destination != null) {
+ ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(destination));
+ }
+
+ return ipv4MatchBuilder.build();
+ }
+
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">\r
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">\r
+\r
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">\r
+ <layout class="org.apache.log4j.PatternLayout">\r
+ <param name="ConversionPattern" value="%-6p %d{HH:mm:ss.SSS} [%10.10t] %30.30c %x - %m%n" />\r
+ </layout>\r
+ </appender>\r
+\r
+ <logger name="org.opendaylight.controller.md.statistics" additivity="false">\r
+ <level value="DEBUG" />\r
+ <appender-ref ref="console" />\r
+ </logger>\r
+\r
+ <root>\r
+ <priority value="INFO" />\r
+ <appender-ref ref="console" />\r
+ </root>\r
+</log4j:configuration>\r
package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes;
+import javax.management.openmbean.ArrayType;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.OpenType;
+import javax.management.openmbean.SimpleType;
+
import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.DependencyAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
-import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.SimpleType;
-
public abstract class AttributeIfcSwitchStatement<T> {
protected AttributeIfc lastAttribute;
protected abstract T caseListDependeciesAttribute(ArrayType<?> openType);
private static class UnknownOpenTypeException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
+
public UnknownOpenTypeException(String message) {
super(message);
}
package org.opendaylight.controller.netconf.api;
-import org.opendaylight.protocol.framework.DeserializerException;
-
/**
* This exception is thrown by
* {@link NetconfSessionListener#onMessage(NetconfMessage)} to indicate fatal
* communication problem after which the session should be closed.
*/
-public class NetconfDeserializerException extends DeserializerException {
+public class NetconfDeserializerException extends Exception {
private static final long serialVersionUID = 1L;
public NetconfDeserializerException(final String message) {
import java.util.Collections;
import java.util.Map;
-import org.opendaylight.protocol.framework.DocumentedException;
-
/**
* Checked exception to communicate an error that needs to be sent to the
* netconf client.
*/
-public class NetconfDocumentedException extends DocumentedException {
+public class NetconfDocumentedException extends Exception {
private static final long serialVersionUID = 1L;
* implementing ProtocolMessage interface.
*/
public final class NetconfMessage {
-
- private static final long serialVersionUID = 462175939836367285L;
-
+ private final String additionalHeader;
private final Document doc;
- private String additionalHeader;
-
public NetconfMessage(final Document doc) {
this(doc, null);
}
package org.opendaylight.controller.netconf.api;
import io.netty.channel.Channel;
+import io.netty.channel.ChannelFuture;
+
+import java.io.IOException;
+
import org.opendaylight.protocol.framework.AbstractProtocolSession;
import org.opendaylight.protocol.framework.SessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-
public abstract class NetconfSession extends AbstractProtocolSession<NetconfMessage> {
- protected final Channel channel;
- private final SessionListener sessionListener;
+ private static final Logger logger = LoggerFactory.getLogger(NetconfSession.class);
+ private final SessionListener<NetconfMessage, NetconfSession, NetconfTerminationReason> sessionListener;
private final long sessionId;
private boolean up = false;
- private static final Logger logger = LoggerFactory.getLogger(NetconfSession.class);
- protected NetconfSession(SessionListener sessionListener, Channel channel, long sessionId) {
+ protected final Channel channel;
+
+ protected NetconfSession(SessionListener<NetconfMessage, NetconfSession, NetconfTerminationReason> sessionListener, Channel channel, long sessionId) {
this.sessionListener = sessionListener;
this.channel = channel;
this.sessionId = sessionId;
logger.debug("Session {} created", toString());
}
+
@Override
public void close() {
channel.close();
sessionListener.onMessage(this, netconfMessage);
}
- public void sendMessage(NetconfMessage netconfMessage) {
- channel.writeAndFlush(netconfMessage);
+ public ChannelFuture sendMessage(NetconfMessage netconfMessage) {
+ return channel.writeAndFlush(netconfMessage);
}
@Override
return sb.toString();
}
- public boolean isUp() {
+ public final boolean isUp() {
return up;
}
- public long getSessionId() {
+ public final long getSessionId() {
return sessionId;
}
}
package org.opendaylight.controller.netconf.client;
-import com.google.common.base.Optional;
-import io.netty.channel.ChannelHandler;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.util.HashedWheelTimer;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.Promise;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.api.NetconfTerminationReason;
import org.opendaylight.controller.netconf.util.handler.ssh.SshHandler;
import org.opendaylight.controller.netconf.util.handler.ssh.authentication.AuthenticationHandler;
import org.opendaylight.controller.netconf.util.handler.ssh.client.Invoker;
-import org.opendaylight.controller.netconf.util.messages.NetconfMessageFactory;
-import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
-import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
-import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.framework.SessionListener;
import org.opendaylight.protocol.framework.SessionListenerFactory;
-import java.io.IOException;
-import java.net.InetSocketAddress;
+import com.google.common.base.Optional;
public class NetconfSshClientDispatcher extends NetconfClientDispatcher {
- private AuthenticationHandler authHandler;
- private HashedWheelTimer timer;
- private NetconfClientSessionNegotiatorFactory negotatorFactory;
+ private final AuthenticationHandler authHandler;
+ private final HashedWheelTimer timer;
+ private final NetconfClientSessionNegotiatorFactory negotatorFactory;
public NetconfSshClientDispatcher(AuthenticationHandler authHandler, EventLoopGroup bossGroup,
EventLoopGroup workerGroup, long connectionTimeoutMillis) {
this.negotatorFactory = new NetconfClientSessionNegotiatorFactory(timer, Optional.of(additionalHeader), socketTimeoutMillis);
}
+ @Override
public Future<NetconfClientSession> createClient(InetSocketAddress address,
final NetconfClientSessionListener sessionListener, ReconnectStrategy strat) {
return super.createClient(address, strat, new PipelineInitializer<NetconfClientSession>() {
private static final class NetconfSshClientInitializer extends AbstractChannelInitializer {
- private final NetconfHandlerFactory handlerFactory;
private final AuthenticationHandler authenticationHandler;
private final NetconfClientSessionNegotiatorFactory negotiatorFactory;
private final NetconfClientSessionListener sessionListener;
public NetconfSshClientInitializer(AuthenticationHandler authHandler,
NetconfClientSessionNegotiatorFactory negotiatorFactory,
final NetconfClientSessionListener sessionListener) {
- this.handlerFactory = new NetconfHandlerFactory(new NetconfMessageFactory());
this.authenticationHandler = authHandler;
this.negotiatorFactory = negotiatorFactory;
this.sessionListener = sessionListener;
}
}
-
- private static final class NetconfHandlerFactory extends ProtocolHandlerFactory<NetconfMessage> {
-
- public NetconfHandlerFactory(final NetconfMessageFactory msgFactory) {
- super(msgFactory);
- }
-
- @Override
- public ChannelHandler[] getEncoders() {
- return new ChannelHandler[] { new ProtocolMessageEncoder(this.msgFactory) };
- }
-
- @Override
- public ChannelHandler[] getDecoders() {
- return new ChannelHandler[] { new ProtocolMessageDecoder(this.msgFactory) };
- }
- }
}
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-
-import java.util.Queue;
-
import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
import io.netty.channel.embedded.EmbeddedChannel;
+import java.util.Queue;
+
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.netconf.api.NetconfMessage;
import org.opendaylight.controller.netconf.util.handler.FramingMechanismHandlerFactory;
import org.opendaylight.controller.netconf.util.handler.NetconfMessageAggregator;
import org.opendaylight.controller.netconf.util.handler.NetconfMessageChunkDecoder;
+import org.opendaylight.controller.netconf.util.handler.NetconfMessageToXMLEncoder;
+import org.opendaylight.controller.netconf.util.handler.NetconfXMLToMessageDecoder;
import org.opendaylight.controller.netconf.util.messages.FramingMechanism;
import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants;
-import org.opendaylight.controller.netconf.util.messages.NetconfMessageFactory;
import org.opendaylight.controller.netconf.util.messages.NetconfMessageHeader;
import org.opendaylight.controller.netconf.util.test.XmlFileLoader;
-import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
-import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
public class MessageParserTest {
private NetconfMessage msg;
- private NetconfMessageFactory msgFactory = new NetconfMessageFactory();
@Before
public void setUp() throws Exception {
public void testChunkedFramingMechanismOnPipeline() throws Exception {
EmbeddedChannel testChunkChannel = new EmbeddedChannel(
FramingMechanismHandlerFactory.createHandler(FramingMechanism.CHUNK),
- new ProtocolMessageEncoder<NetconfMessage>(msgFactory),
+ new NetconfMessageToXMLEncoder(),
new NetconfMessageAggregator(FramingMechanism.CHUNK), new NetconfMessageChunkDecoder(),
- new ProtocolMessageDecoder<NetconfMessage>(msgFactory));
+ new NetconfXMLToMessageDecoder());
testChunkChannel.writeOutbound(this.msg);
Queue<Object> messages = testChunkChannel.outboundMessages();
assertFalse(messages.isEmpty());
- int msgLength = this.msgFactory.put(this.msg).length;
+ final NetconfMessageToXMLEncoder enc = new NetconfMessageToXMLEncoder();
+ final ByteBuf out = Unpooled.buffer();
+ enc.encode(null, msg, out);
+ int msgLength = out.readableBytes();
+
int chunkCount = msgLength / NetconfMessageConstants.MAX_CHUNK_SIZE;
if ((msgLength % NetconfMessageConstants.MAX_CHUNK_SIZE) != 0) {
chunkCount++;
public void testEOMFramingMechanismOnPipeline() throws Exception {
EmbeddedChannel testChunkChannel = new EmbeddedChannel(
FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM),
- new ProtocolMessageEncoder<NetconfMessage>(msgFactory), new NetconfMessageAggregator(
- FramingMechanism.EOM), new ProtocolMessageDecoder<NetconfMessage>(msgFactory));
+ new NetconfMessageToXMLEncoder(), new NetconfMessageAggregator(
+ FramingMechanism.EOM), new NetconfXMLToMessageDecoder());
testChunkChannel.writeOutbound(this.msg);
ByteBuf recievedOutbound = (ByteBuf) testChunkChannel.readOutbound();
import io.netty.channel.socket.SocketChannel;
import io.netty.util.concurrent.Promise;
+
import org.opendaylight.controller.netconf.api.NetconfSession;
import org.opendaylight.controller.netconf.util.handler.FramingMechanismHandlerFactory;
-import org.opendaylight.controller.netconf.util.handler.NetconfHandlerFactory;
import org.opendaylight.controller.netconf.util.handler.NetconfMessageAggregator;
+import org.opendaylight.controller.netconf.util.handler.NetconfMessageToXMLEncoder;
+import org.opendaylight.controller.netconf.util.handler.NetconfXMLToMessageDecoder;
import org.opendaylight.controller.netconf.util.messages.FramingMechanism;
-import org.opendaylight.controller.netconf.util.messages.NetconfMessageFactory;
public abstract class AbstractChannelInitializer {
public void initialize(SocketChannel ch, Promise<? extends NetconfSession> promise){
- NetconfHandlerFactory handlerFactory = new NetconfHandlerFactory(new NetconfMessageFactory());
ch.pipeline().addLast("aggregator", new NetconfMessageAggregator(FramingMechanism.EOM));
- ch.pipeline().addLast(handlerFactory.getDecoders());
+ ch.pipeline().addLast(new NetconfXMLToMessageDecoder());
initializeAfterDecoder(ch, promise);
ch.pipeline().addLast("frameEncoder", FramingMechanismHandlerFactory.createHandler(FramingMechanism.EOM));
- ch.pipeline().addLast(handlerFactory.getEncoders());
+ ch.pipeline().addLast(new NetconfMessageToXMLEncoder());
}
protected abstract void initializeAfterDecoder(SocketChannel ch, Promise<? extends NetconfSession> promise);
+++ /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.netconf.util.handler;
-
-import io.netty.channel.ChannelHandler;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.util.messages.NetconfMessageFactory;
-import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
-import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
-import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
-
-public class NetconfHandlerFactory extends ProtocolHandlerFactory<NetconfMessage> {
-
- public NetconfHandlerFactory(final NetconfMessageFactory msgFactory) {
- super(msgFactory);
- }
-
- @Override
- public ChannelHandler[] getEncoders() {
- return new ChannelHandler[] { new ProtocolMessageEncoder(this.msgFactory) };
- }
-
- @Override
- public ChannelHandler[] getDecoders() {
- return new ChannelHandler[] { new ProtocolMessageDecoder(this.msgFactory) };
- }
-
-}
package org.opendaylight.controller.netconf.util.handler;
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.Unpooled;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
import java.nio.charset.Charset;
import java.util.List;
+import org.opendaylight.controller.netconf.api.NetconfDeserializerException;
import org.opendaylight.controller.netconf.util.messages.NetconfMessageConstants;
-import org.opendaylight.protocol.framework.DeserializerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.handler.codec.ByteToMessageDecoder;
-
public class NetconfMessageChunkDecoder extends ByteToMessageDecoder {
private final static Logger logger = LoggerFactory.getLogger(NetconfMessageChunkDecoder.class);
in.readBytes(byteBufMsg, chunkSize);
isParsed = false;
} else {
- throw new DeserializerException("Unable to parse chunked data or header.");
+ throw new NetconfDeserializerException("Unable to parse chunked data or header.");
}
} catch (Exception e) {
logger.error("Failed to decode chunked message.", e);
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.netconf.util.handler;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToByteEncoder;
+
+import java.nio.ByteBuffer;
+
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
+
+public final class NetconfMessageToXMLEncoder extends MessageToByteEncoder<NetconfMessage> {
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMessageToXMLEncoder.class);
+
+ private final Optional<String> clientId;
+
+ public NetconfMessageToXMLEncoder() {
+ this(Optional.<String>absent());
+ }
+
+ public NetconfMessageToXMLEncoder(Optional<String> clientId) {
+ this.clientId = clientId;
+ }
+
+ @Override
+ @VisibleForTesting
+ public void encode(ChannelHandlerContext ctx, NetconfMessage msg, ByteBuf out) throws Exception {
+ LOG.debug("Sent to encode : {}", msg);
+
+ if (clientId.isPresent()) {
+ Comment comment = msg.getDocument().createComment("clientId:" + clientId.get());
+ msg.getDocument().appendChild(comment);
+ }
+
+ final ByteBuffer msgBytes;
+ if(msg.getAdditionalHeader().isPresent()) {
+ final String header = msg.getAdditionalHeader().get();
+ LOG.trace("Header of netconf message parsed \n{}", header);
+ // FIXME: this can be written in pieces
+ msgBytes = Charsets.UTF_8.encode(header + xmlToString(msg.getDocument()));
+ } else {
+ msgBytes = Charsets.UTF_8.encode(xmlToString(msg.getDocument()));
+ }
+
+ LOG.trace("Putting message \n{}", xmlToString(msg.getDocument()));
+ out.writeBytes(msgBytes);
+ }
+
+ private String xmlToString(Document doc) {
+ return XmlUtil.toString(doc, false);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.netconf.util.handler;
+
+import io.netty.buffer.ByteBuf;
+import io.netty.buffer.ByteBufUtil;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.ByteToMessageDecoder;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Arrays;
+import java.util.List;
+
+import org.opendaylight.controller.netconf.api.NetconfDeserializerException;
+import org.opendaylight.controller.netconf.api.NetconfMessage;
+import org.opendaylight.controller.netconf.util.xml.XmlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Charsets;
+import com.google.common.collect.ImmutableList;
+
+public final class NetconfXMLToMessageDecoder extends ByteToMessageDecoder {
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfXMLToMessageDecoder.class);
+
+ private static final List<byte[]> POSSIBLE_ENDS = ImmutableList.of(
+ new byte[] { ']', '\n' },
+ new byte[] { ']', '\r', '\n' });
+ private static final List<byte[]> POSSIBLE_STARTS = ImmutableList.of(
+ new byte[] { '[' },
+ new byte[] { '\r', '\n', '[' },
+ new byte[] { '\n', '[' });
+
+ @Override
+ @VisibleForTesting
+ public void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
+ if (in.readableBytes() == 0) {
+ LOG.debug("No more content in incoming buffer.");
+ return;
+ }
+
+ in.markReaderIndex();
+ try {
+ LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
+ byte[] bytes = new byte[in.readableBytes()];
+ in.readBytes(bytes);
+
+ logMessage(bytes);
+
+ String additionalHeader = null;
+
+ // FIXME: this has to be moved into the negotiator and explained as to what the heck
+ // is going on. This is definitely not specified in NETCONF and has no place here. It
+ // requires reading all data and incurs inefficiency by being unable to pipe the ByteBuf
+ // directly into the XML decoder.
+ if (startsWithAdditionalHeader(bytes)) {
+ // Auth information containing username, ip address... extracted for monitoring
+ int endOfAuthHeader = getAdditionalHeaderEndIndex(bytes);
+ if (endOfAuthHeader > -1) {
+ byte[] additionalHeaderBytes = Arrays.copyOfRange(bytes, 0, endOfAuthHeader + 2);
+ additionalHeader = additionalHeaderToString(additionalHeaderBytes);
+ bytes = Arrays.copyOfRange(bytes, endOfAuthHeader + 2, bytes.length);
+ }
+ }
+ NetconfMessage message;
+ try {
+ Document doc = XmlUtil.readXmlToDocument(new ByteArrayInputStream(bytes));
+ message = new NetconfMessage(doc, additionalHeader);
+ } catch (final SAXException | IOException | IllegalStateException e) {
+ throw new NetconfDeserializerException("Could not parse message from " + new String(bytes), e);
+ }
+
+ out.add(message);
+ } finally {
+ in.discardReadBytes();
+ }
+ }
+
+ private int getAdditionalHeaderEndIndex(byte[] bytes) {
+ for (byte[] possibleEnd : POSSIBLE_ENDS) {
+ int idx = findByteSequence(bytes, possibleEnd);
+
+ if (idx != -1) {
+ return idx;
+ }
+ }
+
+ return -1;
+ }
+
+ private static int findByteSequence(final byte[] bytes, final byte[] sequence) {
+ if (bytes.length < sequence.length) {
+ throw new IllegalArgumentException("Sequence to be found is longer than the given byte array.");
+ }
+ if (bytes.length == sequence.length) {
+ if (Arrays.equals(bytes, sequence)) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+ int j = 0;
+ for (int i = 0; i < bytes.length; i++) {
+ if (bytes[i] == sequence[j]) {
+ j++;
+ if (j == sequence.length) {
+ return i - j + 1;
+ }
+ } else {
+ j = 0;
+ }
+ }
+ return -1;
+ }
+
+ private boolean startsWithAdditionalHeader(byte[] bytes) {
+ for (byte[] possibleStart : POSSIBLE_STARTS) {
+ int i = 0;
+ for (byte b : possibleStart) {
+ if(bytes[i] != b)
+ break;
+
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ private void logMessage(byte[] bytes) {
+ String s = Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
+ LOG.debug("Parsing message \n{}", s);
+ }
+
+ private String additionalHeaderToString(byte[] bytes) {
+ return Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
+ }
+
+}
* Exception class which provides notification about exceptional situations at the virtual socket layer.
*/
public class VirtualSocketException extends RuntimeException {
+ private static final long serialVersionUID = 1L;
}
package org.opendaylight.controller.netconf.util.mapping;
+import java.util.Map;
+
import org.opendaylight.controller.netconf.api.NetconfDocumentedException;
import org.opendaylight.controller.netconf.api.NetconfOperationRouter;
import org.opendaylight.controller.netconf.mapping.api.HandlingPriority;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-import java.util.Map;
-
public abstract class AbstractNetconfOperation implements NetconfOperation {
private final String netconfSessionIdForReporting;
this.netconfSessionIdForReporting = netconfSessionIdForReporting;
}
- public String getNetconfSessionIdForReporting() {
+ public final String getNetconfSessionIdForReporting() {
return netconfSessionIdForReporting;
}
protected abstract HandlingPriority canHandle(String operationName, String netconfOperationNamespace);
@Override
- public Document handle(Document message, NetconfOperationRouter opRouter) throws NetconfDocumentedException {
+ public final Document handle(Document message, NetconfOperationRouter opRouter) throws NetconfDocumentedException {
XmlElement requestElement = getRequestElementWithCheck(message);
+++ /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.netconf.util.messages;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.Arrays;
-import java.util.List;
-
-import org.opendaylight.controller.netconf.api.NetconfDeserializerException;
-import org.opendaylight.controller.netconf.api.NetconfMessage;
-import org.opendaylight.controller.netconf.util.xml.XmlUtil;
-import org.opendaylight.protocol.framework.DeserializerException;
-import org.opendaylight.protocol.framework.DocumentedException;
-import org.opendaylight.protocol.framework.ProtocolMessageFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.xml.sax.SAXException;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableList;
-
-/**
- * NetconfMessageFactory for (de)serializing DOM documents.
- */
-public final class NetconfMessageFactory implements ProtocolMessageFactory<NetconfMessage> {
-
- private static final Logger logger = LoggerFactory.getLogger(NetconfMessageFactory.class);
- private static final List<byte[]> POSSIBLE_STARTS = ImmutableList.of(
- "[".getBytes(Charsets.UTF_8), "\r\n[".getBytes(Charsets.UTF_8), "\n[".getBytes(Charsets.UTF_8));
- private static final List<byte[]> POSSIBLE_ENDS = ImmutableList.of(
- "]\n".getBytes(Charsets.UTF_8), "]\r\n".getBytes(Charsets.UTF_8));
-
- private final Optional<String> clientId;
-
- public NetconfMessageFactory() {
- clientId = Optional.absent();
- }
-
- public NetconfMessageFactory(Optional<String> clientId) {
- this.clientId = clientId;
- }
-
- @Override
- public NetconfMessage parse(byte[] bytes) throws DeserializerException, DocumentedException {
- logMessage(bytes);
-
- String additionalHeader = null;
-
- if (startsWithAdditionalHeader(bytes)) {
- // Auth information containing username, ip address... extracted for monitoring
- int endOfAuthHeader = getAdditionalHeaderEndIndex(bytes);
- if (endOfAuthHeader > -1) {
- byte[] additionalHeaderBytes = Arrays.copyOfRange(bytes, 0, endOfAuthHeader + 2);
- additionalHeader = additionalHeaderToString(additionalHeaderBytes);
- bytes = Arrays.copyOfRange(bytes, endOfAuthHeader + 2, bytes.length);
- }
- }
- NetconfMessage message;
- try {
- Document doc = XmlUtil.readXmlToDocument(new ByteArrayInputStream(bytes));
- message = new NetconfMessage(doc, additionalHeader);
- } catch (final SAXException | IOException | IllegalStateException e) {
- throw new NetconfDeserializerException("Could not parse message from " + new String(bytes), e);
- }
- return message;
- }
-
- private static int findByteSequence(final byte[] bytes, final byte[] sequence) {
- if (bytes.length < sequence.length) {
- throw new IllegalArgumentException("Sequence to be found is longer than the given byte array.");
- }
- if (bytes.length == sequence.length) {
- if (Arrays.equals(bytes, sequence)) {
- return 0;
- } else {
- return -1;
- }
- }
- int j = 0;
- for (int i = 0; i < bytes.length; i++) {
- if (bytes[i] == sequence[j]) {
- j++;
- if (j == sequence.length) {
- return i - j + 1;
- }
- } else {
- j = 0;
- }
- }
- return -1;
- }
-
- private int getAdditionalHeaderEndIndex(byte[] bytes) {
- for (byte[] possibleEnd : POSSIBLE_ENDS) {
- int idx = findByteSequence(bytes, possibleEnd);
-
- if (idx != -1) {
- return idx;
- }
- }
-
- return -1;
- }
-
- private boolean startsWithAdditionalHeader(byte[] bytes) {
- for (byte[] possibleStart : POSSIBLE_STARTS) {
- int i = 0;
- for (byte b : possibleStart) {
- if(bytes[i] != b)
- break;
-
- return true;
- }
- }
-
- return false;
- };
-
- private void logMessage(byte[] bytes) {
- String s = Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
- logger.debug("Parsing message \n{}", s);
- }
-
- private String additionalHeaderToString(byte[] bytes) {
- return Charsets.UTF_8.decode(ByteBuffer.wrap(bytes)).toString();
- }
-
- @Override
- public byte[] put(NetconfMessage netconfMessage) {
- if (clientId.isPresent()) {
- Comment comment = netconfMessage.getDocument().createComment("clientId:" + clientId.get());
- netconfMessage.getDocument().appendChild(comment);
- }
- ByteBuffer msgBytes;
- if(netconfMessage.getAdditionalHeader().isPresent()) {
- String header = netconfMessage.getAdditionalHeader().get();
- logger.trace("Header of netconf message parsed \n{}", header);
- msgBytes = Charsets.UTF_8.encode(header + xmlToString(netconfMessage.getDocument()));
- } else {
- msgBytes = Charsets.UTF_8.encode(xmlToString(netconfMessage.getDocument()));
- }
- String content = xmlToString(netconfMessage.getDocument());
-
- logger.trace("Putting message \n{}", content);
- byte[] b = new byte[msgBytes.limit()];
- msgBytes.get(b);
- return b;
- }
-
- private String xmlToString(Document doc) {
- return XmlUtil.toString(doc, false);
- }
-}
*/
package org.opendaylight.controller.netconf.util.messages;
-import com.google.common.io.Files;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import io.netty.buffer.Unpooled;
import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
-public class NetconfMessageFactoryTest {
+import org.junit.Test;
+import org.opendaylight.controller.netconf.util.handler.NetconfXMLToMessageDecoder;
+import com.google.common.io.Files;
+public class NetconfMessageFactoryTest {
@Test
public void testAuth() throws Exception {
- NetconfMessageFactory parser = new NetconfMessageFactory();
+ NetconfXMLToMessageDecoder parser = new NetconfXMLToMessageDecoder();
File authHelloFile = new File(getClass().getResource("/netconfMessages/client_hello_with_auth.xml").getFile());
- parser.parse(Files.toByteArray(authHelloFile));
+ final List<Object> out = new ArrayList<>();
+ parser.decode(null, Unpooled.wrappedBuffer(Files.toByteArray(authHelloFile)), out);
+ assertEquals(1, out.size());
}
}
<url>${sitedeploy}</url>
</site>
</distributionManagement>
- <groupId>org.opendaylight.controller</groupId>
<artifactId>networkconfig.neutron.implementation</artifactId>
<version>0.4.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<url>${sitedeploy}</url>
</site>
</distributionManagement>
- <groupId>org.opendaylight.controller</groupId>
<artifactId>networkconfig.neutron</artifactId>
<version>0.4.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<tag>HEAD</tag>
</scm>
- <groupId>org.opendaylight.controller</groupId>
<artifactId>containermanager.northbound</artifactId>
<version>0.4.2-SNAPSHOT</version>
<packaging>bundle</packaging>
<tag>HEAD</tag>
</scm>
- <groupId>org.opendaylight.controller</groupId>
<artifactId>northbound.integrationtest</artifactId>
<version>0.4.2-SNAPSHOT</version>
<pluginRepositories>
<url>${sitedeploy}</url>
</site>
</distributionManagement>
- <groupId>org.opendaylight.controller</groupId>
<artifactId>networkconfig.neutron.northbound</artifactId>
<version>0.4.2-SNAPSHOT</version>
<packaging>bundle</packaging>
@Path("/ports")
public class NeutronPortsNorthbound {
+ final String mac_regex="^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$";
+
private NeutronPort extractFields(NeutronPort o, List<String> fields) {
return o.extractFields(fields);
}
return Response.status(404).build();
}
if (singleton.getMacAddress() == null ||
- !singleton.getMacAddress().matches("^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$")) {
+ !singleton.getMacAddress().matches(mac_regex)) {
return Response.status(400).build();
}
if (portInterface.macInUse(singleton.getMacAddress())) {
if (!networkInterface.networkExists(test.getNetworkUUID())) {
return Response.status(404).build();
}
- if (!test.getMacAddress().matches("^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$")) {
+ if (!test.getMacAddress().matches(mac_regex)) {
return Response.status(400).build();
}
if (portInterface.macInUse(test.getMacAddress())) {
* {@link org.opendaylight.controller.sal.core.Property} attached to
* it.
*
- * <pre>
+ * <pre>
*
* Example:
*
* Type of the node connector being programmed (Eg. 'OF')
* @param nodeConnectorId
* NodeConnector Identifier as specified by
- * {@link org.opendaylight.controller.sal.core.NodeConnector}
- * (Eg. '2')
+ * {@link org.opendaylight.controller.sal.core.NodeConnector}.
+ * (Eg. '2'). If nodeConnecterId contains forward slash(/),
+ * replace forward slash with underscore(_) in the URL. (Eg. for
+ * Ethernet1/2, use Ethernet1_2)
* @param propertyName
* Name of the Property specified by
* {@link org.opendaylight.controller.sal.core.Property} and its
* extended classes
* @return Response as dictated by the HTTP Response Status code
*
- * <pre>
+ * <pre>
*
* Example:
*
handleNodeAvailability(containerName, nodeType, nodeId);
Node node = Node.fromString(nodeType, nodeId);
+ if (nodeConnectorId.contains("_")) {
+ nodeConnectorId = nodeConnectorId.replace("_", "/");
+ }
+
handleNodeConnectorAvailability(containerName, node, nodeConnectorType, nodeConnectorId);
NodeConnector nc = NodeConnector.fromStringNoNode(nodeConnectorType, nodeConnectorId, node);
* @param nodeConnectorId
* NodeConnector Identifier as specified by
* {@link org.opendaylight.controller.sal.core.NodeConnector}
- * (Eg. '1')
+ * (Eg. '1'). If nodeConnecterId contains forward slash(/),
+ * replace forward slash with underscore(_) in the URL. (Eg. for
+ * Ethernet1/2, use Ethernet1_2)
* @param propertyName
* Name of the Property specified by
* {@link org.opendaylight.controller.sal.core.Property} and its
* extended classes. Property that can be deleted is bandwidth
* @return Response as dictated by the HTTP Response Status code
*
- * <pre>
+ * <pre>
*
* Example:
*
handleNodeAvailability(containerName, nodeType, nodeId);
Node node = Node.fromString(nodeType, nodeId);
+ if (nodeConnectorId.contains("_")) {
+ nodeConnectorId = nodeConnectorId.replace("_", "/");
+ }
+
handleNodeConnectorAvailability(containerName, node, nodeConnectorType, nodeConnectorId);
NodeConnector nc = NodeConnector.fromStringNoNode(nodeConnectorType, nodeConnectorId, node);
Status ret = switchManager.removeNodeConnectorProp(nc, propertyName);
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* @return the int variable containing the unsigned byte value
*/
public static int getUnsignedByte(byte b) {
- return (b > 0) ? (int) b : (b & 0x7F | 0x80);
+ return b & 0xFF;
}
/**
* @return the int variable containing the unsigned short value
*/
public static int getUnsignedShort(short s) {
- return (s > 0) ? (int) s : (s & 0x7FFF | 0x8000);
+ return s & 0xFFFF;
}
/**
public static byte[] getBroadcastMACAddr() {
return Arrays.copyOf(BroadcastMACAddr, BroadcastMACAddr.length);
}
-
}
-
/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2013-2014 Cisco Systems, Inc. and others. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
Assert.assertTrue(NetUtils
.isIPAddressValid("2001:420:281:1004:407a:57f4:4d15:c355"));
}
+
+ @Test
+ public void testGetUnsignedByte() {
+ Assert.assertEquals(0, NetUtils.getUnsignedByte((byte) 0x00));
+ Assert.assertEquals(1, NetUtils.getUnsignedByte((byte) 0x01));
+ Assert.assertEquals(127, NetUtils.getUnsignedByte((byte) 0x7f));
+
+ Assert.assertEquals(128, NetUtils.getUnsignedByte((byte) 0x80));
+ Assert.assertEquals(255, NetUtils.getUnsignedByte((byte) 0xff));
+ }
+
+ @Test
+ public void testGetUnsignedShort() {
+ Assert.assertEquals(0, NetUtils.getUnsignedShort((short) 0x0000));
+ Assert.assertEquals(1, NetUtils.getUnsignedShort((short) 0x0001));
+ Assert.assertEquals(32767, NetUtils.getUnsignedShort((short) 0x7fff));
+
+ Assert.assertEquals(32768, NetUtils.getUnsignedShort((short) 0x8000));
+ Assert.assertEquals(65535, NetUtils.getUnsignedShort((short) 0xffff));
+ }
}