</instructions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
</plugins>
</build>
</project>
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.changed.by.parms.changed.by.server.or.user.ServerBuilder;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
private static final InstanceIdentifier<Capabilities> CAPABILITIES_INSTANCE_IDENTIFIER =
InstanceIdentifier.create(NetconfState.class).child(Capabilities.class);
+ private static final Logger LOG = LoggerFactory.getLogger(CapabilityChangeNotificationProducer.class);
private final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
private final ListenerRegistration capabilityChangeListenerRegistration;
case WRITE: {
final Capabilities dataAfter = rootNode.getDataAfter();
final Capabilities dataBefore = rootNode.getDataBefore();
- final Set<Uri> before = dataBefore != null ? ImmutableSet.copyOf(dataBefore.getCapability()) : Collections.emptySet();
- final Set<Uri> after = dataAfter != null ? ImmutableSet.copyOf(dataAfter.getCapability()) : Collections.emptySet();
+ final Set<Uri> before = dataBefore != null ? ImmutableSet.copyOf(dataBefore.getCapability()) :
+ Collections.emptySet();
+ final Set<Uri> after = dataAfter != null ? ImmutableSet.copyOf(dataAfter.getCapability()) :
+ Collections.emptySet();
final Set<Uri> added = Sets.difference(after, before);
final Set<Uri> removed = Sets.difference(before, after);
publishNotification(added, removed);
}
break;
}
+ default:
+ LOG.debug("Received intentionally unhandled type: {}.", modificationType);
}
}
private void publishNotification(Set<Uri> added, Set<Uri> removed) {
final NetconfCapabilityChangeBuilder netconfCapabilityChangeBuilder = new NetconfCapabilityChangeBuilder();
- netconfCapabilityChangeBuilder.setChangedBy(new ChangedByBuilder().setServerOrUser(new ServerBuilder().setServer(true).build()).build());
+ netconfCapabilityChangeBuilder.setChangedBy(new ChangedByBuilder().setServerOrUser(new ServerBuilder()
+ .setServer(true).build()).build());
netconfCapabilityChangeBuilder.setAddedCapability(ImmutableList.copyOf(added));
netconfCapabilityChangeBuilder.setDeletedCapability(ImmutableList.copyOf(removed));
// TODO modified should be computed ... but why ?
}
/**
- * Invoke by blueprint
+ * Invoked by blueprint.
*/
public void close() {
if (baseNotificationPublisherRegistration != null) {
* Listens on changes in netconf notification stream availability and writes
* changes to the data store.
*/
-public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificationCollector.NetconfNotificationStreamListener {
+public final class NotificationToMdsalWriter implements AutoCloseable, NetconfNotificationCollector
+ .NetconfNotificationStreamListener {
private static final Logger LOG = LoggerFactory.getLogger(NotificationToMdsalWriter.class);
Futures.addCallback(submit, new FutureCallback<Void>() {
@Override
- public void onSuccess(Void aVoid) {
+ public void onSuccess(Void avoid) {
LOG.debug("Streams cleared successfully");
}
}
/**
- * Invoke by blueprint
+ * Invoked by blueprint.
*/
public void start() {
notificationRegistration = netconfNotificationCollector.registerStreamListener(this);
public void onStreamRegistered(Stream stream) {
final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class).child(Streams.class).
- builder().child(Stream.class, stream.getKey()).build();
+ final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class).child(Streams.class)
+ .builder().child(Stream.class, stream.getKey()).build();
tx.merge(LogicalDatastoreType.OPERATIONAL, streamIdentifier, stream, true);
try {
final WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
final StreamKey streamKey = new StreamKey(stream);
- final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class).child(Streams.class).
- builder().child(Stream.class, streamKey).build();
+ final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class).child(Streams.class)
+ .builder().child(Stream.class, streamKey).build();
tx.delete(LogicalDatastoreType.OPERATIONAL, streamIdentifier);
/**
* Abstract base class for subclasses, which want to listen for changes on specified subtree in operational datastore.
+ *
* @param <T> data object class
*/
abstract class OperationalDatastoreListener<T extends DataObject> implements DataTreeChangeListener<T> {
private final InstanceIdentifier<T> instanceIdentifier;
/**
- * @param instanceIdentifier instance identifier of subtree, on which this instance should listen on changes
+ * Constructor.
+ *
+ * @param instanceIdentifier instance identifier of subtree, on which this instance should listen on changes.
*/
OperationalDatastoreListener(InstanceIdentifier<T> instanceIdentifier) {
this.instanceIdentifier = instanceIdentifier;
}
/**
- * Registers this instance as OPERATIONAL datastore listener via provided dataBroker
+ * Registers this instance as OPERATIONAL datastore listener via provided dataBroker.
+ *
* @param dataBroker data broker
* @return listener registration
*/
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
- * Listens on changes in NetconfState/Sessions/Session datastore and publishes them
+ * Listens on changes in NetconfState/Sessions/Session datastore and publishes them.
*/
public class SessionNotificationProducer extends OperationalDatastoreListener<Session> {
private static final InstanceIdentifier<Session> SESSION_INSTANCE_IDENTIFIER =
InstanceIdentifier.create(NetconfState.class).child(Sessions.class).child(Session.class);
+ private static final Logger LOG = LoggerFactory.getLogger(SessionNotificationProducer.class);
+
private final BaseNotificationPublisherRegistration baseNotificationPublisherRegistration;
private final ListenerRegistration sessionListenerRegistration;
this.sessionListenerRegistration = registerOnChanges(dataBroker);
}
+ @SuppressWarnings("checkstyle:MissingSwitchDefault")
@Override
public void onDataTreeChanged(@Nonnull Collection<DataTreeModification<Session>> changes) {
for (DataTreeModification<Session> change : changes) {
publishEndedSession(removed);
}
break;
+ default:
+ LOG.debug("Received intentionally unhandled type: {}.", modificationType);
}
}
}
/**
- * Invoke by blueprint
+ * Invoked by blueprint.
*/
public void close() {
if (baseNotificationPublisherRegistration != null) {
public class NetconfNotificationOperationService implements NetconfOperationService {
private final Set<NetconfOperation> netconfOperations;
- public NetconfNotificationOperationService(String netconfSessionIdForReporting, NetconfNotificationRegistry netconfNotificationRegistry) {
- this.netconfOperations = Collections.singleton(new CreateSubscription(netconfSessionIdForReporting, netconfNotificationRegistry));
+ public NetconfNotificationOperationService(String netconfSessionIdForReporting, NetconfNotificationRegistry
+ netconfNotificationRegistry) {
+ this.netconfOperations = Collections.singleton(new CreateSubscription(netconfSessionIdForReporting,
+ netconfNotificationRegistry));
}
return netconfOperations;
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public void close() {
for (NetconfOperation netconfOperation : netconfOperations) {
private final NetconfNotificationRegistry netconfNotificationRegistry;
private final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener;
- public NetconfNotificationOperationServiceFactory(final NetconfNotificationRegistry netconfNotificationRegistry,
- final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener) {
+ public NetconfNotificationOperationServiceFactory(
+ final NetconfNotificationRegistry netconfNotificationRegistry,
+ final NetconfOperationServiceFactoryListener netconfOperationServiceFactoryListener) {
this.netconfNotificationRegistry = netconfNotificationRegistry;
this.netconfOperationServiceFactoryListener = netconfOperationServiceFactoryListener;
@Override
public Set<Capability> getCapabilities() {
// TODO
- // No capabilities exposed to prevent clashes with schemas from config-netconf-connector (it exposes all the schemas)
- // If the schemas exposed by config-netconf-connector are filtered, this class would expose monitoring related models
+ // No capabilities exposed to prevent clashes with schemas from
+ // config-netconf-connector (it exposes all the schemas)
+ // If the schemas exposed by config-netconf-connector are filtered,
+ // this class would expose monitoring related models
return Collections.emptySet();
}
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class));
+ doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class),
+ any(DataTreeChangeListener.class));
doNothing().when(baseNotificationPublisherRegistration).onCapabilityChanged(any(NetconfCapabilityChange.class));
- doReturn(baseNotificationPublisherRegistration).when(netconfNotificationCollector).registerBaseNotificationPublisher();
+ doReturn(baseNotificationPublisherRegistration).when(netconfNotificationCollector)
+ .registerBaseNotificationPublisher();
- capabilityChangeNotificationProducer = new CapabilityChangeNotificationProducer(netconfNotificationCollector, dataBroker);
+ capabilityChangeNotificationProducer = new CapabilityChangeNotificationProducer(netconfNotificationCollector,
+ dataBroker);
}
@Test
public void testOnDataChangedCreate() {
- final InstanceIdentifier capabilitiesIdentifier = InstanceIdentifier.create(NetconfState.class).child(Capabilities.class).builder().build();
- final List<Uri> newCapabilitiesList = Lists.newArrayList(new Uri("newCapability"), new Uri("createdCapability"));
+ final InstanceIdentifier capabilitiesIdentifier =
+ InstanceIdentifier.create(NetconfState.class).child(Capabilities.class).builder().build();
+ final List<Uri> newCapabilitiesList =
+ Lists.newArrayList(new Uri("newCapability"), new Uri("createdCapability"));
Capabilities newCapabilities = new CapabilitiesBuilder().setCapability(newCapabilitiesList).build();
Map<InstanceIdentifier<?>, DataObject> createdData = Maps.newHashMap();
createdData.put(capabilitiesIdentifier, newCapabilities);
@Test
public void testOnDataChangedUpdate() {
- final List<Uri> originalCapabilitiesList = Lists.newArrayList(new Uri("originalCapability"), new Uri("anotherOriginalCapability"));
- final List<Uri> updatedCapabilitiesList = Lists.newArrayList(new Uri("originalCapability"), new Uri("newCapability"));
+ final List<Uri> originalCapabilitiesList =
+ Lists.newArrayList(new Uri("originalCapability"), new Uri("anotherOriginalCapability"));
+ final List<Uri> updatedCapabilitiesList =
+ Lists.newArrayList(new Uri("originalCapability"), new Uri("newCapability"));
Capabilities originalCapabilities = new CapabilitiesBuilder().setCapability(originalCapabilitiesList).build();
Capabilities updatedCapabilities = new CapabilitiesBuilder().setCapability(updatedCapabilitiesList).build();
- verifyDataTreeChange(DataObjectModification.ModificationType.WRITE, originalCapabilities, updatedCapabilities, changedCapabilitesFrom(
- Lists.newArrayList(new Uri("newCapability")), Lists.newArrayList(new Uri("anotherOriginalCapability"))));
+ verifyDataTreeChange(DataObjectModification.ModificationType.WRITE, originalCapabilities,
+ updatedCapabilities, changedCapabilitesFrom(
+ Lists.newArrayList(new Uri("newCapability")), Lists.newArrayList(new Uri("anotherOriginalCapability")
+ )));
}
@Test
doReturn(dataBroker).when(session).getSALService(DataBroker.class);
WriteTransaction tx = mock(WriteTransaction.class);
- doNothing().when(tx).merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class)
- , any(DataObject.class), anyBoolean());
+ doNothing().when(tx).merge(any(LogicalDatastoreType.class), any(InstanceIdentifier.class),
+ any(DataObject.class), anyBoolean());
doNothing().when(tx).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
doReturn(Futures.immediateCheckedFuture(null)).when(tx).submit();
doReturn(tx).when(dataBroker).newWriteOnlyTransaction();
writer.onStreamRegistered(testStream);
- verify(dataBroker.newWriteOnlyTransaction()).merge(LogicalDatastoreType.OPERATIONAL, streamIdentifier, testStream, true);
+ verify(dataBroker.newWriteOnlyTransaction()).merge(LogicalDatastoreType.OPERATIONAL, streamIdentifier,
+ testStream, true);
writer.onStreamUnregistered(testStreamName);
}
@Test
- public void testClose(){
+ public void testClose() {
doNothing().when(notificationRegistration).close();
final InstanceIdentifier streamIdentifier = InstanceIdentifier.create(Netconf.class);
}
@Test
- public void testDataStoreListener(){
+ public void testDataStoreListener() {
final InstanceIdentifier<DataObject> instanceIdentifier = InstanceIdentifier.create(DataObject.class);
final DataTreeIdentifier<DataObject> testId =
new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
- final OperationalDatastoreListener<DataObject> op = new OperationalDatastoreListener<DataObject>(instanceIdentifier) {
+ final OperationalDatastoreListener<DataObject> op =
+ new OperationalDatastoreListener<DataObject>(instanceIdentifier) {
@Override
public void onDataTreeChanged(@Nonnull Collection collection) {
}
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.ZeroBasedCounter32;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SessionNotificationProducerTest {
+ private static final Logger LOG = LoggerFactory.getLogger(SessionNotificationProducerTest.class);
+
private SessionNotificationProducer publisher;
@Mock
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
- doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class), any(DataTreeChangeListener.class));
+ doReturn(listenerRegistration).when(dataBroker).registerDataTreeChangeListener(any(DataTreeIdentifier.class),
+ any(DataTreeChangeListener.class));
doNothing().when(registration).onCapabilityChanged(any(NetconfCapabilityChange.class));
doNothing().when(registration).onSessionStarted(any());
@Test
public void testOnDataChangedSessionCreated() throws Exception {
final Session session = createSession(1);
- final DataTreeModification<Session> treeChange = getTreeModification(session, DataObjectModification.ModificationType.WRITE);
+ final DataTreeModification<Session> treeChange = getTreeModification(session, DataObjectModification
+ .ModificationType.WRITE);
publisher.onDataTreeChanged(Collections.singleton(treeChange));
ArgumentCaptor<NetconfSessionStart> captor = ArgumentCaptor.forClass(NetconfSessionStart.class);
verify(registration).onSessionStarted(captor.capture());
@Test
public void testOnDataChangedSessionDeleted() throws Exception {
final Session session = createSession(1);
- final DataTreeModification<Session> data = getTreeModification(session, DataObjectModification.ModificationType.DELETE);
+ final DataTreeModification<Session> data = getTreeModification(session, DataObjectModification
+ .ModificationType.DELETE);
publisher.onDataTreeChanged(Collections.singleton(data));
ArgumentCaptor<NetconfSessionEnd> captor = ArgumentCaptor.forClass(NetconfSessionEnd.class);
verify(registration).onSessionEnded(captor.capture());
}
@SuppressWarnings("unchecked")
- private DataTreeModification<Session> getTreeModification(Session session, DataObjectModification.ModificationType type) {
+ private DataTreeModification<Session> getTreeModification(Session session, DataObjectModification
+ .ModificationType type) {
final DataTreeModification<Session> treeChange = mock(DataTreeModification.class);
final DataObjectModification<Session> changeObject = mock(DataObjectModification.class);
switch (type) {
case DELETE:
doReturn(session).when(changeObject).getDataBefore();
break;
+ default:
+ LOG.debug("Received intentionally unhandled type: {}.", type);
}
doReturn(type).when(changeObject).getModificationType();
doReturn(changeObject).when(treeChange).getRootNode();