*/
package org.opendaylight.controller.md.sal.binding.compat;
+import com.google.common.base.Preconditions;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.yang.binding.Notification;
-import com.google.common.base.Preconditions;
-
/**
* Abstract implementation of {@link NotificationListenerRegistration}.
*
* @param <T> Notification type
*/
-abstract class AbstractNotificationListenerRegistration<T extends Notification> extends AbstractListenerRegistration<NotificationListener<T>> implements NotificationListenerRegistration<T> {
+abstract class AbstractNotificationListenerRegistration<T extends Notification>
+ extends AbstractListenerRegistration<NotificationListener<T>> implements NotificationListenerRegistration<T> {
private final Class<? extends Notification> type;
- protected AbstractNotificationListenerRegistration(final Class<? extends Notification> type, final NotificationListener<T> listener) {
+ protected AbstractNotificationListenerRegistration(final Class<? extends Notification> type,
+ final NotificationListener<T> listener) {
super(listener);
this.type = Preconditions.checkNotNull(type);
}
* interfaces at the same time. In order to support correct delivery, we need to maintain per-type registrations
* which get squashed if a notification which implements multiple interfaces is encountered.
*
+ * <p>
* We take care of that by implementing alternate {@link #hashCode()}/{@link #equals(Object)}, which resolve
* to the backing aggregator.
*
* @param <N> Notification type
* @param <A> Aggregator type
*/
-abstract class AggregatedNotificationListenerRegistration<N extends Notification, A> extends AbstractNotificationListenerRegistration<N> {
+abstract class AggregatedNotificationListenerRegistration<N extends Notification, A>
+ extends AbstractNotificationListenerRegistration<N> {
private final A aggregator;
- protected AggregatedNotificationListenerRegistration(final Class<? extends Notification> type, final NotificationListener<N> listener, final A aggregator) {
+ protected AggregatedNotificationListenerRegistration(final Class<? extends Notification> type,
+ final NotificationListener<N> listener, final A aggregator) {
super(type, listener);
this.aggregator = Preconditions.checkNotNull(aggregator);
}
*/
package org.opendaylight.controller.md.sal.binding.compat;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableSet;
import java.util.HashMap;
import java.util.Map;
private final BindingDOMRpcProviderServiceAdapter adapter;
private final Map<InstanceIdentifier<?>, ObjectRegistration<T>> registrations = new HashMap<>(2);
- CompositeRoutedRpcRegistration(final Class<T> type, final T impl, final BindingDOMRpcProviderServiceAdapter providerAdapter) {
+ CompositeRoutedRpcRegistration(final Class<T> type, final T impl,
+ final BindingDOMRpcProviderServiceAdapter providerAdapter) {
this.type = type;
this.instance = impl;
this.adapter = providerAdapter;
}
@Override
- public synchronized void registerPath(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
- if(!registrations.containsKey(path)) {
- registrations.put(path, adapter.registerRpcImplementation(type, instance, ImmutableSet.<InstanceIdentifier<?>>of(path)));
+ public synchronized void registerPath(final Class<? extends BaseIdentity> context,
+ final InstanceIdentifier<?> path) {
+ if (!registrations.containsKey(path)) {
+ registrations.put(path,
+ adapter.registerRpcImplementation(type, instance, ImmutableSet.<InstanceIdentifier<?>>of(path)));
}
}
}
@Override
- public synchronized void unregisterPath(final Class<? extends BaseIdentity> context, final InstanceIdentifier<?> path) {
+ public synchronized void unregisterPath(final Class<? extends BaseIdentity> context,
+ final InstanceIdentifier<?> path) {
final ObjectRegistration<T> reg = registrations.remove(path);
- if(reg != null) {
- try {
- reg.close();
- } catch (final Exception e) {
- // FIXME: Once we have proper subclass of ObjectRegistrationo
- throw Throwables.propagate(e);
- }
+ if (reg != null) {
+ reg.close();
}
}
@Override
public synchronized void close() {
- try {
- for(final ObjectRegistration<T> reg : registrations.values()) {
- reg.close();
- }
- } catch (final Exception e) {
- throw Throwables.propagate(e);
+ for (final ObjectRegistration<T> reg : registrations.values()) {
+ reg.close();
}
}
-
}
*/
package org.opendaylight.controller.md.sal.binding.compat;
-import com.google.common.base.Throwables;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.RpcService;
private final ObjectRegistration<T> delegate;
private final Class<T> type;
- public DelegatedRootRpcRegistration(final Class<T> type,final ObjectRegistration<T> impl) {
+ DelegatedRootRpcRegistration(final Class<T> type, final ObjectRegistration<T> impl) {
this.delegate = impl;
this.type = type;
}
@Override
public void close() {
- try {
- // FIXME: Should use more specific registration object.
- delegate.close();
- } catch (final Exception e) {
- throw Throwables.propagate(e);
- }
+ delegate.close();
}
@Override
public Class<T> getServiceType() {
return type;
}
-
}
private final NotificationListener<N> delegate;
private final Class<N> type;
- public FunctionalNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final Class<N> type, final NotificationListener<N> delegate) {
+ FunctionalNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final Class<N> type,
+ final NotificationListener<N> delegate) {
this.codec = codec;
this.type = type;
this.delegate = delegate;
@Override
public void onNotification(@Nonnull final DOMNotification notification) {
- delegate.onNotification( type.cast(deserialize(notification)));
+ delegate.onNotification(type.cast(deserialize(notification)));
}
private Notification deserialize(final DOMNotification notification) {
- if(notification instanceof LazySerializedDOMNotification) {
+ if (notification instanceof LazySerializedDOMNotification) {
return ((LazySerializedDOMNotification) notification).getBindingData();
}
return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class HeliumNotificationProviderServiceAdapter extends HeliumNotificationServiceAdapter implements NotificationProviderService, AutoCloseable {
+public class HeliumNotificationProviderServiceAdapter extends HeliumNotificationServiceAdapter
+ implements NotificationProviderService, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(HeliumNotificationProviderServiceAdapter.class);
private final NotificationPublishService notificationPublishService;
@Override
public void close() throws Exception {
-
}
-
}
public class HeliumNotificationProviderServiceWithInterestListeners extends HeliumNotificationProviderServiceAdapter {
- private static final Logger LOG = LoggerFactory.getLogger(HeliumNotificationProviderServiceWithInterestListeners.class);
+ private static final Logger LOG = LoggerFactory.getLogger(
+ HeliumNotificationProviderServiceWithInterestListeners.class);
private final ListenerRegistry<NotificationInterestListener> interestListeners = ListenerRegistry.create();
private final ListenerRegistration<Listener> domListener;
private final BindingToNormalizedNodeCodec codec;
public HeliumNotificationProviderServiceWithInterestListeners(
- final BindingDOMNotificationPublishServiceAdapter publishService, final BindingDOMNotificationServiceAdapter listenService, final DOMNotificationSubscriptionListenerRegistry registry) {
+ final BindingDOMNotificationPublishServiceAdapter publishService,
+ final BindingDOMNotificationServiceAdapter listenService,
+ final DOMNotificationSubscriptionListenerRegistry registry) {
super(publishService, listenService);
this.codec = publishService.getCodecRegistry();
this.domListener = registry.registerSubscriptionListener(new Listener());
return codec.getNotificationClasses(added);
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void notifyAllListeners(final Set<SchemaPath> added) {
final Iterator<ListenerRegistration<NotificationInterestListener>> listeners = interestListeners.iterator();
- if(listeners.hasNext()) {
+ if (listeners.hasNext()) {
final Set<Class<? extends Notification>> baEvent = translate(added);
- while(listeners.hasNext()) {
+ while (listeners.hasNext()) {
final NotificationInterestListener listenerRef = listeners.next().getInstance();
try {
- notifyListener(listenerRef,baEvent);
- } catch (final Exception e) {
- LOG.warn("Unhandled exception during invoking listener {}",e, listenerRef);
+ notifyListener(listenerRef, baEvent);
+ } catch (RuntimeException e) {
+ LOG.warn("Unhandled exception during invoking listener {}", e, listenerRef);
}
}
}
public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(
final Class<T> type, final NotificationListener<T> listener) {
- final FunctionalNotificationListenerAdapter<T> adapter = new FunctionalNotificationListenerAdapter<>(codec, type, listener);
+ final FunctionalNotificationListenerAdapter<T> adapter =
+ new FunctionalNotificationListenerAdapter<>(codec, type, listener);
final SchemaPath domType = SchemaPath.create(true, BindingReflections.findQName(type));
final ListenerRegistration<?> domReg = domService.registerNotificationListener(adapter, domType);
return new AbstractListenerRegistration<NotificationListener<T>>(listener) {
protected void removeRegistration() {
domReg.close();
}
-
};
}
- private void notifyListener(final NotificationInterestListener listener, final Set<Class<? extends Notification>> baEvent) {
- for(final Class<? extends Notification> event: baEvent) {
+ private void notifyListener(final NotificationInterestListener listener,
+ final Set<Class<? extends Notification>> baEvent) {
+ for (final Class<? extends Notification> event: baEvent) {
listener.onNotificationSubscribtion(event);
}
}
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.binding.NotificationListener;
-public class HeliumNotificationServiceAdapter implements org.opendaylight.controller.sal.binding.api.NotificationService, AutoCloseable {
+public class HeliumNotificationServiceAdapter
+ implements org.opendaylight.controller.sal.binding.api.NotificationService, AutoCloseable {
private final NotificationService notificationService;
}
@Override
- public <T extends Notification> ListenerRegistration<org.opendaylight.controller.sal.binding.api.NotificationListener<T>> registerNotificationListener(
- final Class<T> notificationType, final org.opendaylight.controller.sal.binding.api.NotificationListener<T> listener) {
+ public <T extends Notification> ListenerRegistration<
+ org.opendaylight.controller.sal.binding.api.NotificationListener<T>> registerNotificationListener(
+ final Class<T> notificationType,
+ final org.opendaylight.controller.sal.binding.api.NotificationListener<T> listener) {
throw new UnsupportedOperationException("Not supported type of listener.");
}
@Override
public void close() throws Exception {
-
}
}
}
@Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
- final L arg0) {
+ public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
+ registerRouteChangeListener(final L listener) {
// FIXME: Implement this only if necessary
return null;
}
-
}
*/
package org.opendaylight.controller.md.sal.binding.compat;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import java.util.stream.Collectors;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.opendaylight.yangtools.yang.binding.Notification;
/**
* An immutable view of the current generation of listeners.
for (final Class<?> type : getNotificationTypes(key)) {
@SuppressWarnings("unchecked")
- final Collection<NotificationListenerRegistration<?>> l = typeToListeners.get((Class<? extends Notification>) type);
+ final Collection<NotificationListenerRegistration<?>> l =
+ typeToListeners.get((Class<? extends Notification>) type);
if (l != null) {
regs.addAll(l);
}
typeToListeners = ImmutableMultimap.of();
}
- ListenerMapGeneration(final Multimap<Class<? extends Notification>, NotificationListenerRegistration<?>> listeners) {
+ ListenerMapGeneration(final Multimap<Class<? extends Notification>,
+ NotificationListenerRegistration<?>> listeners) {
this.typeToListeners = ImmutableMultimap.copyOf(listeners);
}
.filter(input -> !Notification.class.equals(input) && Notification.class.isAssignableFrom(input))
.collect(Collectors.toList());
}
-}
\ No newline at end of file
+}
import org.opendaylight.yangtools.yang.binding.util.NotificationListenerInvoker;
import org.opendaylight.yangtools.yang.common.QName;
-final class NotificationInvoker implements org.opendaylight.controller.sal.binding.api.NotificationListener<Notification> {
+final class NotificationInvoker
+ implements org.opendaylight.controller.sal.binding.api.NotificationListener<Notification> {
private final NotificationListener delegate;
private final Map<Class<? extends Notification>,InvokerContext> invokers;
private NotificationInvoker(final NotificationListener listener) {
delegate = listener;
final Map<Class<? extends Notification>, InvokerContext> builder = new HashMap<>();
- for(final TypeToken<?> ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) {
+ for (final TypeToken<?> ifaceToken : TypeToken.of(listener.getClass()).getTypes().interfaces()) {
final Class<?> iface = ifaceToken.getRawType();
- if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
+ if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
@SuppressWarnings("unchecked")
- final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
+ final Class<? extends NotificationListener> listenerType =
+ (Class<? extends NotificationListener>) iface;
final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
- for(final Class<? extends Notification> type : getNotificationTypes(listenerType)) {
- builder.put(type, new InvokerContext(BindingReflections.findQName(type) , invoker));
+ for (final Class<? extends Notification> type : getNotificationTypes(listenerType)) {
+ builder.put(type, new InvokerContext(BindingReflections.findQName(type), invoker));
}
}
}
}
@SuppressWarnings("unchecked")
- private static Set<Class<? extends Notification>> getNotificationTypes(final Class<? extends org.opendaylight.yangtools.yang.binding.NotificationListener> type) {
+ private static Set<Class<? extends Notification>> getNotificationTypes(
+ final Class<? extends org.opendaylight.yangtools.yang.binding.NotificationListener> type) {
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<Class<? extends Notification>> ret = new HashSet<>();
- for(final Method method : type.getMethods()) {
- if(BindingReflections.isNotificationCallback(method)) {
- final Class<? extends Notification> notification = (Class<? extends Notification>) method.getParameterTypes()[0];
+ for (final Method method : type.getMethods()) {
+ if (BindingReflections.isNotificationCallback(method)) {
+ final Class<? extends Notification> notification =
+ (Class<? extends Notification>) method.getParameterTypes()[0];
ret.add(notification);
}
}
public void invoke(final Notification notification) {
invoker.invokeNotification(delegate, name, notification);
}
-
}
-
}
*
* @param <T> Type of notification
*/
-interface NotificationListenerRegistration<T extends Notification> extends ListenerRegistration<NotificationListener<T>> {
+interface NotificationListenerRegistration<T extends Notification>
+ extends ListenerRegistration<NotificationListener<T>> {
/**
* Return the interface class of the notification type.
*
}
public ListenerRegistration<DataChangeListener> registerDataChangeListener(final LogicalDatastoreType store,
- final InstanceIdentifier<?> path, final DataChangeListener listener, final DataChangeScope triggeringScope) {
+ final InstanceIdentifier<?> path, final DataChangeListener listener,
+ final DataChangeScope triggeringScope) {
final DOMDataChangeListener domDataChangeListener;
- if(listener instanceof ClusteredDataChangeListener) {
+ if (listener instanceof ClusteredDataChangeListener) {
domDataChangeListener = new TranslatingClusteredDataChangeInvoker(store, path, listener, triggeringScope);
} else {
domDataChangeListener = new TranslatingDataChangeInvoker(store, path, listener,
triggeringScope);
}
final YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(path);
- final ListenerRegistration<DOMDataChangeListener> domRegistration = domDataBroker.registerDataChangeListener(store,
- domPath, domDataChangeListener, triggeringScope);
+ final ListenerRegistration<DOMDataChangeListener> domRegistration =
+ domDataBroker.registerDataChangeListener(store, domPath, domDataChangeListener, triggeringScope);
return new ListenerRegistrationImpl(listener, domRegistration);
}
for (final Map.Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> entry : normalized.entrySet()) {
try {
- final Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential = getCodec().toBinding(entry);
+ final Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> potential =
+ getCodec().toBinding(entry);
if (potential.isPresent()) {
final Entry<InstanceIdentifier<? extends DataObject>, DataObject> binding = potential.get();
newMap.put(binding.getKey(), binding.getValue());
final Set<InstanceIdentifier<?>> hashSet = new HashSet<>();
for (final YangInstanceIdentifier normalizedPath : normalized) {
try {
- final Optional<InstanceIdentifier<? extends DataObject>> potential = getCodec().toBinding(normalizedPath);
+ final Optional<InstanceIdentifier<? extends DataObject>> potential =
+ getCodec().toBinding(normalizedPath);
if (potential.isPresent()) {
final InstanceIdentifier<? extends DataObject> binding = potential.get();
hashSet.add(binding);
- } else if (normalizedPath.getLastPathArgument() instanceof YangInstanceIdentifier.AugmentationIdentifier) {
+ } else if (normalizedPath.getLastPathArgument()
+ instanceof YangInstanceIdentifier.AugmentationIdentifier) {
hashSet.add(path);
}
} catch (final DeserializationException e) {
if (path.isWildcarded()) {
return Optional.absent();
}
- return (Optional<DataObject>) getCodec().deserializeFunction(path).apply(Optional.<NormalizedNode<?, ?>> of(data));
+ return (Optional<DataObject>) getCodec().deserializeFunction(path)
+ .apply(Optional.<NormalizedNode<?, ?>>of(data));
}
private class TranslatingDataChangeInvoker implements DOMDataChangeListener {
private final InstanceIdentifier<?> path;
private final DataChangeScope triggeringScope;
- public TranslatingDataChangeInvoker(final LogicalDatastoreType store, final InstanceIdentifier<?> path,
+ TranslatingDataChangeInvoker(final LogicalDatastoreType store, final InstanceIdentifier<?> path,
final DataChangeListener bindingDataChangeListener, final DataChangeScope triggeringScope) {
this.store = store;
this.path = path;
}
/**
- * Translator for ClusteredDataChangeListener
+ * Translator for ClusteredDataChangeListener.
*/
-
private class TranslatingClusteredDataChangeInvoker extends TranslatingDataChangeInvoker implements
ClusteredDOMDataChangeListener {
- public TranslatingClusteredDataChangeInvoker(final LogicalDatastoreType store, final InstanceIdentifier<?> path,
- final DataChangeListener bindingDataChangeListener,
- final DataChangeScope triggeringScope) {
+ TranslatingClusteredDataChangeInvoker(final LogicalDatastoreType store, final InstanceIdentifier<?> path,
+ final DataChangeListener bindingDataChangeListener, final DataChangeScope triggeringScope) {
super(store, path, bindingDataChangeListener, triggeringScope);
}
}
private Optional<DataObject> originalDataCache;
private Optional<DataObject> updatedDataCache;
- public TranslatedDataChangeEvent(
+ TranslatedDataChangeEvent(
final AsyncDataChangeEvent<YangInstanceIdentifier, NormalizedNode<?, ?>> change,
final InstanceIdentifier<?> path) {
this.domEvent = change;
private static class ListenerRegistrationImpl extends AbstractListenerRegistration<DataChangeListener> {
private final ListenerRegistration<DOMDataChangeListener> registration;
- public ListenerRegistrationImpl(final DataChangeListener listener,
+ ListenerRegistrationImpl(final DataChangeListener listener,
final ListenerRegistration<DOMDataChangeListener> registration) {
super(listener);
this.registration = registration;
@Override
public void close() {
}
-
}
private final T delegate;
private final BindingToNormalizedNodeCodec codec;
- public AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
+ AbstractForwardedTransaction(final T delegateTx, final BindingToNormalizedNodeCodec codec) {
this.delegate = Preconditions.checkNotNull(delegateTx, "Delegate must not be null");
this.codec = Preconditions.checkNotNull(codec, "Codec must not be null");
}
}
@SuppressWarnings("unchecked")
- protected final <S extends AsyncTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>>> S getDelegateChecked(final Class<S> txType) {
+ protected final <S extends AsyncTransaction<YangInstanceIdentifier, NormalizedNode<?, ?>>>
+ S getDelegateChecked(final Class<S> txType) {
Preconditions.checkState(txType.isInstance(delegate));
return (S) delegate;
}
*/
package org.opendaylight.controller.md.sal.binding.impl;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.impl.util.compat.DataNormalizationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
public class AbstractReadWriteTransaction extends AbstractWriteTransaction<DOMDataReadWriteTransaction> {
private static final Logger LOG = LoggerFactory.getLogger(AbstractReadWriteTransaction.class);
- public AbstractReadWriteTransaction(final DOMDataReadWriteTransaction delegate, final BindingToNormalizedNodeCodec codec) {
+ public AbstractReadWriteTransaction(final DOMDataReadWriteTransaction delegate,
+ final BindingToNormalizedNodeCodec codec) {
super(delegate, codec);
}
throw new IllegalArgumentException(String.format("Invalid child encountered in path %s", path), e);
}
currentArguments.add(currentArg);
- org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath = org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(
- currentArguments);
+ org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier currentPath =
+ org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.create(currentArguments);
final Boolean exists;
try {
}
}
}
-
-
}
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
- *
- * Abstract Base Transaction for transactions which are backed by
- * {@link DOMDataWriteTransaction}
+ * Abstract Base Transaction for transactions which are backed by {@link DOMDataWriteTransaction}.
*/
public abstract class AbstractWriteTransaction<T extends DOMDataWriteTransaction> extends
AbstractForwardedTransaction<T> {
}
/**
- *
* Ensures list parent if item is list, otherwise noop.
*
* <p>
* put("/nodes/node/node[key]",domNode);
* </pre>
*
- *
+ * <p>
* In order to allow that to be inserted if necessary, if we know
* item is list item, we will try to merge empty MapNode or OrderedNodeMap
* to ensure list exists.
}
/**
+ * Deprecated.
+ *
* @deprecated Use {@link YangInstanceIdentifier#getParent()} instead.
*/
@Deprecated
/**
* Subclasses of this class are required to implement creation of parent
* nodes based on behaviour of their underlying transaction.
- *
- * @param store
- * @param key
- * @param path
*/
protected abstract void ensureParentsByMerge(LogicalDatastoreType store,
YangInstanceIdentifier key, InstanceIdentifier<?> path);
protected final boolean doCancel() {
return getDelegate().cancel();
}
-
}
import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
public abstract class BindingDOMAdapterLoader extends AdapterLoader<BindingService, DOMService> {
-
-
- private static final Map<Class<?>,BindingDOMAdapterBuilder.Factory<?>> FACTORIES = ImmutableMap.<Class<?>,BindingDOMAdapterBuilder.Factory<?>>builder()
+ private static final Map<Class<?>,BindingDOMAdapterBuilder.Factory<?>> FACTORIES =
+ ImmutableMap.<Class<?>,BindingDOMAdapterBuilder.Factory<?>>builder()
.put(NotificationService.class,BindingDOMNotificationServiceAdapter.BUILDER_FACTORY)
.put(NotificationPublishService.class,BindingDOMNotificationPublishServiceAdapter.BUILDER_FACTORY)
.put(DataBroker.class,BindingDOMDataBrokerAdapter.BUILDER_FACTORY)
}
@Override
- protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(final Class<? extends BindingService> key) {
+ protected final AdapterBuilder<? extends BindingService, DOMService> createBuilder(
+ final Class<? extends BindingService> key) {
final Factory<?> factory = FACTORIES.get(key);
Preconditions.checkArgument(factory != null, "Unsupported service type %s", key);
final BindingDOMAdapterBuilder<?> builder = factory.newBuilder();
*/
package org.opendaylight.controller.md.sal.binding.impl;
-
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
* All transactions and listener registrations are wrapped by the DataBrokerImpl
* to allow binding aware components to use the DataBroker transparently.
*
+ * <p>
* Besides this the DataBrokerImpl and it's collaborators also cache data that
* is already transformed from the binding independent to binding aware format
- *
-
*/
-public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker implements DataBroker, DataTreeChangeService {
-
-
+public class BindingDOMDataBrokerAdapter extends AbstractForwardedDataBroker
+ implements DataBroker, DataTreeChangeService {
static final Factory<DataBroker> BUILDER_FACTORY = Builder::new;
private final DataTreeChangeService treeChangeService;
public BindingDOMDataBrokerAdapter(final DOMDataBroker domDataBroker, final BindingToNormalizedNodeCodec codec) {
super(domDataBroker, codec);
- final DOMDataTreeChangeService domTreeChange = (DOMDataTreeChangeService) domDataBroker.getSupportedExtensions().get(DOMDataTreeChangeService.class);
- if(domTreeChange != null) {
+ final DOMDataTreeChangeService domTreeChange = (DOMDataTreeChangeService) domDataBroker
+ .getSupportedExtensions().get(DOMDataTreeChangeService.class);
+ if (domTreeChange != null) {
treeChangeService = BindingDOMDataTreeChangeServiceAdapter.create(codec, domTreeChange);
} else {
treeChangeService = null;
}
@Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener(
- final DataTreeIdentifier<T> treeId, final L listener) {
- if(treeChangeService == null) {
+ public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L>
+ registerDataTreeChangeListener(final DataTreeIdentifier<T> treeId, final L listener) {
+ if (treeChangeService == null) {
throw new UnsupportedOperationException("Underlying data broker does not expose DOMDataTreeChangeService.");
}
return treeChangeService.registerDataTreeChangeListener(treeId, listener);
}
-
}
private final DataTreeChangeListener<T> listener;
private final LogicalDatastoreType store;
- BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec, final DataTreeChangeListener<T> listener,
- final LogicalDatastoreType store) {
+ BindingDOMDataTreeChangeListenerAdapter(final BindingToNormalizedNodeCodec codec,
+ final DataTreeChangeListener<T> listener, final LogicalDatastoreType store) {
this.codec = Preconditions.checkNotNull(codec);
this.listener = Preconditions.checkNotNull(listener);
this.store = Preconditions.checkNotNull(store);
@Override
public void onDataTreeChanged(final Collection<DataTreeCandidate> domChanges) {
- final Collection<DataTreeModification<T>> bindingChanges = LazyDataTreeModification.from(codec, domChanges, store);
+ final Collection<DataTreeModification<T>> bindingChanges =
+ LazyDataTreeModification.from(codec, domChanges, store);
listener.onDataTreeChanged(bindingChanges);
}
/**
- *
* Adapter exposing Binding {@link DataTreeChangeService} and wrapping
* {@link DOMDataTreeChangeService} and is responsible for translation
* and instantiation of {@link BindingDOMDataTreeChangeListenerAdapter}
* adapters.
*
+ * <p>
* Each registered {@link DataTreeChangeListener} is wrapped using
* adapter and registered directly to DOM service.
*/
}
@Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L> registerDataTreeChangeListener(
- final DataTreeIdentifier<T> treeId, final L listener) {
+ public <T extends DataObject, L extends DataTreeChangeListener<T>> ListenerRegistration<L>
+ registerDataTreeChangeListener(final DataTreeIdentifier<T> treeId, final L listener) {
final DOMDataTreeIdentifier domIdentifier = toDomTreeIdentifier(treeId);
@SuppressWarnings({ "rawtypes", "unchecked" })
final BindingDOMDataTreeChangeListenerAdapter<T> domListener =
- listener instanceof ClusteredDataTreeChangeListener ?
- new BindingClusteredDOMDataTreeChangeListenerAdapter<>(
- codec, (ClusteredDataTreeChangeListener) listener, treeId.getDatastoreType()) :
- new BindingDOMDataTreeChangeListenerAdapter<>(codec, listener, treeId.getDatastoreType());
+ listener instanceof ClusteredDataTreeChangeListener
+ ? new BindingClusteredDOMDataTreeChangeListenerAdapter<>(
+ codec, (ClusteredDataTreeChangeListener) listener, treeId.getDatastoreType())
+ : new BindingDOMDataTreeChangeListenerAdapter<>(codec, listener, treeId.getDatastoreType());
final ListenerRegistration<BindingDOMDataTreeChangeListenerAdapter<T>> domReg =
dataTreeChangeService.registerDataTreeChangeListener(domIdentifier, domListener);
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.impl.codec.DeserializationException;
-final class BindingDOMMountPointListenerAdapter<T extends MountPointListener> implements ListenerRegistration<T>, MountProvisionListener {
+final class BindingDOMMountPointListenerAdapter<T extends MountPointListener>
+ implements ListenerRegistration<T>, MountProvisionListener {
private final T listener;
private final ListenerRegistration<MountProvisionListener> registration;
private final BindingToNormalizedNodeCodec codec;
- public BindingDOMMountPointListenerAdapter(final T listener, final BindingToNormalizedNodeCodec codec, final DOMMountPointService mountService) {
+ BindingDOMMountPointListenerAdapter(final T listener, final BindingToNormalizedNodeCodec codec,
+ final DOMMountPointService mountService) {
this.listener = listener;
this.codec = codec;
this.registration = mountService.registerProvisionListener(this);
final InstanceIdentifier<? extends DataObject> bindingPath = toBinding(path);
listener.onMountPointCreated(bindingPath);
} catch (final DeserializationException e) {
- BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Omitting event.",path,e);
+ BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Omitting event.",
+ path, e);
}
}
- private InstanceIdentifier<? extends DataObject> toBinding(final YangInstanceIdentifier path) throws DeserializationException {
+ private InstanceIdentifier<? extends DataObject> toBinding(final YangInstanceIdentifier path)
+ throws DeserializationException {
final Optional<InstanceIdentifier<? extends DataObject>> instanceIdentifierOptional = codec.toBinding(path);
- if(instanceIdentifierOptional.isPresent()) {
+ if (instanceIdentifierOptional.isPresent()) {
return instanceIdentifierOptional.get();
} else {
throw new DeserializationException("Deserialization unsuccessful, " + instanceIdentifierOptional);
final InstanceIdentifier<? extends DataObject> bindingPath = toBinding(path);
listener.onMountPointRemoved(bindingPath);
} catch (final DeserializationException e) {
- BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Omitting event.",path,e);
+ BindingDOMMountPointServiceAdapter.LOG.error("Unable to translate mountPoint path {}. Omitting event.",
+ path, e);
}
}
-}
\ No newline at end of file
+}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
public class BindingDOMMountPointServiceAdapter implements MountPointService {
-
public static final Logger LOG = LoggerFactory.getLogger(BindingDOMMountPointServiceAdapter.class);
private final BindingToNormalizedNodeCodec codec;
YangInstanceIdentifier domPath = codec.toYangInstanceIdentifierBlocking(mountPoint);
Optional<DOMMountPoint> domMount = mountService.getMountPoint(domPath);
- if(domMount.isPresent()) {
+ if (domMount.isPresent()) {
return Optional.<MountPoint>fromNullable(bindingMountpoints.getUnchecked(domMount.get()));
}
return Optional.absent();
T listener) {
return new BindingDOMMountPointListenerAdapter<>(listener, codec, mountService);
}
-
}
private final NotificationListener delegate;
private final Map<SchemaPath,NotificationListenerInvoker> invokers;
- public BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec, final NotificationListener delegate) {
+ BindingDOMNotificationListenerAdapter(final BindingNormalizedNodeSerializer codec,
+ final NotificationListener delegate) {
this.codec = codec;
this.delegate = delegate;
this.invokers = createInvokerMapFor(delegate.getClass());
}
private Notification deserialize(final DOMNotification notification) {
- if(notification instanceof LazySerializedDOMNotification) {
+ if (notification instanceof LazySerializedDOMNotification) {
return ((LazySerializedDOMNotification) notification).getBindingData();
}
return codec.fromNormalizedNodeNotification(notification.getType(), notification.getBody());
return invokers.keySet();
}
- public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(final Class<? extends NotificationListener> implClz) {
+ public static Map<SchemaPath, NotificationListenerInvoker> createInvokerMapFor(
+ final Class<? extends NotificationListener> implClz) {
final Map<SchemaPath, NotificationListenerInvoker> builder = new HashMap<>();
- for(final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
+ for (final TypeToken<?> ifaceToken : TypeToken.of(implClz).getTypes().interfaces()) {
Class<?> iface = ifaceToken.getRawType();
- if(NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
+ if (NotificationListener.class.isAssignableFrom(iface) && BindingReflections.isBindingClass(iface)) {
@SuppressWarnings("unchecked")
- final Class<? extends NotificationListener> listenerType = (Class<? extends NotificationListener>) iface;
+ final Class<? extends NotificationListener> listenerType =
+ (Class<? extends NotificationListener>) iface;
final NotificationListenerInvoker invoker = NotificationListenerInvoker.from(listenerType);
- for(final SchemaPath path : getNotificationTypes(listenerType)) {
+ for (final SchemaPath path : getNotificationTypes(listenerType)) {
builder.put(path, invoker);
}
}
// TODO: Investigate possibility and performance impact if we cache this or expose
// it from NotificationListenerInvoker
final Set<SchemaPath> ret = new HashSet<>();
- for(final Method method : type.getMethods()) {
- if(BindingReflections.isNotificationCallback(method)) {
+ for (final Method method : type.getMethods()) {
+ if (BindingReflections.isNotificationCallback(method)) {
final Class<?> notification = method.getParameterTypes()[0];
final QName name = BindingReflections.findQName(notification);
ret.add(SchemaPath.create(true, name));
private final BindingToNormalizedNodeCodec codecRegistry;
private final DOMNotificationPublishService domPublishService;
- public BindingDOMNotificationPublishServiceAdapter(final BindingToNormalizedNodeCodec codec, final DOMNotificationPublishService domPublishService) {
+ public BindingDOMNotificationPublishServiceAdapter(final BindingToNormalizedNodeCodec codec,
+ final DOMNotificationPublishService domPublishService) {
this.codecRegistry = codec;
this.domPublishService = domPublishService;
}
}
@Override
- public ListenableFuture<?> offerNotification(final Notification notification, final int timeout, final TimeUnit unit) throws InterruptedException {
- ListenableFuture<?> offerResult = domPublishService.offerNotification(toDomNotification(notification), timeout, unit);
+ public ListenableFuture<?> offerNotification(final Notification notification, final int timeout,
+ final TimeUnit unit) throws InterruptedException {
+ ListenableFuture<?> offerResult = domPublishService.offerNotification(toDomNotification(notification),
+ timeout, unit);
return DOMNotificationPublishService.REJECTED.equals(offerResult)
? NotificationPublishService.REJECTED
: offerResult;
final DOMNotificationPublishService domPublish = delegates.getInstance(DOMNotificationPublishService.class);
return new BindingDOMNotificationPublishServiceAdapter(codec, domPublish);
}
-
}
}
private final BindingNormalizedNodeSerializer codec;
private final DOMNotificationService domNotifService;
- public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec, final DOMNotificationService domNotifService) {
+ public BindingDOMNotificationServiceAdapter(final BindingNormalizedNodeSerializer codec,
+ final DOMNotificationService domNotifService) {
this.codec = codec;
this.domNotifService = domNotifService;
}
@Override
public <T extends NotificationListener> ListenerRegistration<T> registerNotificationListener(final T listener) {
- final BindingDOMNotificationListenerAdapter domListener = new BindingDOMNotificationListenerAdapter(codec, listener);
+ final BindingDOMNotificationListenerAdapter domListener =
+ new BindingDOMNotificationListenerAdapter(codec, listener);
final ListenerRegistration<BindingDOMNotificationListenerAdapter> domRegistration =
domNotifService.registerNotificationListener(domListener, domListener.getSupportedNotifications());
return new ListenerRegistrationImpl<>(listener, domRegistration);
}
- private static class ListenerRegistrationImpl<T extends NotificationListener> extends AbstractListenerRegistration<T> {
+ private static class ListenerRegistrationImpl<T extends NotificationListener>
+ extends AbstractListenerRegistration<T> {
private final ListenerRegistration<?> listenerRegistration;
- public ListenerRegistrationImpl(final T listener, final ListenerRegistration<?> listenerRegistration) {
+ ListenerRegistrationImpl(final T listener, final ListenerRegistration<?> listenerRegistration) {
super(listener);
this.listenerRegistration = listenerRegistration;
}
*/
package org.opendaylight.controller.md.sal.binding.impl;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-
class BindingDOMReadTransactionAdapter extends AbstractForwardedTransaction<DOMDataReadOnlyTransaction> implements
ReadOnlyTransaction {
public void close() {
getDelegate().close();
}
-
-}
\ No newline at end of file
+}
*/
package org.opendaylight.controller.md.sal.binding.impl;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-
class BindingDOMReadWriteTransactionAdapter extends
BindingDOMWriteTransactionAdapter<DOMDataReadWriteTransaction> implements ReadWriteTransaction {
final LogicalDatastoreType store, final InstanceIdentifier<T> path) {
return doRead(getDelegate(), store, path);
}
-}
\ No newline at end of file
+}
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.yang.binding.RpcService;
-class BindingDOMRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T>{
+class BindingDOMRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T> {
private final DOMRpcImplementationRegistration<?> reg;
- public BindingDOMRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
+ BindingDOMRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
super(instance);
this.reg = reg;
}
public class BindingDOMRpcImplementationAdapter implements DOMRpcImplementation {
- private static final Cache<Class<?>, RpcServiceInvoker> SERVICE_INVOKERS = CacheBuilder.newBuilder().weakKeys().build();
+ private static final Cache<Class<?>, RpcServiceInvoker> SERVICE_INVOKERS =
+ CacheBuilder.newBuilder().weakKeys().build();
private final BindingNormalizedNodeSerializer codec;
private final RpcServiceInvoker invoker;
private final RpcService delegate;
private final QName inputQname;
- <T extends RpcService> BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeSerializer codec, final Class<T> type, final Map<SchemaPath, Method> localNameToMethod, final T delegate) {
+ <T extends RpcService> BindingDOMRpcImplementationAdapter(final BindingNormalizedNodeSerializer codec,
+ final Class<T> type, final Map<SchemaPath, Method> localNameToMethod, final T delegate) {
try {
this.invoker = SERVICE_INVOKERS.get(type, () -> {
final Map<QName, Method> map = new HashMap<>();
@Nonnull
@Override
- public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final DOMRpcIdentifier rpc, final NormalizedNode<?, ?> input) {
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(@Nonnull final DOMRpcIdentifier rpc,
+ final NormalizedNode<?, ?> input) {
final SchemaPath schemaPath = rpc.getType();
final DataObject bindingInput = input != null ? deserialize(rpc.getType(), input) : null;
final ListenableFuture<RpcResult<?>> bindingResult = invoke(schemaPath, bindingInput);
return JdkFutureAdapters.listenInPoolThread(invoker.invokeRpc(delegate, schemaPath.getLastComponent(), input));
}
- private CheckedFuture<DOMRpcResult, DOMRpcException> transformResult(final ListenableFuture<RpcResult<?>> bindingResult) {
+ private CheckedFuture<DOMRpcResult, DOMRpcException> transformResult(
+ final ListenableFuture<RpcResult<?>> bindingResult) {
return LazyDOMRpcResultFuture.create(codec, bindingResult);
}
private final BindingToNormalizedNodeCodec codec;
private final DOMRpcProviderService domRpcRegistry;
- public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry, final BindingToNormalizedNodeCodec codec) {
+ public BindingDOMRpcProviderServiceAdapter(final DOMRpcProviderService domRpcRegistry,
+ final BindingToNormalizedNodeCodec codec) {
this.codec = codec;
this.domRpcRegistry = domRpcRegistry;
}
return register(type, implementation, toYangInstanceIdentifiers(paths));
}
- private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type, final T implementation, final Collection<YangInstanceIdentifier> rpcContextPaths) {
+ private <S extends RpcService, T extends S> ObjectRegistration<T> register(final Class<S> type,
+ final T implementation, final Collection<YangInstanceIdentifier> rpcContextPaths) {
final Map<SchemaPath, Method> rpcs = codec.getRpcMethodToSchemaPath(type).inverse();
- final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(codec.getCodecRegistry(), type, rpcs, implementation);
+ final BindingDOMRpcImplementationAdapter adapter = new BindingDOMRpcImplementationAdapter(
+ codec.getCodecRegistry(), type, rpcs, implementation);
final Set<DOMRpcIdentifier> domRpcs = createDomRpcIdentifiers(rpcs.keySet(), rpcContextPaths);
final DOMRpcImplementationRegistration<?> domReg = domRpcRegistry.registerRpcImplementation(adapter, domRpcs);
return new BindingRpcAdapterRegistration<>(implementation, domReg);
}
- private static Set<DOMRpcIdentifier> createDomRpcIdentifiers(final Set<SchemaPath> rpcs, final Collection<YangInstanceIdentifier> paths) {
+ private static Set<DOMRpcIdentifier> createDomRpcIdentifiers(final Set<SchemaPath> rpcs,
+ final Collection<YangInstanceIdentifier> paths) {
final Set<DOMRpcIdentifier> ret = new HashSet<>();
for (final YangInstanceIdentifier path : paths) {
for (final SchemaPath rpc : rpcs) {
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
import org.opendaylight.controller.md.sal.binding.api.BindingTransactionChain;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
private final DelegateChainListener domListener;
private final TransactionChainListener bindingListener;
- public BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
+ BindingDOMTransactionChainAdapter(final DOMDataBroker chainFactory,
final BindingToNormalizedNodeCodec codec, final TransactionChainListener listener) {
Preconditions.checkNotNull(chainFactory, "DOM Transaction chain factory must not be null");
this.domListener = new DelegateChainListener();
final WriteTransaction tx, final CheckedFuture<Void, TransactionCommitFailedException> future) {
Futures.addCallback(future, new FutureCallback<Void>() {
@Override
- public void onFailure(final Throwable t) {
- failTransactionChain(tx,t);
+ public void onFailure(final Throwable ex) {
+ failTransactionChain(tx,ex);
}
@Override
public void onSuccess(final Void result) {
// Intentionally NOOP
}
- });
+ }, MoreExecutors.directExecutor());
return future;
}
- private void failTransactionChain(final WriteTransaction tx, final Throwable t) {
+ private void failTransactionChain(final WriteTransaction tx, final Throwable ex) {
/*
* We asume correct state change for underlaying transaction
*
* chain, so we are not changing any of our internal state
* to mark that we failed.
*/
- this.bindingListener.onTransactionChainFailed(this, tx, t);
+ this.bindingListener.onTransactionChainFailed(this, tx, ex);
}
@Override
*/
package org.opendaylight.controller.md.sal.binding.impl;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.ArrayList;
import java.util.List;
-
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-
class BindingDOMWriteTransactionAdapter<T extends DOMDataWriteTransaction> extends
AbstractWriteTransaction<T> implements WriteTransaction {
@Override
protected void ensureParentsByMerge(final LogicalDatastoreType store,
- final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath, final InstanceIdentifier<?> path) {
+ final org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier normalizedPath,
+ final InstanceIdentifier<?> path) {
List<PathArgument> currentArguments = new ArrayList<>();
DataNormalizationOperation<?> currentOp = getCodec().getDataNormalizer().getRootOperation();
for (PathArgument currentArg : normalizedPath.getPathArguments()) {
@Override
public void delete(final LogicalDatastoreType store, final InstanceIdentifier<?> path) {
- doDelete( store, path);
+ doDelete(store, path);
}
@Override
public boolean cancel() {
return doCancel();
}
-}
\ No newline at end of file
+}
import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-class BindingDataTreeChangeListenerRegistration<L extends DataTreeChangeListener<?>> extends AbstractListenerRegistration<L> {
+class BindingDataTreeChangeListenerRegistration<L extends DataTreeChangeListener<?>>
+ extends AbstractListenerRegistration<L> {
private final ListenerRegistration<?> domReg;
@Override
public <T extends BindingService> Optional<T> getService(Class<T> service) {
Optional<BindingService> potential = services.getUnchecked(service);
- if(potential.isPresent()) {
+ if (potential.isPresent()) {
return Optional.of(service.cast(potential.get()));
}
return Optional.absent();
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
import org.opendaylight.yangtools.yang.binding.RpcService;
-class BindingRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T>{
+class BindingRpcAdapterRegistration<T extends RpcService> extends AbstractObjectRegistration<T> {
private final DOMRpcImplementationRegistration<?> reg;
- public BindingRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
+ BindingRpcAdapterRegistration(T instance, DOMRpcImplementationRegistration<?> reg) {
super(instance);
this.reg = reg;
}
/**
* Converts Binding Map.Entry to DOM Map.Entry
*
+ * <p>
* Same as {@link #toNormalizedNode(InstanceIdentifier, DataObject)}.
*
* @param binding Map Entry with InstanceIdentifier as key and DataObject as value.
return this.codecRegistry.toNormalizedNodeRpcData(data);
}
+ public DataNormalizer getDataNormalizer() {
+ return this.legacyToNormalized;
+ }
+
/**
- *
* Returns a Binding-Aware instance identifier from normalized
* instance-identifier if it is possible to create representation.
*
+ * <p>
* Returns Optional.absent for cases where target is mixin node except
* augmentation.
*
}
}
- public DataNormalizer getDataNormalizer() {
- return this.legacyToNormalized;
- }
-
public Optional<Entry<InstanceIdentifier<? extends DataObject>, DataObject>> toBinding(
@Nonnull final Entry<YangInstanceIdentifier, ? extends NormalizedNode<?, ?>> normalized)
throws DeserializationException {
return module;
}
- private void waitForSchema(final Collection<Class<?>> binding, final MissingSchemaException e) {
+ private void waitForSchema(final Collection<Class<?>> binding, final MissingSchemaException ex) {
LOG.warn("Blocking thread to wait for schema convergence updates for {} {}", this.futureSchema.getDuration(),
this.futureSchema.getUnit());
if (this.futureSchema.waitForSchema(binding)) {
return;
}
- throw e;
+ throw ex;
}
private Method findRpcMethod(final Class<? extends RpcService> key, final RpcDefinition rpcDef)
*
* @author Thomas Pantelis
*/
-public class BindingToNormalizedNodeCodecFactory {
+public final class BindingToNormalizedNodeCodecFactory {
+ private BindingToNormalizedNodeCodecFactory() {
+ }
+
/**
* Creates a new BindingToNormalizedNodeCodec instance.
*
- * @param classLoadingStrategy
+ * @param classLoadingStrategy the ClassLoadingStrategy
* @return the BindingToNormalizedNodeCodec instance
*/
public static BindingToNormalizedNodeCodec newInstance(final ClassLoadingStrategy classLoadingStrategy) {
* @param schemaService the SchemaService.
* @return the ListenerRegistration
*/
- public static ListenerRegistration<SchemaContextListener> registerInstance(final BindingToNormalizedNodeCodec instance,
- final DOMSchemaService schemaService) {
+ public static ListenerRegistration<SchemaContextListener> registerInstance(
+ final BindingToNormalizedNodeCodec instance, final DOMSchemaService schemaService) {
return schemaService.registerSchemaContextListener(instance);
}
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
abstract class ContextReferenceExtractor {
-
private static final Logger LOG = LoggerFactory.getLogger(ContextReferenceExtractor.class);
private static final ContextReferenceExtractor NULL_EXTRACTOR = new ContextReferenceExtractor() {
}
};
-
private static final LoadingCache<Class<?>, ContextReferenceExtractor> EXTRACTORS = CacheBuilder.newBuilder()
.weakKeys().build(new CacheLoader<Class<?>, ContextReferenceExtractor>() {
* Extract context-reference (Instance Identifier) from
* Binding DataObject.
*
- * @param obj DataObject from which context reference
- * should be extracted.
+ * @param obj DataObject from which context reference should be extracted.
*
- * @return Instance Identifier representing context reference
- * or null, if data object does not contain context reference.
+ * @return Instance Identifier representing context reference or null, if data object does not contain
+ * context reference.
*/
abstract @Nullable InstanceIdentifier<?> extract(DataObject obj);
private static Method findGetValueMethod(final Class<?> type, final Class<?> returnType) {
try {
final Method method = type.getMethod(GET_VALUE_NAME);
- if(returnType.equals(method.getReturnType())) {
+ if (returnType.equals(method.getReturnType())) {
return method;
}
} catch (final NoSuchMethodException e) {
}
return null;
}
-
-
-
}
final class DirectGetterRouteContextExtractor extends ContextReferenceExtractor {
- private final static Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
+ private static final Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
private final MethodHandle handle;
private DirectGetterRouteContextExtractor(final MethodHandle rawHandle) {
handle = rawHandle.asType(MethodType.methodType(InstanceIdentifier.class, DataObject.class));
}
- static final ContextReferenceExtractor create(final Method getterMethod) throws IllegalAccessException {
+ static ContextReferenceExtractor create(final Method getterMethod) throws IllegalAccessException {
final MethodHandle getterHandle = PUBLIC_LOOKUP.unreflect(getterMethod);
return new DirectGetterRouteContextExtractor(getterHandle);
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
InstanceIdentifier<?> extract(final DataObject obj) {
try {
return (InstanceIdentifier<?>) handle.invokeExact(obj);
- } catch (final Throwable e) {
+ } catch (Throwable e) {
throw Throwables.propagate(e);
}
}
-
}
class FutureSchema implements AutoCloseable {
- @GuardedBy(value="postponedOperations")
+ @GuardedBy(value = "postponedOperations")
private final Set<FutureSchemaPredicate> postponedOperations = new LinkedHashSet<>();
private final long duration;
private final TimeUnit unit;
BindingRuntimeContext runtimeContext() {
final BindingRuntimeContext localRuntimeContext = this.runtimeContext;
- if(localRuntimeContext != null) {
+ if (localRuntimeContext != null) {
return localRuntimeContext;
}
- if(waitForSchema(Collections.emptyList())) {
+ if (waitForSchema(Collections.emptyList())) {
return this.runtimeContext;
}
}
void onRuntimeContextUpdated(final BindingRuntimeContext context) {
- synchronized(this.postponedOperations) {
+ synchronized (this.postponedOperations) {
this.runtimeContext = context;
for (final FutureSchemaPredicate op : this.postponedOperations) {
op.unlockIfPossible(context);
@Override
public void close() {
- synchronized(this.postponedOperations) {
+ synchronized (this.postponedOperations) {
for (final FutureSchemaPredicate op : this.postponedOperations) {
op.cancel();
}
}
private boolean addPostponedOpAndWait(final FutureSchemaPredicate postponedOp) {
- if(!this.waitEnabled) {
+ if (!this.waitEnabled) {
return false;
}
final BindingRuntimeContext localRuntimeContext = this.runtimeContext;
- synchronized(this.postponedOperations) {
+ synchronized (this.postponedOperations) {
this.postponedOperations.add(postponedOp);
// If the runtimeContext changed, this op may now be satisfied so check it.
- if(localRuntimeContext != this.runtimeContext) {
+ if (localRuntimeContext != this.runtimeContext) {
postponedOp.unlockIfPossible(this.runtimeContext);
}
}
} catch (final TimeoutException e) {
return false;
} finally {
- synchronized(FutureSchema.this.postponedOperations) {
+ synchronized (FutureSchema.this.postponedOperations) {
FutureSchema.this.postponedOperations.remove(this);
}
}
private final SettableFuture<?> schemaPromise = SettableFuture.create();
}
-
}
final class GetValueRouteContextExtractor extends ContextReferenceExtractor {
- private final static Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
+ private static final Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup();
private final MethodHandle contextHandle;
private final MethodHandle valueHandle;
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
InstanceIdentifier<?> extract(final DataObject obj) {
try {
final Object ctx = contextHandle.invokeExact(obj);
return (InstanceIdentifier<?>) valueHandle.invokeExact(ctx);
}
return null;
- } catch (final Throwable e) {
+ } catch (Throwable e) {
throw Throwables.propagate(e);
}
}
-
-
}
*/
final class LazyDataObjectModification<T extends DataObject> implements DataObjectModification<T> {
- private final static Logger LOG = LoggerFactory.getLogger(LazyDataObjectModification.class);
+ private static final Logger LOG = LoggerFactory.getLogger(LazyDataObjectModification.class);
private final BindingCodecTreeNode<T> codec;
private final DataTreeCandidateNode domData;
return new LazyDataObjectModification<>(codec,domData);
}
- private static Collection<DataObjectModification<? extends DataObject>> from(final BindingCodecTreeNode<?> parentCodec,
- final Collection<DataTreeCandidateNode> domChildNodes) {
+ private static Collection<DataObjectModification<? extends DataObject>> from(
+ final BindingCodecTreeNode<?> parentCodec, final Collection<DataTreeCandidateNode> domChildNodes) {
final List<DataObjectModification<? extends DataObject>> result = new ArrayList<>(domChildNodes.size());
populateList(result, parentCodec, domChildNodes);
return result;
case UNKNOWN:
case VISIBLE_CONTAINER:
result.add(create(childCodec, domChildNode));
+ break;
default:
break;
}
@Override
@SuppressWarnings("unchecked")
- public <C extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem(
- final Class<C> listItem, final K listKey) {
- return (DataObjectModification<C>) getModifiedChild(new InstanceIdentifier.IdentifiableItem<>(listItem, listKey));
+ public <C extends Identifiable<K> & ChildOf<? super T>, K extends Identifier<C>> DataObjectModification<C>
+ getModifiedChildListItem(final Class<C> listItem, final K listKey) {
+ return (DataObjectModification<C>) getModifiedChild(new InstanceIdentifier.IdentifiableItem<>(
+ listItem, listKey));
}
@Override
private final DataTreeIdentifier<T> path;
private final DataObjectModification<T> rootNode;
- LazyDataTreeModification(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> path, final BindingCodecTreeNode<T> codec, final DataTreeCandidate domChange) {
+ LazyDataTreeModification(final LogicalDatastoreType datastoreType, final InstanceIdentifier<T> path,
+ final BindingCodecTreeNode<T> codec, final DataTreeCandidate domChange) {
this.path = new DataTreeIdentifier<>(datastoreType, path);
this.rootNode = LazyDataObjectModification.create(codec, domChange.getRootNode());
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
- static <T extends DataObject> DataTreeModification<T> create(final BindingToNormalizedNodeCodec codec, final DataTreeCandidate domChange,
- final LogicalDatastoreType datastoreType) {
+ static <T extends DataObject> DataTreeModification<T> create(final BindingToNormalizedNodeCodec codec,
+ final DataTreeCandidate domChange, final LogicalDatastoreType datastoreType) {
final Entry<InstanceIdentifier<?>, BindingCodecTreeNode<?>> codecCtx =
codec.getSubtreeCodec(domChange.getRootPath());
return new LazyDataTreeModification(datastoreType, codecCtx.getKey(), codecCtx.getValue(), domChange);
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-/**
- *
- * FIXME: Should be this moved to binding-data-codec?
- *
- */
+ // FIXME: Should be this moved to binding-data-codec?
class LazySerializedContainerNode implements ContainerNode {
private final NodeIdentifier identifier;
/**
* Lazy serialized implementation of DOM Notification.
*
+ * <p>
* This implementation performs serialization of data, only if receiver
* of notification actually accessed data from notification.
*
private ContainerNode domBody;
- private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification data, final SchemaPath type) {
+ private LazySerializedDOMNotification(final BindingNormalizedNodeSerializer codec, final Notification data,
+ final SchemaPath type) {
this.codec = codec;
this.data = data;
this.type = type;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.MoreExecutors;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
private ListenableFuture<RpcResult<?>> invoke0(final SchemaPath schemaPath, final NormalizedNode<?, ?> input) {
final CheckedFuture<DOMRpcResult, DOMRpcException> result = delegate.invokeRpc(schemaPath, input);
- if(result instanceof LazyDOMRpcResultFuture) {
+ if (result instanceof LazyDOMRpcResultFuture) {
return ((LazyDOMRpcResultFuture) result).getBindingFuture();
}
}
@Override
- public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
+ public Object invoke(final Object proxyObj, final Method method, final Object[] args) throws Throwable {
final RpcInvocationStrategy rpc = rpcNames.get(method);
if (rpc != null) {
}
if (isObjectMethod(method)) {
- return callObjectMethod(proxy, method, args);
+ return callObjectMethod(proxyObj, method, args);
}
throw new UnsupportedOperationException("Method " + method.toString() + "is unsupported.");
}
- private static boolean isObjectMethod(final Method m) {
- switch (m.getName()) {
+ private static boolean isObjectMethod(final Method method) {
+ switch (method.getName()) {
case "toString":
- return (m.getReturnType().equals(String.class) && m.getParameterTypes().length == 0);
+ return method.getReturnType().equals(String.class) && method.getParameterTypes().length == 0;
case "hashCode":
- return (m.getReturnType().equals(int.class) && m.getParameterTypes().length == 0);
+ return method.getReturnType().equals(int.class) && method.getParameterTypes().length == 0;
case "equals":
- return (m.getReturnType().equals(boolean.class) && m.getParameterTypes().length == 1 && m
- .getParameterTypes()[0] == Object.class);
+ return method.getReturnType().equals(boolean.class) && method.getParameterTypes().length == 1 && method
+ .getParameterTypes()[0] == Object.class;
default:
return false;
}
}
- private Object callObjectMethod(final Object self, final Method m, final Object[] args) {
- switch (m.getName()) {
+ private Object callObjectMethod(final Object self, final Method method, final Object[] args) {
+ switch (method.getName()) {
case "toString":
return type.getName() + "$Adapter{delegate=" + delegate.toString() + "}";
case "hashCode":
return System.identityHashCode(self);
case "equals":
- return (self == args[0]);
+ return self == args[0];
default:
return null;
}
bindingResult = null;
}
return RpcResult.class.cast(RpcResultBuilder.success(bindingResult).build());
- });
+ }, MoreExecutors.directExecutor());
}
private abstract class RpcInvocationStrategy {
final SchemaPath getRpcName() {
return rpcName;
}
-
}
private final class NonRoutedStrategy extends RpcInvocationStrategy {
NormalizedNode<?, ?> serialize(final DataObject input) {
return LazySerializedContainerNode.create(getRpcName(), input, codec.getCodecRegistry());
}
-
}
private final class RoutedStrategy extends RpcInvocationStrategy {
}
return LazySerializedContainerNode.create(getRpcName(), input, codec.getCodecRegistry());
}
-
}
}
*/
package org.opendaylight.controller.md.sal.binding.spi;
-
import com.google.common.base.Preconditions;
import com.google.common.collect.ClassToInstanceMap;
import com.google.common.collect.ImmutableClassToInstanceMap;
public abstract Set<? extends Class<? extends D>> getRequiredDelegates();
- protected abstract T createInstance(ClassToInstanceMap<D> delegates);
+ protected abstract T createInstance(ClassToInstanceMap<D> classToInstanceMap);
private void checkAllRequiredServices() {
- for(final Class<? extends D> type : getRequiredDelegates()) {
+ for (final Class<? extends D> type : getRequiredDelegates()) {
Preconditions.checkState(delegates.get(type) != null, "Requires service %s is not defined.",type);
}
}
- public final <V extends D>void addDelegate(final Class<V> type,final D impl) {
+ public final <V extends D> void addDelegate(final Class<V> type,final D impl) {
delegates.put(type,impl);
}
checkAllRequiredServices();
return createInstance(ImmutableClassToInstanceMap.<D,D>copyOf(delegates));
}
-
}
public Optional<T> load(final Class<? extends T> key) {
final AdapterBuilder<? extends T, D> builder = createBuilder(key);
- for(final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
+ for (final Class<? extends D> reqDeleg : builder.getRequiredDelegates()) {
final D deleg = getDelegate(reqDeleg);
- if(deleg != null) {
- builder.addDelegate(reqDeleg,deleg);
+ if (deleg != null) {
+ builder.addDelegate(reqDeleg, deleg);
} else {
return Optional.absent();
}
@Nonnull
protected abstract AdapterBuilder<? extends T, D> createBuilder(Class<? extends T> key);
-
}
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import javassist.ClassPool;
import org.apache.commons.lang3.StringUtils;
import org.opendaylight.mdsal.binding.generator.util.JavassistUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javassist.ClassPool;
-public class SingletonHolder {
+public final class SingletonHolder {
private static final Logger LOG = LoggerFactory.getLogger(SingletonHolder.class);
public static final ClassPool CLASS_POOL = ClassPool.getDefault();
private static ListeningExecutorService COMMIT_EXECUTOR = null;
private static ListeningExecutorService CHANGE_EVENT_EXECUTOR = null;
+ private SingletonHolder() {
+ }
+
/**
+ * Deprecated.
+ *
* @deprecated This method is only used from configuration modules and thus callers of it
* should use service injection to make the executor configurable.
*/
}
@Override
- public boolean offer(final Runnable r) {
+ public boolean offer(final Runnable runnrunnableable) {
// ThreadPoolExecutor will spawn a new thread after core size is reached only
// if the queue.offer returns false.
return false;
}
};
- final ThreadFactory factory = new ThreadFactoryBuilder()
- .setDaemon(true)
- .setNameFormat("md-sal-binding-notification-%d")
- .build();
-
- final ThreadPoolExecutor executor = new ThreadPoolExecutor(CORE_NOTIFICATION_THREADS, MAX_NOTIFICATION_THREADS,
- NOTIFICATION_THREAD_LIFE, TimeUnit.SECONDS, queue, factory,
- // if the max threads are met, then it will raise a rejectedExecution. We then push to the queue.
- (r, executor1) -> {
- try {
- executor1.getQueue().put(r);
- } catch (final InterruptedException e) {
- throw new RejectedExecutionException("Interrupted while waiting on the queue", e);
- }
- });
+ final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true)
+ .setNameFormat("md-sal-binding-notification-%d").build();
+
+ final ThreadPoolExecutor executor = new ThreadPoolExecutor(CORE_NOTIFICATION_THREADS,
+ MAX_NOTIFICATION_THREADS, NOTIFICATION_THREAD_LIFE, TimeUnit.SECONDS, queue, factory,
+ // if the max threads are met, then it will raise a rejectedExecution. We then push to the queue.
+ (runnable, executor1) -> {
+ try {
+ executor1.getQueue().put(runnable);
+ } catch (final InterruptedException e) {
+ throw new RejectedExecutionException("Interrupted while waiting on the queue", e);
+ }
+ });
NOTIFICATION_EXECUTOR = MoreExecutors.listeningDecorator(executor);
}
}
/**
+ * Deprecated.
+ *
* @deprecated This method is only used from configuration modules and thus callers of it
* should use service injection to make the executor configurable.
*/
@Deprecated
public static synchronized ListeningExecutorService getDefaultCommitExecutor() {
if (COMMIT_EXECUTOR == null) {
- final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("md-sal-binding-commit-%d").build();
+ final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true)
+ .setNameFormat("md-sal-binding-commit-%d").build();
/*
* FIXME: this used to be newCacheThreadPool(), but MD-SAL does not have transaction
* ordering guarantees, which means that using a concurrent threadpool results
public static ExecutorService getDefaultChangeEventExecutor() {
if (CHANGE_EVENT_EXECUTOR == null) {
- final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true).setNameFormat("md-sal-binding-change-%d").build();
+ final ThreadFactory factory = new ThreadFactoryBuilder().setDaemon(true)
+ .setNameFormat("md-sal-binding-change-%d").build();
/*
* FIXME: this used to be newCacheThreadPool(), but MD-SAL does not have transaction
* ordering guarantees, which means that using a concurrent threadpool results
public class RootBindingAwareBroker implements Mutable, Identifiable<String>, BindingAwareBroker, AutoCloseable,
RpcProviderRegistry {
- private final static Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
+ private static final Logger LOG = LoggerFactory.getLogger(RootBindingAwareBroker.class);
RootSalInstance controllerRoot;
return registerConsumer(consumer);
}
- @Override
- public ProviderContext registerProvider(final BindingAwareProvider provider, final BundleContext ctx) {
- return registerProvider(provider);
- }
-
@Override
public ConsumerContext registerConsumer(final BindingAwareConsumer consumer) {
checkState(supportedConsumerServices != null, "Broker is not initialized.");
return BindingContextUtils.createConsumerContextAndInitialize(consumer, supportedConsumerServices);
}
+ @Override
+ public ProviderContext registerProvider(final BindingAwareProvider provider, final BundleContext ctx) {
+ return registerProvider(provider);
+ }
+
@Override
public ProviderContext registerProvider(final BindingAwareProvider provider) {
checkState(supportedProviderServices != null, "Broker is not initialized.");
}
@Override
- public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L> registerRouteChangeListener(
- final L arg0) {
- return getRoot().registerRouteChangeListener(arg0);
+ public <L extends RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> ListenerRegistration<L>
+ registerRouteChangeListener(final L listener) {
+ return getRoot().registerRouteChangeListener(listener);
}
public class RootSalInstance extends
super(rpcRegistry, notificationBroker);
}
}
-
}
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
+
import java.util.Collection;
import org.hamcrest.Description;
import org.junit.Before;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeListener;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeChangeService;
import org.opendaylight.controller.md.sal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry;
+import org.opendaylight.mdsal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@Test
public void testRegisterDataTreeChangeListener() {
- final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
+ final BindingToNormalizedNodeCodec codec =
+ new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
final DataTreeChangeService service = BindingDOMDataTreeChangeServiceAdapter.create(codec, this.mockDOMService);
- doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID),
+ doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(
+ domDataTreeIdentifier(this.mockYangID),
any(DOMDataTreeChangeListener.class));
final DataTreeIdentifier<Top> treeId = new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, TOP_PATH);
final TestClusteredDataTreeChangeListener mockClusteredListener = new TestClusteredDataTreeChangeListener();
isA(ClusteredDOMDataTreeChangeListener.class));
reset(this.mockDOMService);
- doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(domDataTreeIdentifier(this.mockYangID),
- any(DOMDataTreeChangeListener.class));
+ doReturn(this.mockDOMReg).when(this.mockDOMService).registerDataTreeChangeListener(
+ domDataTreeIdentifier(this.mockYangID), any(DOMDataTreeChangeListener.class));
final TestDataTreeChangeListener mockNonClusteredListener = new TestDataTreeChangeListener();
service.registerDataTreeChangeListener(treeId , mockNonClusteredListener);
@Override
public boolean matches(final Object argument) {
final DOMDataTreeIdentifier treeId = (DOMDataTreeIdentifier) argument;
- return (treeId.getDatastoreType() == LogicalDatastoreType.CONFIGURATION) &&
- yangID.equals(treeId.getRootIdentifier());
+ return treeId.getDatastoreType() == LogicalDatastoreType.CONFIGURATION
+ && yangID.equals(treeId.getRootIdentifier());
}
@Override
private static final TopLevelListKey TOP_FOO_KEY = new TopLevelListKey("foo");
private static final InstanceIdentifier<TopLevelList> BA_TOP_LEVEL_LIST = InstanceIdentifier
.builder(Top.class).child(TopLevelList.class, TOP_FOO_KEY).build();
- private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY = BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
- private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES = BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
+ private static final InstanceIdentifier<TreeLeafOnlyAugment> BA_TREE_LEAF_ONLY =
+ BA_TOP_LEVEL_LIST.augmentation(TreeLeafOnlyAugment.class);
+ private static final InstanceIdentifier<TreeComplexUsesAugment> BA_TREE_COMPLEX_USES =
+ BA_TOP_LEVEL_LIST.augmentation(TreeComplexUsesAugment.class);
private static final QName SIMPLE_VALUE_QNAME = QName.create(TreeComplexUsesAugment.QNAME, "simple-value");
private static final QName NAME_QNAME = QName.create(Top.QNAME, "name");
- private static final YangInstanceIdentifier BI_TOP_LEVEL_LIST = YangInstanceIdentifier.builder().
- node(Top.QNAME).node(TopLevelList.QNAME).nodeWithKey(
+ private static final YangInstanceIdentifier BI_TOP_LEVEL_LIST = YangInstanceIdentifier.builder()
+ .node(Top.QNAME).node(TopLevelList.QNAME).nodeWithKey(
TopLevelList.QNAME, NAME_QNAME, TOP_FOO_KEY.getName()).build();
private SchemaContext context;
@Override
- protected void setupWithSchema(final SchemaContext context) {
- this.context = context;
- final DataObjectSerializerGenerator streamWriter = StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()));
+ protected void setupWithSchema(final SchemaContext schemaContext) {
+ this.context = schemaContext;
+ final DataObjectSerializerGenerator streamWriter = StreamWriterGenerator
+ .create(JavassistUtils.forClassPool(ClassPool.getDefault()));
final BindingNormalizedNodeCodecRegistry registry = new BindingNormalizedNodeCodecRegistry(streamWriter);
- this.codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), registry, true);
+ this.codec = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
+ registry, true);
}
@Test
@Test
public void testLeafOnlyAugmentationSerialization() {
this.codec.onGlobalContextUpdated(this.context);
- final PathArgument leafOnlyLastArg = this.codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY).getLastPathArgument();
+ final PathArgument leafOnlyLastArg = this.codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY)
+ .getLastPathArgument();
assertTrue(leafOnlyLastArg instanceof AugmentationIdentifier);
assertTrue(((AugmentationIdentifier) leafOnlyLastArg).getPossibleChildNames().contains(SIMPLE_VALUE_QNAME));
}
@Test
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void testToYangInstanceIdentifierBlocking() {
this.codec.onGlobalContextUpdated(new EmptySchemaContext());
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference<YangInstanceIdentifier> yangId = new AtomicReference<>();
final AtomicReference<RuntimeException> error = new AtomicReference<>();
+
new Thread(() -> {
try {
yangId.set(BindingNormalizedCodecTest.this.codec.toYangInstanceIdentifierBlocking(BA_TOP_LEVEL_LIST));
- } catch(final RuntimeException e) {
+ } catch (RuntimeException e) {
error.set(e);
} finally {
done.countDown();
assertEquals("toYangInstanceIdentifierBlocking completed", true,
Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS));
- if(error.get() != null) {
+ if (error.get() != null) {
throw error.get();
}
testGetRpcMethodToSchemaPath();
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private void testGetRpcMethodToSchemaPath() {
final CountDownLatch done = new CountDownLatch(1);
final AtomicReference<ImmutableBiMap<Method, SchemaPath>> retMap = new AtomicReference<>();
final AtomicReference<RuntimeException> error = new AtomicReference<>();
new Thread(() -> {
try {
- retMap.set(BindingNormalizedCodecTest.this.codec.getRpcMethodToSchemaPath(OpendaylightTestRpcServiceService.class));
- } catch(final RuntimeException e) {
+ retMap.set(BindingNormalizedCodecTest.this.codec.getRpcMethodToSchemaPath(
+ OpendaylightTestRpcServiceService.class));
+ } catch (RuntimeException e) {
error.set(e);
} finally {
done.countDown();
assertEquals("getRpcMethodToSchemaPath completed", true,
Uninterruptibles.awaitUninterruptibly(done, 3, TimeUnit.SECONDS));
- if(error.get() != null) {
+ if (error.get() != null) {
throw error.get();
}
- for(final Method method: retMap.get().keySet()) {
- if(method.getName().equals("rockTheHouse")) {
+ for (final Method method: retMap.get().keySet()) {
+ if (method.getName().equals("rockTheHouse")) {
return;
}
}
final InstanceIdentifier<?> extractedValue = extractor.extract(TEST_GROUPING);
assertSame(TEST_ROUTE,extractedValue);
}
- }
+}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import java.util.concurrent.TimeUnit;
-import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
-
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.binding.compat.HeliumNotificationProviderServiceAdapter;
import org.opendaylight.controller.md.sal.binding.test.AbstractNotificationBrokerTest;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.OpendaylightMdsalListTestListener;
public void initTest() {
final NotificationService notificationService = getNotificationService();
final NotificationPublishService notificationPublishService = getNotificationPublishService();
- notificationProviderService = new HeliumNotificationProviderServiceAdapter(notificationPublishService, notificationService);
+ notificationProviderService = new HeliumNotificationProviderServiceAdapter(notificationPublishService,
+ notificationService);
}
private TwoLevelListChanged createTestData() {
private static class NotifTestListenerChild extends NotifTestListener {
- public NotifTestListenerChild(final CountDownLatch latch) {
+ NotifTestListenerChild(final CountDownLatch latch) {
super(latch);
}
}
+
private static class NotifTestListener implements OpendaylightMdsalListTestListener {
- private List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
- private CountDownLatch latch;
+ private final List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
+ private final CountDownLatch latch;
- public NotifTestListener(CountDownLatch latch) {
+ NotifTestListener(CountDownLatch latch) {
this.latch = latch;
}
return receivedNotifications;
}
}
-
}
@Test
public void testClusteredDataChangeListernerRegisteration() {
- final BindingToNormalizedNodeCodec codec = new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
+ final BindingToNormalizedNodeCodec codec =
+ new BindingToNormalizedNodeCodec(this.classLoadingStrategy, this.codecRegistry);
try (BindingDOMDataBrokerAdapter bindingDOMDataBrokerAdapter = new BindingDOMDataBrokerAdapter(this.dataBroker,
codec)) {
.forClass(LogicalDatastoreType.class);
final ArgumentCaptor<AsyncDataBroker.DataChangeScope> dataChangeScope = ArgumentCaptor
.forClass(AsyncDataBroker.DataChangeScope.class);
- final ArgumentCaptor<YangInstanceIdentifier> yangInstanceIdentifier = ArgumentCaptor
+ final ArgumentCaptor<YangInstanceIdentifier> yangIidCapture = ArgumentCaptor
.forClass(YangInstanceIdentifier.class);
final TestListener listener = new TestListener();
bindingDOMDataBrokerAdapter.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL, TOP_PATH,
listener, AsyncDataBroker.DataChangeScope.BASE);
Mockito.verify(this.dataBroker).registerDataChangeListener(logicalDatastoreType.capture(),
- yangInstanceIdentifier.capture(), clusteredDOMListener.capture(), dataChangeScope.capture());
+ yangIidCapture.capture(), clusteredDOMListener.capture(), dataChangeScope.capture());
}
}
/**
* Regression test suite for Bug 1125 - Can't detect switch disconnection
- * https://bugs.opendaylight.org/show_bug.cgi?id=1125
+ * https://bugs.opendaylight.org/show_bug.cgi?id=1125.
*/
public class Bug1125RegressionTest extends AbstractDataChangeListenerTest {
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
- *
* This testsuite tries to replicate bug 1333 and tests regresion of it
* using test-model with similar construction as one reported.
*
- *
+ * <p>
* See https://bugs.opendaylight.org/show_bug.cgi?id=1333 for Bug Description
- *
*/
-public class Bug1333DataChangeListenerTest extends AbstractDataChangeListenerTest{
+public class Bug1333DataChangeListenerTest extends AbstractDataChangeListenerTest {
private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
assertContains(event.getRemovedPaths(), deletePath);
}
-
}
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class Bug1418AugmentationTest extends AbstractDataChangeListenerTest{
+public class Bug1418AugmentationTest extends AbstractDataChangeListenerTest {
private static final InstanceIdentifier<Top> TOP = InstanceIdentifier.create(Top.class);
private static final InstanceIdentifier<TopLevelList> TOP_FOO = TOP.child(TopLevelList.class, TOP_FOO_KEY);
private static final InstanceIdentifier<TreeLeafOnlyUsesAugment> SIMPLE_AUGMENT =
@Test
public void leafOnlyAugmentationCreatedTest() {
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE, false);
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf changed"));
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT, leafOnlyUsesAugment("test leaf"));
assertCommit(writeTx.submit());
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.delete(LogicalDatastoreType.CONFIGURATION, SIMPLE_AUGMENT);
@Test
public void complexAugmentationCreatedTest() {
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE, false);
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP, top());
writeTx.put(LogicalDatastoreType.CONFIGURATION, TOP_FOO, topLevelList(new TopLevelListKey(TOP_FOO_KEY)));
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY));
assertCommit(writeTx.submit());
- TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
+ final TestListener listener = createListener(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT,
AsyncDataBroker.DataChangeScope.SUBTREE);
writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.CONFIGURATION, COMPLEX_AUGMENT, complexUsesAugment(LIST_VIA_USES_KEY_MOD));
private void writeRoot(final LogicalDatastoreType store) {
final ReadWriteTransaction readWriteTransaction = getDataBroker().newReadWriteTransaction();
final Barroot barRoot = new BarrootBuilder().setType(2).setValue(2).setKey(new BarrootKey(2)).build();
- final ArrayList barRootList = new ArrayList();
+ final ArrayList<Barroot> barRootList = new ArrayList<>();
barRootList.add(barRoot);
final Fooroot fooRoot = new FoorootBuilder().setBarroot(barRootList).build();
- final ArrayList fooRootList = new ArrayList();
+ final ArrayList<Fooroot> fooRootList = new ArrayList<>();
fooRootList.add(fooRoot);
final Root root = new RootBuilder().setFooroot(fooRootList).build();
@Test
public void writeListToList2562Root() {
- final AbstractDataChangeListenerTest.TestListener listenerRoot = createListener(LogicalDatastoreType.CONFIGURATION,
- ROOT_PATH, AsyncDataBroker.DataChangeScope.ONE, false);
+ final AbstractDataChangeListenerTest.TestListener listenerRoot =
+ createListener(LogicalDatastoreType.CONFIGURATION, ROOT_PATH, AsyncDataBroker.DataChangeScope.ONE, false);
writeRoot(LogicalDatastoreType.CONFIGURATION);
final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> eventRoot = listenerRoot.event();
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public class Bug3090MultiKeyList extends AbstractDataChangeListenerTest{
+public class Bug3090MultiKeyList extends AbstractDataChangeListenerTest {
private static final InstanceIdentifier<Root> ROOT_PATH = InstanceIdentifier.create(Root.class);
private void write(final LogicalDatastoreType store) {
private SettableFuture<Collection<DataTreeModification<T>>> changes = SettableFuture.create();
@Override
- public void onDataTreeChanged(final Collection<DataTreeModification<T>> changes) {
- this.changes.set(changes);
+ public void onDataTreeChanged(final Collection<DataTreeModification<T>> modification) {
+ this.changes.set(modification);
}
changes = SettableFuture.create();
return result;
}
-
}
@Override
createAndVerifyTop(listener);
putTx(BAR_PATH, BAR_DATA).submit().checkedGet();
- final DataObjectModification<Top> afterBarPutEvent = Iterables.getOnlyElement(listener.nextEvent()).getRootNode();
+ final DataObjectModification<Top> afterBarPutEvent = Iterables.getOnlyElement(listener.nextEvent())
+ .getRootNode();
verifyModification(afterBarPutEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED);
- final DataObjectModification<TopLevelList> barPutMod = afterBarPutEvent.getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
+ final DataObjectModification<TopLevelList> barPutMod = afterBarPutEvent
+ .getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
assertNotNull(barPutMod);
verifyModification(barPutMod, BAR_ARGUMENT, ModificationType.WRITE);
deleteTx(BAR_PATH).submit().checkedGet();
- final DataObjectModification<Top> afterBarDeleteEvent = Iterables.getOnlyElement(listener.nextEvent()).getRootNode();
+ final DataObjectModification<Top> afterBarDeleteEvent = Iterables.getOnlyElement(listener.nextEvent())
+ .getRootNode();
verifyModification(afterBarDeleteEvent, TOP_ARGUMENT, ModificationType.SUBTREE_MODIFIED);
- final DataObjectModification<TopLevelList> barDeleteMod = afterBarDeleteEvent.getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
+ final DataObjectModification<TopLevelList> barDeleteMod = afterBarDeleteEvent
+ .getModifiedChildListItem(TopLevelList.class, TOP_BAR_KEY);
verifyModification(barDeleteMod, BAR_ARGUMENT, ModificationType.DELETE);
}
@Test
public void testWildcardedListListener() throws Exception {
final EventCapturingListener<TopLevelList> listener = new EventCapturingListener<>();
- final DataTreeIdentifier<TopLevelList> wildcard = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, TOP_PATH.child(TopLevelList.class));
+ final DataTreeIdentifier<TopLevelList> wildcard = new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+ TOP_PATH.child(TopLevelList.class));
dataBrokerImpl.registerDataTreeChangeListener(wildcard, listener);
putTx(TOP_PATH, TOP_INITIAL_DATA).submit().checkedGet();
assertEquals(TOP_INITIAL_DATA, initialNode.getDataAfter());
}
- private void verifyModification(final DataObjectModification<? extends DataObject> barWrite, final PathArgument pathArg,
- final ModificationType eventType) {
+ private void verifyModification(final DataObjectModification<? extends DataObject> barWrite,
+ final PathArgument pathArg, final ModificationType eventType) {
assertEquals(pathArg.getType(), barWrite.getDataType());
assertEquals(eventType,barWrite.getModificationType());
assertEquals(pathArg, barWrite.getIdentifier());
}
private static class TestNotifListener implements OpendaylightMdsalListTestListener {
- private List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
- private CountDownLatch latch;
+ private final List<TwoLevelListChanged> receivedNotifications = new ArrayList<>();
+ private final CountDownLatch latch;
- public TestNotifListener(CountDownLatch latch) {
+ TestNotifListener(CountDownLatch latch) {
this.latch = latch;
}
import static org.junit.Assert.assertTrue;
+import com.google.common.base.Optional;
import java.util.concurrent.ExecutionException;
-
import org.junit.Test;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import com.google.common.base.Optional;
-
-
public class WriteTransactionTest extends AbstractConcurrentDataBrokerTest {
private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
}
@Test
- public void testPutCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
+ public void testPutCreateParentsSuccess()
+ throws TransactionCommitFailedException, InterruptedException, ExecutionException {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.put(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
writeTx.submit().checkedGet();
}
@Test
- public void testMergeCreateParentsSuccess() throws TransactionCommitFailedException, InterruptedException, ExecutionException {
+ public void testMergeCreateParentsSuccess()
+ throws TransactionCommitFailedException, InterruptedException, ExecutionException {
WriteTransaction writeTx = getDataBroker().newWriteOnlyTransaction();
writeTx.merge(LogicalDatastoreType.OPERATIONAL, NODE_PATH, NODE,true);
writeTx.submit().checkedGet();
Optional<TopLevelList> listNode = readTx.read(LogicalDatastoreType.OPERATIONAL, NODE_PATH).get();
assertTrue("List node must exists after commit",listNode.isPresent());
}
-
}
}
public NotificationService createNotificationService() {
- return new BindingDOMNotificationServiceAdapter(this.bindingToNormalized.getCodecRegistry(), this.domNotificationRouter);
+ return new BindingDOMNotificationServiceAdapter(this.bindingToNormalized.getCodecRegistry(),
+ this.domNotificationRouter);
}
public NotificationPublishService createNotificationPublishService() {
import java.util.Collection;
import java.util.Map;
-
import org.junit.Assert;
-public class AssertCollections {
+public final class AssertCollections {
+ private AssertCollections() {
+ }
public static void assertEmpty(final Collection<?> set) {
Assert.assertTrue(set.isEmpty());
}
- public static void assertNotContains(final Collection<?> set, final Object... values) {
+ public static void assertContains(final Map<?,?> map, final Object... values) {
for (Object key : values) {
- Assert.assertFalse(set.contains(key));
+ Assert.assertTrue(map.containsKey(key));
}
}
- public static void assertContains(final Map<?,?> map, final Object... values) {
+ public static void assertNotContains(final Collection<?> set, final Object... values) {
for (Object key : values) {
- Assert.assertTrue(map.containsKey(key));
+ Assert.assertFalse(set.contains(key));
}
}
package org.opendaylight.controller.sal.binding.test;
import static org.junit.Assert.assertNotNull;
+
import org.opendaylight.yangtools.yang.binding.Augmentable;
import org.opendaylight.yangtools.yang.binding.Augmentation;
public class AugmentationVerifier<T extends Augmentable<T>> {
- private T object;
+ private final T object;
public AugmentationVerifier(T objectToVerify) {
this.object = objectToVerify;
public static <T extends Augmentable<T>> void assertHasAugmentation(T object,
Class<? extends Augmentation<T>> augmentation) {
assertNotNull(object);
- assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.", object.getAugmentation(augmentation));
+ assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.",
+ object.getAugmentation(augmentation));
}
public static <T extends Augmentable<T>> AugmentationVerifier<T> from(T obj) {
return new AugmentationVerifier<>(obj);
}
-
}
import org.opendaylight.yangtools.yang.binding.DataRoot;
import org.opendaylight.yangtools.yang.binding.Identifiable;
-public interface ReferencableObject extends DataObject,
- Identifiable<ReferencableObjectKey>,ChildOf<DataRoot>{
-
+public interface ReferencableObject extends DataObject, Identifiable<ReferencableObjectKey>,ChildOf<DataRoot> {
}
private static final long serialVersionUID = 1L;
final Integer value;
- public ReferencableObjectKey(Integer _value) {
- this.value = _value;
+ public ReferencableObjectKey(Integer value) {
+ this.value = value;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + ((value == null) ? 0 : value.hashCode());
+ result = prime * result + (value == null ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
ReferencableObjectKey other = (ReferencableObjectKey) obj;
if (value == null) {
- if (other.value != null)
+ if (other.value != null) {
return false;
- } else if (!value.equals(other.value))
+ }
+ } else if (!value.equals(other.value)) {
return false;
+ }
return true;
}
*/
package org.opendaylight.controller.sal.binding.test.util;
-import java.util.concurrent.ExecutorService;
-
-import javassist.ClassPool;
-
import com.google.common.annotations.Beta;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
+import java.util.concurrent.ExecutorService;
+import javassist.ClassPool;
@Beta
public class BindingBrokerTestFactory {
}
public ClassPool getClassPool() {
- if(classPool == null) {
+ if (classPool == null) {
return CLASS_POOL;
}
public void setClassPool(final ClassPool classPool) {
this.classPool = classPool;
}
-
}
@Beta
public class BindingTestContext implements AutoCloseable {
-
-
private BindingToNormalizedNodeCodec codec;
private RootBindingAwareBroker baBrokerImpl;
return this.codec;
}
- protected BindingTestContext(final ListeningExecutorService executor, final ClassPool classPool, final boolean startWithSchema) {
+ protected BindingTestContext(final ListeningExecutorService executor, final ClassPool classPool,
+ final boolean startWithSchema) {
this.executor = executor;
this.classPool = classPool;
this.startWithSchema = startWithSchema;
public void startBindingToDomMappingService() {
checkState(this.classPool != null, "ClassPool needs to be present");
- final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(JavassistUtils.forClassPool(this.classPool));
+ final DataObjectSerializerGenerator generator = StreamWriterGenerator.create(
+ JavassistUtils.forClassPool(this.classPool));
final BindingNormalizedNodeCodecRegistry codecRegistry = new BindingNormalizedNodeCodecRegistry(generator);
final GeneratedClassLoadingStrategy loading = GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy();
this.codec = new BindingToNormalizedNodeCodec(loading, codecRegistry);
public DataBroker getDataBroker() {
return this.dataBroker;
}
-
-
}