xtend-gen
classes
out/
+.externalToolBuilders
+maven-eclipse.xml
byte[] targetIP = tIP.getAddress();
ARP arp = createARP(ARP.REPLY, sMAC, senderIP, tMAC, targetIP);
+ if(log.isTraceEnabled()) {
+ log.trace("Sending Arp Reply with srcMac {} - srcIp {} - dstMac {} - dstIp {} - outport {}",
+ HexEncode.bytesToHexString(sMAC),
+ sIP, HexEncode.bytesToHexString(tMAC), tIP, p);
+ }
+
Ethernet ethernet = createEthernet(sMAC, tMAC, arp);
RawPacket destPkt = this.dataPacketService.encodeDataPacket(ethernet);
this.dataPacketService.transmitDataPacket(destPkt);
}
+ private void logArpPacket(ARP pkt, NodeConnector p) {
+ try {
+ if (pkt.getOpCode() == ARP.REQUEST) {
+ log.trace("Received Arp Request with srcMac {} - srcIp {} - dstMac {} - dstIp {} - inport {}", HexEncode.bytesToHexString(pkt.getSenderHardwareAddress()),
+ InetAddress.getByAddress(pkt.getSenderProtocolAddress()), HexEncode.bytesToHexString(pkt.getTargetHardwareAddress()),
+ InetAddress.getByAddress(pkt.getTargetProtocolAddress()), p);
+ } else if(pkt.getOpCode() == ARP.REPLY) {
+ log.trace("Received Arp Reply with srcMac {} - srcIp {} - dstMac {} - dstIp {} - inport {}", HexEncode.bytesToHexString(pkt.getSenderHardwareAddress()),
+ InetAddress.getByAddress(pkt.getSenderProtocolAddress()), HexEncode.bytesToHexString(pkt.getTargetHardwareAddress()),
+ InetAddress.getByAddress(pkt.getTargetProtocolAddress()), p);
+ }
+ } catch(UnknownHostException e) {
+ log.warn("Illegal Ip Address in the ARP packet", e);
+ }
+ }
+
protected void handleARPPacket(Ethernet eHeader, ARP pkt, NodeConnector p) {
+ if(log.isTraceEnabled()) {
+ logArpPacket(pkt, p);
+ }
+
byte[] sourceMAC = eHeader.getSourceMACAddress();
byte[] targetMAC = eHeader.getDestinationMACAddress();
/*
byte[] targetIPByte = targetIP.getAddress();
ARP arp = createARP(ARP.REQUEST, getControllerMAC(), senderIP, targetHardwareAddress, targetIPByte);
+ if(log.isTraceEnabled()) {
+ log.trace("Sending Broadcast Arp Request with srcMac {} - srcIp {} - dstMac {} - dstIp {} - outport {}", HexEncode.bytesToHexString(getControllerMAC()),
+ subnet.getNetworkAddress(), HexEncode.bytesToHexString(targetHardwareAddress), targetIP, p);
+ }
+
byte[] destMACAddress = NetUtils.getBroadcastMACAddr();
Ethernet ethernet = createEthernet(getControllerMAC(), destMACAddress, arp);
byte[] targetMAC = host.getDataLayerAddressBytes();
ARP arp = createARP(ARP.REQUEST, getControllerMAC(), senderIP, targetMAC, targetIP);
+ if(log.isTraceEnabled()) {
+ log.trace("Sending Unicast Arp Request with srcMac {} - srcIp {} - dstMac {} - dstIp {} - outport {}",
+ HexEncode.bytesToHexString(getControllerMAC()),
+ subnet.getNetworkAddress(), HexEncode.bytesToHexString(targetMAC), host.getNetworkAddress(),
+ outPort);
+ }
+
Ethernet ethernet = createEthernet(getControllerMAC(), targetMAC, arp);
RawPacket destPkt = this.dataPacketService.encodeDataPacket(ethernet);
package org.opendaylight.controller.clustering.services_implementation.internal;
import java.util.Map;
+
import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
import org.slf4j.Logger;
@Override
void setCacheUpdateAware(Map props, ICacheUpdateAware s) {
- logger.trace("setCacheUpdateAware");
+ logger.trace("setCacheUpdateAware: {}",s);
if (props.get("containerName") != null) {
// If we got a reference with the containerName property
// that is not what we are looking for, so filter it out.
@Override
void unsetCacheUpdateAware(Map props, ICacheUpdateAware s) {
- logger.trace("unsetCacheUpdateAware");
+ logger.trace("unsetCacheUpdateAware: {}",s);
if (props.get("containerName") != null) {
// If we got a reference with the containerName property
// that is not what we are looking for, so filter it out.
* export the interface ICoordinatorChangeAware
*/
class ListenCoordinatorChange implements IListenRoleChange {
+ @Override
public void newActiveAvailable() {
if (coordinatorChangeAware != null) {
// Make sure to look the set while walking it
logger.trace("cachenames provided below:");
for (String cache : caches) {
if (this.cacheUpdateAware.get(cache) != null) {
- logger.error("cachename:{} on container:{} has " +
- "already a listener", cache,
- this.containerName);
+ logger.error("cachename:{} on container:{} has already a listener", cache, this.containerName);
} else {
- GetUpdatesContainer<?, ?> up =
- new GetUpdatesContainer(s, this.containerName,
- cache);
+ GetUpdatesContainer<?, ?> up = new GetUpdatesContainer(s, this.containerName, cache);
if (up != null) {
try {
this.clusterService.addListener(this.containerName,
"been registered", cache,
this.containerName);
} catch (CacheListenerAddException exc) {
+ logger.debug("Cache {} didn't exist when {} tried to register to its updates", cache, s);
// Do nothing, the important is that
// we don't register the listener in
// the shadow, and we are not doing
import org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker;
import org.opendaylight.controller.config.manager.impl.osgi.mapping.RuntimeGeneratedMappingServiceActivator;
import org.opendaylight.controller.config.spi.ModuleFactory;
-import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry;
import org.osgi.framework.BundleActivator;
public class ConfigManagerActivator implements BundleActivator {
private static final Logger logger = LoggerFactory.getLogger(ConfigManagerActivator.class);
- private ExtensibleBundleTracker<Collection<Registration<YangModuleInfo>>> bundleTracker;
+ private final MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
+ private ExtensibleBundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> bundleTracker;
private ConfigRegistryImpl configRegistry;
private ConfigRegistryJMXRegistrator configRegistryJMXRegistrator;
private ServiceRegistration<?> configRegistryServiceRegistration;
-
- private final MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
-
private RuntimeGeneratedMappingServiceActivator mappingServiceActivator;
@Override
*/
package org.opendaylight.controller.config.manager.impl.osgi.mapping;
+import static java.lang.String.format;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
import org.apache.commons.io.IOUtils;
-import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy;
import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import static java.lang.String.format;
-
/**
* Tracks bundles and attempts to retrieve YangModuleInfo.
*/
-public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Collection<Registration<YangModuleInfo>>> {
+public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer<Collection<ObjectRegistration<YangModuleInfo>>> {
private static final Logger logger = LoggerFactory.getLogger(ModuleInfoBundleTracker.class);
public static final String GET_MODULE_INFO_METHOD = "getModuleInfo";
public static final String MODULE_INFO_PROVIDER_PATH_PREFIX = "META-INF/services/";
- private ModuleInfoBackedContext moduleInfoLoadingStrategy = ModuleInfoBackedContext.create();
+ private final ModuleInfoBackedContext moduleInfoLoadingStrategy = ModuleInfoBackedContext.create();
public GeneratedClassLoadingStrategy getModuleInfoLoadingStrategy() {
return moduleInfoLoadingStrategy;
}
@Override
- public Collection<Registration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
+ public Collection<ObjectRegistration<YangModuleInfo>> addingBundle(Bundle bundle, BundleEvent event) {
URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName());
if(resource==null) {
return null;
}
- List<Registration<YangModuleInfo>> registrations = new LinkedList<>();
+ List<ObjectRegistration<YangModuleInfo>> registrations = new LinkedList<>();
try (InputStream inputStream = resource.openStream()) {
List<String> lines = IOUtils.readLines(inputStream);
}
@Override
- public void modifiedBundle(Bundle bundle, BundleEvent event, Collection<Registration<YangModuleInfo>> object) {
+ public void modifiedBundle(Bundle bundle, BundleEvent event, Collection<ObjectRegistration<YangModuleInfo>> object) {
// NOOP
}
@Override
- public void removedBundle(Bundle bundle, BundleEvent event, Collection<Registration<YangModuleInfo>> regs) {
+ public void removedBundle(Bundle bundle, BundleEvent event, Collection<ObjectRegistration<YangModuleInfo>> regs) {
if(regs == null) {
return;
}
- for (Registration<YangModuleInfo> reg : regs) {
+ for (ObjectRegistration<YangModuleInfo> reg : regs) {
try {
reg.close();
} catch (Exception e) {
private void assertSnapshot(ConfigSnapshotHolder result, String directory) throws Exception {
SortedSet<String> expectedCapabilities = new TreeSet<>(IOUtils.readLines(getClass().getResourceAsStream("/" + directory + "/expectedCapabilities.txt")));
String expectedSnapshot = IOUtils.toString(getClass().getResourceAsStream("/" + directory + "/expectedSnapshot.xml"));
+ expectedSnapshot = expectedSnapshot.replaceAll("\r","");
+ String _snapshot = result.getConfigSnapshot();
+ _snapshot = _snapshot.replaceAll("\r","");
assertEquals(expectedCapabilities, result.getCapabilities());
- assertEquals(expectedSnapshot, result.getConfigSnapshot());
+ assertEquals(expectedSnapshot, _snapshot);
}
}
}
public void started() {
- String schemeStr = System.getProperty("connection.scheme");
- for (ConnectionMgmtScheme scheme : ConnectionMgmtScheme.values()) {
- AbstractScheme schemeImpl = SchemeFactory.getScheme(scheme,
- clusterServices);
- if (schemeImpl != null) {
- schemes.put(scheme, schemeImpl);
- if (scheme.name().equalsIgnoreCase(schemeStr)) {
- activeScheme = scheme;
- }
- }
- }
connectionEventThread.start();
"ConnectionEvent Thread");
this.connectionEvents = new LinkedBlockingQueue<ConnectionMgmtEvent>();
schemes = new ConcurrentHashMap<ConnectionMgmtScheme, AbstractScheme>();
+
+ String schemeStr = System.getProperty("connection.scheme");
+ for (ConnectionMgmtScheme scheme : ConnectionMgmtScheme.values()) {
+ AbstractScheme schemeImpl = SchemeFactory.getScheme(scheme, clusterServices);
+ if (schemeImpl != null) {
+ schemes.put(scheme, schemeImpl);
+ if (scheme.name().equalsIgnoreCase(schemeStr)) {
+ activeScheme = scheme;
+ }
+ }
+ }
}
public void stopping() {
}
/*
- * Clustering Services' doesnt provide the existing states in the cache
+ * Clustering Services doesn't provide the existing states in the cache
* update callbacks. Hence, using a scratch local cache to maintain the
* existing state.
*/
return;
Set<InetAddress> existingControllers = existingConnections.get(node);
if (existingControllers != null) {
- logger.debug(
- "Processing Update for : {} NewControllers : {} existingControllers : {}",
- node, newControllers.toString(),
- existingControllers.toString());
+ logger.debug("Processing Update for : {} NewControllers : {} existingControllers : {}", node,
+ newControllers.toString(), existingControllers.toString());
if (newControllers.size() < existingControllers.size()) {
- Set<InetAddress> removed = new HashSet<InetAddress>(
- existingControllers);
+ Set<InetAddress> removed = new HashSet<InetAddress>(existingControllers);
if (removed.removeAll(newControllers)) {
logger.debug("notifyNodeDisconnectFromMaster({})", node);
notifyNodeDisconnectedEvent(node);
}
}
} else {
- logger.debug("Ignoring the Update for : {} NewControllers : {}",
- node, newControllers.toString());
+ logger.debug("Ignoring the Update for : {} NewControllers : {}", node, newControllers.toString());
}
existingConnections.put(node, newControllers);
}
public void entryDeleted(Node key, String cacheName, boolean originLocal) {
if (originLocal)
return;
- logger.debug("Deleted : {} cache : {}", key, cacheName);
+ logger.debug("Deleted entry {} from cache : {}", key, cacheName);
notifyNodeDisconnectedEvent(key);
}
allocateCaches();
retrieveCaches();
} else {
- log.error("Couldn't retrieve caches for scheme %s. Clustering service unavailable", name);
+ log.error("Couldn't retrieve caches for scheme {}. Clustering service unavailable", name);
}
}
log.error("An error occured",e);
}
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((nodeConnections == null) ? 0 : nodeConnections.hashCode());
+ result = prime * result + ((nodeConnectionsCacheName == null) ? 0 : nodeConnectionsCacheName.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof AbstractScheme)) {
+ return false;
+ }
+ AbstractScheme other = (AbstractScheme) obj;
+ if (name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!name.equals(other.name)) {
+ return false;
+ }
+ if (nodeConnections == null) {
+ if (other.nodeConnections != null) {
+ return false;
+ }
+ } else if (!nodeConnections.equals(other.nodeConnections)) {
+ return false;
+ }
+ if (nodeConnectionsCacheName == null) {
+ if (other.nodeConnectionsCacheName != null) {
+ return false;
+ }
+ } else if (!nodeConnectionsCacheName.equals(other.nodeConnectionsCacheName)) {
+ return false;
+ }
+ return true;
+ }
}
reference\:file\:../lib/slf4j-api-1.7.2.jar@1:start,\
reference\:file\:../lib/logback-classic-1.0.9.jar@1:start,\
reference\:file\:../lib/logback-core-1.0.9.jar@1:start,\
- reference\:file\:../lib/logging.bridge-0.4.1-SNAPSHOT@1:start,\
+ reference\:file\:../lib/logging.bridge-0.4.2-SNAPSHOT@1:start,\
reference\:file\:../lib/jersey-core-1.17.jar@2:start,\
reference\:file\:../lib/jersey-server-1.17.jar@2:start
* removes direct dependencies between providers and consumers.
*
* The Binding-aware broker is also responsible for translation from Java
- * classes modeling the functionality and data to binding-indpenedent form which
+ * classes modeling the functionality and data to binding-independent form which
* is used in SAL Core.
*
*
import org.opendaylight.yangtools.yang.binding.Notification;
public interface NotificationProviderService extends NotificationService, NotificationPublishService<Notification> {
-
-
- /**
- * Deprecated. Use {@link #publish(Notification)}.
- *
- * @param notification
- */
- @Deprecated
- void notify(Notification notification);
-
- /**
- * Deprecated. Use {@link #publish(Notification,ExecutorService)}.
- *
- * @param notification
- */
- @Deprecated
- void notify(Notification notification, ExecutorService service);
-
/**
* Publishes a notification.
*
import org.opendaylight.yangtools.yang.binding.Notification;
public interface NotificationService extends BindingAwareService {
- /**
- *
- * Deprecated: use {@link #addNotificationListener(Class, NotificationListener)} istead.
- *
- * @param listener
- */
- @Deprecated
- <T extends Notification> void addNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
-
- /**
- *
- * Deprecated: use {@link #addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener)} istead.
- *
- * @param listener
- */
- @Deprecated
- void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener);
-
- /**
- * Deprecated: use {@link Registration#close()} istead.
- * @param listener
- */
- @Deprecated
- void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener);
-
- /**
- * Deprecated: use {@link Registration#close()} istead.
- * @param listener
- */
- @Deprecated
- <T extends Notification> void removeNotificationListener(Class<T> notificationType, NotificationListener<T> listener);
-
-
/**
* Register a generic listener for specified notification type only.
*
<T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(
Class<T> notificationType, NotificationListener<T> listener);
-
/**
* Register a listener which implements generated notification interfaces derived from
* {@link org.opendaylight.yangtools.yang.binding.NotificationListener}.
public interface RpcConsumerRegistry extends BindingAwareService {
/**
* Returns a session specific instance (implementation) of requested
- * YANG module implentation / service provided by consumer.
+ * YANG module implementation / service provided by consumer.
*
* @return Session specific implementation of service
*/
RpcConsumerRegistry, //
RouteChangePublisher<RpcContextIdentifier, InstanceIdentifier<?>> {
/**
- * Registers an global RpcService implementation.
+ * Registers a global RpcService implementation.
*
* @param type
* @param implementation
/**
*
- * Register an Routed RpcService where routing is determined on annotated
+ * Register a Routed RpcService where routing is determined on annotated
* (in YANG model) context-reference and value of annotated leaf.
*
* @param type
* Type of RpcService, use generated interface class, not your
- * implementation clas
+ * implementation class
* @param implementation
* Implementation of RpcService
- * @return Registration object for routed Rpc which could be used to close
- * an
+ * @return Registration object for routed Rpc which could be used to unregister
*
* @throws IllegalStateException
*/
/**
* Synchronized wrapper for DataModificationTransaction.
- *
+ *
* To get instance of synchronized wrapper use {@link #from(DataModificationTransaction)}
*
*/
public final class SynchronizedTransaction implements DataModificationTransaction,Delegator<DataModificationTransaction> {
private final DataModificationTransaction delegate;
-
+
private SynchronizedTransaction(DataModificationTransaction delegate) {
this.delegate = delegate;
}
/**
* Returns synchronized wrapper on supplied transaction.
- *
+ *
* @param transaction Transaction for which synchronized wrapper should be created.
* @return Synchronized wrapper over transaction.
*/
return delegate.getUpdatedOperationalData();
}
- @Deprecated
- public synchronized void putRuntimeData(InstanceIdentifier<? extends DataObject> path, DataObject data) {
- delegate.putRuntimeData(path, data);
- }
-
@Override
public synchronized Object getIdentifier() {
return delegate.getIdentifier();
return delegate.getUpdatedConfigurationData();
}
- @Deprecated
- public synchronized void removeRuntimeData(InstanceIdentifier<? extends DataObject> path) {
- delegate.removeRuntimeData(path);
- }
-
@Override
public synchronized void removeOperationalData(InstanceIdentifier<? extends DataObject> path) {
delegate.removeOperationalData(path);
/**
* RpcRouter is responsible for selecting RpcService based on provided routing
* context identifier {@link RpcRoutingTable#getContextIdentifier()} and path in
- * overal data tree (@link {@link InstanceIdentifier}.
+ * overall data tree (@link {@link InstanceIdentifier}.
*
*
* @author Tony Tkacik <ttkacik@cisco.com>
this.executor = executor;\r
}\r
\r
- @Deprecated\r
- override <T extends Notification> addNotificationListener(Class<T> notificationType,\r
- NotificationListener<T> listener) {\r
- listeners.put(notificationType, listener)\r
- }\r
-\r
- @Deprecated\r
- override <T extends Notification> removeNotificationListener(Class<T> notificationType,\r
- NotificationListener<T> listener) {\r
- listeners.remove(notificationType, listener)\r
- }\r
-\r
- override notify(Notification notification) {\r
- publish(notification)\r
- }\r
-\r
def getNotificationTypes(Notification notification) {\r
notification.class.interfaces.filter[it != Notification && Notification.isAssignableFrom(it)]\r
}\r
\r
- @Deprecated\r
- override addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {\r
- throw new UnsupportedOperationException("Deprecated method. Use registerNotificationListener instead.");\r
-\r
- }\r
-\r
- @Deprecated\r
- override removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {\r
- throw new UnsupportedOperationException(\r
- "Deprecated method. Use RegisterNotificationListener returned value to close registration.")\r
- }\r
-\r
- @Deprecated\r
- override notify(Notification notification, ExecutorService service) {\r
- publish(notification, service)\r
- }\r
-\r
override publish(Notification notification) {\r
publish(notification, executor)\r
}\r
*/
package org.opendaylight.controller.sal.binding.impl;
-import static com.google.common.base.Preconditions.checkState;
-
-import java.util.EventListener;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.WeakHashMap;
-
import org.opendaylight.controller.md.sal.common.api.routing.RouteChange;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangeListener;
import org.opendaylight.controller.md.sal.common.api.routing.RouteChangePublisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.WeakHashMap;
+
+import static com.google.common.base.Preconditions.checkState;
+
public class RpcProviderRegistryImpl implements //
RpcProviderRegistry, //
RouteChangePublisher<RpcContextIdentifier, InstanceIdentifier<?>> {
private RuntimeCodeGenerator rpcFactory = SingletonHolder.RPC_GENERATOR_IMPL;
+ // publicProxies is a cache of proxy objects where each value in the map corresponds to a specific RpcService
private final Map<Class<? extends RpcService>, RpcService> publicProxies = new WeakHashMap<>();
private final Map<Class<? extends RpcService>, RpcRouter<?>> rpcRouters = new WeakHashMap<>();
private final ListenerRegistry<RouteChangeListener<RpcContextIdentifier, InstanceIdentifier<?>>> routeChangeListeners = ListenerRegistry
return getRpcRegistryChecked().getRpcService(module);
}
- @Override
- @Deprecated
- public <T extends Notification> void addNotificationListener(Class<T> notificationType,
- NotificationListener<T> listener) {
- getNotificationBrokerChecked().addNotificationListener(notificationType, listener);
- }
-
- @Override
- @Deprecated
- public void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- getNotificationBrokerChecked().addNotificationListener(listener);
- }
-
- @Override
- @Deprecated
- public void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- getNotificationBrokerChecked().removeNotificationListener(listener);
- }
-
- @Override
- @Deprecated
- public <T extends Notification> void removeNotificationListener(Class<T> notificationType,
- NotificationListener<T> listener) {
- getNotificationBrokerChecked().removeNotificationListener(notificationType, listener);
- }
-
@Override
public <T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(
Class<T> notificationType, NotificationListener<T> listener) {
return getRpcRegistryChecked().addRoutedRpcImplementation(type, implementation);
}
- @Override
- @Deprecated
- public void notify(Notification notification) {
- getNotificationBrokerChecked().notify(notification);
- }
-
- @Override
- @Deprecated
- public void notify(Notification notification, ExecutorService service) {
- getNotificationBrokerChecked().notify(notification, service);
- }
-
@Override
public void publish(Notification notification) {
getNotificationBrokerChecked().publish(notification);
import org.opendaylight.yangtools.yang.common.RpcResult;
public interface DataModification<P extends Path<P>, D> extends DataChange<P, D>, DataReader<P, D> {
-
/**
* Returns transaction identifier
*
TransactionStatus getStatus();
- /**
- *
- * @deprecated Use {@link #putOperationalData(Object, Object)} instead.
- *
- * @param path
- * @param data
- */
- @Deprecated
- void putRuntimeData(P path, D data);
-
/**
* Store a piece of data at specified path. This acts as a merge operation,
* which is to say that any pre-existing data which is not explicitly
*/
void putConfigurationData(P path, D data);
- /**
- * @deprecated Use {@link #removeOperationalData(Object)}
- *
- * @param path
- */
- @Deprecated
- void removeRuntimeData(P path);
-
void removeOperationalData(P path);
void removeConfigurationData(P path);
* {@link TransactionStatus#FAILED} is reached.
*/
Future<RpcResult<TransactionStatus>> commit();
-
}
private final Map<P, D> unmodifiable_operationalUpdate;
private final Set<P> unmodifiable_configurationRemove;
private final Set<P> unmodifiable_OperationalRemove;
- private DataReader<P, D> reader;
+ private final DataReader<P, D> reader;
public AbstractDataModification(DataReader<P, D> reader) {
this.reader = reader;
operationalUpdate.put(path, mergeOperationalData(path,original,data));
}
- @Override
- public final void putRuntimeData(P path, D data) {
- putOperationalData(path, data);
- }
-
@Override
public final void removeOperationalData(P path) {
checkMutable();
operationalRemove.put(path, path);
}
- @Override
- public final void removeRuntimeData(P path) {
- removeOperationalData(path);
- }
-
@Override
public final void removeConfigurationData(P path) {
checkMutable();
}
return null;
}
-
+
protected D mergeOperationalData(P path,D stored, D modified) {
return modified;
}
-
+
protected D mergeConfigurationData(P path,D stored, D modified) {
return modified;
}
import org.opendaylight.controller.sal.core.api.Provider;
import org.opendaylight.yangtools.yang.data.api.CompositeNode;
-
/**
* Notification Publishing Service
*
* <li>For each subscriber {@link Broker} invokes
* {@link NotificationListener#onNotification(CompositeNode)}
* </ol>
- *
- *
- *
*/
public interface NotificationPublishService extends NotificationService {
-
/**
* Publishes a notification.
*
* @param notification
* Notification to publish
*/
- @Deprecated
- void sendNotification(CompositeNode notification);
-
void publish(CompositeNode notification);
}
private final DataBrokerImpl dataReader;
private final NotificationRouter notificationRouter;
private final DataReader<InstanceIdentifier,CompositeNode> readWrapper;
-
-
+
+
private final InstanceIdentifier mountPath;
private SchemaContext schemaContext;
return dataReader.readOperationalData(path);
}
+ @Override
public Registration<DataReader<InstanceIdentifier, CompositeNode>> registerOperationalReader(
InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
return dataReader.registerOperationalReader(path, reader);
}
+ @Override
public Registration<DataReader<InstanceIdentifier, CompositeNode>> registerConfigurationReader(
InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
return dataReader.registerConfigurationReader(path, reader);
return rpcs.addRpcImplementation(rpcType, implementation);
}
+ @Override
public Set<QName> getSupportedRpcs() {
return rpcs.getSupportedRpcs();
}
-
+
+ @Override
public RpcResult<CompositeNode> invokeRpc(QName rpc, CompositeNode input) {
return rpcs.invokeRpc(rpc, input);
}
+ @Override
public ListenerRegistration<RpcRegistrationListener> addRpcRegistrationListener(RpcRegistrationListener listener) {
return rpcs.addRpcRegistrationListener(listener);
}
return dataReader.registerDataChangeListener(path, listener);
}
- @Override
- public void sendNotification(CompositeNode notification) {
- publish(notification);
- }
-
@Override
public Registration<DataCommitHandler<InstanceIdentifier, CompositeNode>> registerCommitHandler(
InstanceIdentifier path, DataCommitHandler<InstanceIdentifier, CompositeNode> commitHandler) {
return dataReader.registerCommitHandler(path, commitHandler);
}
-
+
@Override
public void removeRefresher(DataStoreIdentifier store, DataRefresher refresher) {
// NOOP
}
-
+
@Override
public void addRefresher(DataStoreIdentifier store, DataRefresher refresher) {
// NOOP
}
-
+
@Override
public void addValidator(DataStoreIdentifier store, DataValidator validator) {
// NOOP
public void removeValidator(DataStoreIdentifier store, DataValidator validator) {
// NOOP
}
-
+
+ @Override
public SchemaContext getSchemaContext() {
return schemaContext;
}
+ @Override
public void setSchemaContext(SchemaContext schemaContext) {
this.schemaContext = schemaContext;
}
class ReadWrapper implements DataReader<InstanceIdentifier, CompositeNode> {
-
-
+
+
private InstanceIdentifier shortenPath(InstanceIdentifier path) {
InstanceIdentifier ret = null;
if(mountPath.contains(path)) {
}
return ret;
}
-
+
@Override
public CompositeNode readConfigurationData(InstanceIdentifier path) {
InstanceIdentifier newPath = shortenPath(path);
}
return MountPointImpl.this.readConfigurationData(newPath);
}
-
+
@Override
public CompositeNode readOperationalData(InstanceIdentifier path) {
InstanceIdentifier newPath = shortenPath(path);
NotificationPublishService {
@Override
- public void sendNotification(CompositeNode notification) {
+ public void publish(CompositeNode notification) {
checkSessionState();
if (notification == null)
throw new IllegalArgumentException(
"Notification must not be null.");
NotificationModule.this.sendNotification(notification);
}
-
- @Override
- public void publish(CompositeNode notification) {
- sendNotification(notification);
- }
}
@Override
super(ref, delegate);
}
- public void sendNotification(CompositeNode notification) {
- getDelegate().sendNotification(notification);
- }
-
+ @Override
public Registration<NotificationListener> addNotificationListener(QName notification, NotificationListener listener) {
return addRegistration(getDelegate().addNotificationListener(notification, listener));
}
+ @Override
public void publish(CompositeNode notification) {
getDelegate().publish(notification);
}
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.ExecutorService;
import org.opendaylight.controller.sal.binding.api.NotificationListener;
import org.opendaylight.controller.sal.binding.api.NotificationService;
import org.opendaylight.controller.sal.restconf.broker.tools.RemoteStreamTools;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.QName;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.remote.rev140114.SalRemoteService;
+import org.opendaylight.yangtools.concepts.AbstractListenerRegistration;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.restconf.client.api.RestconfClientContext;
import org.opendaylight.yangtools.restconf.client.api.event.EventStreamInfo;
import org.opendaylight.yangtools.yang.binding.Notification;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import com.google.common.collect.Multimaps;
-import com.google.common.collect.SetMultimap;
-
public class NotificationServiceImpl implements NotificationService {
private final SalRemoteService salRemoteService;
private final RestconfClientContext restconfClientContext;
- private final Multimap<Class<? extends Notification>,NotificationListener<? extends Object>> listeners;
- private ExecutorService _executor;
-
public NotificationServiceImpl(RestconfClientContext restconfClienetContext){
this.restconfClientContext = restconfClienetContext;
this.salRemoteService = this.restconfClientContext.getRpcServiceContext(SalRemoteService.class).getRpcService();
-
- HashMultimap<Class<? extends Notification>,NotificationListener<? extends Object>> _create = HashMultimap.<Class<? extends Notification>, NotificationListener<? extends Object>>create();
- SetMultimap<Class<? extends Notification>,NotificationListener<? extends Object>> _synchronizedSetMultimap = Multimaps.<Class<? extends Notification>, NotificationListener<? extends Object>>synchronizedSetMultimap(_create);
- this.listeners = _synchronizedSetMultimap;
-
- }
- public ExecutorService getExecutor() {
- return this._executor;
- }
-
- public void setExecutor(final ExecutorService executor) {
- this._executor = executor;
- }
-
- @Override
- public <T extends Notification> void addNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
- this.listeners.put(notificationType, listener);
- }
-
- @Override
- public void addNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException("Deprecated method. Use registerNotificationListener instead.");
- throw _unsupportedOperationException;
- }
-
- @Override
- public void removeNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
- UnsupportedOperationException _unsupportedOperationException = new UnsupportedOperationException(
- "Deprecated method. Use RegisterNotificationListener returned value to close registration.");
- throw _unsupportedOperationException;
}
@Override
- public <T extends Notification> void removeNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
- this.listeners.remove(notificationType, listener);
- }
-
- @Override
- public <T extends Notification> Registration<NotificationListener<T>> registerNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
+ public <T extends Notification> ListenerRegistration<NotificationListener<T>> registerNotificationListener(Class<T> notificationType, NotificationListener<T> listener) {
//TODO implementation using sal-remote
List<QName> notifications = new ArrayList<QName>();
notifications.add(new QName(notificationType.toString()));
String notificationStreamName = RemoteStreamTools.createNotificationStream(salRemoteService, notifications);
final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext, notificationStreamName);
RemoteNotificationListener remoteNotificationListener = new RemoteNotificationListener(listener);
- ListenerRegistration<?> listenerRegistration = restconfClientContext.getEventStreamContext(desiredEventStream.get(desiredEventStream.get(notificationStreamName))).registerNotificationListener(remoteNotificationListener);
- return new SalNotificationRegistration<T>(listenerRegistration);
+
+ final ListenerRegistration<?> listenerRegistration = restconfClientContext.getEventStreamContext(desiredEventStream.get(desiredEventStream.get(notificationStreamName)))
+ .registerNotificationListener(remoteNotificationListener);
+
+ return new AbstractListenerRegistration<NotificationListener<T>>(listener) {
+ @Override
+ protected void removeRegistration() {
+ listenerRegistration.close();
+ }
+ };
}
@Override
- public Registration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
+ public ListenerRegistration<org.opendaylight.yangtools.yang.binding.NotificationListener> registerNotificationListener(org.opendaylight.yangtools.yang.binding.NotificationListener listener) {
//TODO implementation using sal-remote
String notificationStreamName = RemoteStreamTools.createNotificationStream(salRemoteService, null);
final Map<String,EventStreamInfo> desiredEventStream = RemoteStreamTools.createEventStream(restconfClientContext, notificationStreamName);
return restconfClientContext.getEventStreamContext(desiredEventStream.get(desiredEventStream.get(notificationStreamName))).registerNotificationListener(listener);
}
-
- private class SalNotificationRegistration<T extends Notification> implements Registration<NotificationListener<T>>{
- private final Registration<?> registration;
-
- public SalNotificationRegistration(ListenerRegistration<?> listenerRegistration){
- this.registration = listenerRegistration;
- }
-
- @Override
- public NotificationListener<T> getInstance() {
- return this.getInstance();
- }
-
- @Override
- public void close() throws Exception {
- this.registration.close();
- }
- }
-
-
}
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Future;
+
import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
return null;
}
- @Override
- public void putRuntimeData(InstanceIdentifier<? extends DataObject> path, DataObject data) {
-
- }
-
@Override
public void putOperationalData(InstanceIdentifier<? extends DataObject> path, DataObject data) {
}
- @Override
- public void removeRuntimeData(InstanceIdentifier<? extends DataObject> path) {
-
- }
-
@Override
public void removeOperationalData(InstanceIdentifier<? extends DataObject> path) {
package org.opendaylight.controller.sample.toaster.provider;
import java.util.Collections;
-
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.opendaylight.controller.config.yang.config.toaster_provider.impl.ToasterProviderRuntimeMXBean;
import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
-import org.opendaylight.controller.sal.common.util.Futures;
import org.opendaylight.controller.sal.common.util.Rpcs;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.DisplayString;
import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.util.concurrent.Futures;
+
public class OpendaylightToaster implements ToasterData, ToasterService, ToasterProviderRuntimeMXBean {
private static final Logger log = LoggerFactory.getLogger(OpendaylightToaster.class);
private static final DisplayString toasterManufacturer = new DisplayString("Opendaylight");
private static final DisplayString toasterModelNumber = new DisplayString("Model 1 - Binding Aware");
- private ToasterStatus toasterStatus;
+ private final ToasterStatus toasterStatus;
private NotificationProviderService notificationProvider;
private final ExecutorService executor;
currentTask.cancel(true);
ToastDoneBuilder toastDone = new ToastDoneBuilder();
toastDone.setToastStatus(ToastStatus.Cancelled);
- notificationProvider.notify(toastDone.build());
+ notificationProvider.publish(toastDone.build());
}
public void setNotificationProvider(NotificationProviderService salService) {
ToastDoneBuilder notifyBuilder = new ToastDoneBuilder();
notifyBuilder.setToastStatus(ToastStatus.Done);
- notificationProvider.notify(notifyBuilder.build());
+ notificationProvider.publish(notifyBuilder.build());
log.trace("Toast Done");
logToastInput(toastRequest);
currentTask = null;
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>app-northbound</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+
+ <name>app-northbound</name>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.2</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="app"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>.settings</directory>
+ <includes>
+ <include>**/*.prefs</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory></directory>
+ <includes>
+ <include>.classpath</include>
+ <include>.project</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
--- /dev/null
+#set( $dollar = '$' )
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.opendaylight</artifactId>
+ <version>1.4.1-SNAPSHOT</version>
+ <relativePath>../../commons/opendaylight</relativePath>
+ </parent>
+
+ <artifactId>${artifactId}</artifactId>
+
+ <groupId>${groupId}</groupId>
+ <packaging>bundle</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${bundle.plugin.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package></Export-Package>
+ <Import-Package>org.opendaylight.controller.northbound.commons,
+ com.sun.jersey.spi.container.servlet,
+ com.fasterxml.jackson.annotation,
+ javax.ws.rs,
+ javax.ws.rs.core,
+ javax.xml.bind,
+ javax.xml.bind.annotation,
+ org.slf4j,
+ org.apache.catalina.filters,
+ com.fasterxml.jackson.jaxrs.base,
+ com.fasterxml.jackson.jaxrs.json,
+ !org.codehaus.enunciate.jaxrs</Import-Package>
+ <Web-ContextPath>/northbound/${artifactId}</Web-ContextPath>
+ <Jaxrs-Resources>,${dollar}{classes;ANNOTATION;javax.ws.rs.Path}</Jaxrs-Resources>
+ </instructions>
+ <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <version>${version}</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.enunciate</groupId>
+ <artifactId>enunciate-core-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>commons.northbound</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ </dependencies>
+</project>
--- /dev/null
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package ${package};
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.SecurityContext;
+
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.codehaus.enunciate.jaxrs.TypeHint;
+
+/**
+ * Northbound REST API
+ *
+ * <br>
+ * <br>
+ * Authentication scheme : <b>HTTP Basic</b><br>
+ * Authentication realm : <b>opendaylight</b><br>
+ * Transport : <b>HTTP and HTTPS</b><br>
+ * <br>
+ * HTTPS Authentication is disabled by default.
+ */
+
+@Path("/")
+public class Northbound {
+
+ private String username;
+
+ @Context
+ public void setSecurityContext(SecurityContext context) {
+ if (context != null && context.getUserPrincipal() != null) {
+ username = context.getUserPrincipal().getName();
+ }
+ }
+
+ /**
+ *
+ * Sample REST API call
+ *
+ * @return A response string
+ *
+ * <pre>
+ * Example:
+ *
+ * Request URL:
+ * http://localhost:8080/northbound/${artifactId}/api
+ *
+ * Response body in XML:
+ * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ * Sample Northbound API
+ *
+ * Response body in JSON:
+ * Sample Northbound API
+ * </pre>
+ */
+ @Path("/api")
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ @TypeHint(String.class)
+ @StatusCodes()
+ public String getWidget() {
+ String result = "Sample Northbound API - ${artifactId}";
+ return result;
+ }
+
+}
--- /dev/null
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+ <servlet>
+ <servlet-name>JAXRS${artifactId}</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <param-name>javax.ws.rs.Application</param-name>
+ <param-value>org.opendaylight.controller.northbound.commons.NorthboundApplication</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>JAXRS${artifactId}</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <filter>
+ <filter-name>CorsFilter</filter-name>
+ <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
+ <init-param>
+ <param-name>cors.allowed.origins</param-name>
+ <param-value>*</param-value>
+ </init-param>
+ <init-param>
+ <param-name>cors.allowed.methods</param-name>
+ <param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE</param-value>
+ </init-param>
+ <init-param>
+ <param-name>cors.allowed.headers</param-name>
+ <param-value>Content-Type,X-Requested-With,accept,authorization, origin,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
+ </init-param>
+ <init-param>
+ <param-name>cors.exposed.headers</param-name>
+ <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
+ </init-param>
+ <init-param>
+ <param-name>cors.support.credentials</param-name>
+ <param-value>true</param-value>
+ </init-param>
+ <init-param>
+ <param-name>cors.preflight.maxage</param-name>
+ <param-value>10</param-value>
+ </init-param>
+ </filter>
+ <filter-mapping>
+ <filter-name>CorsFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>${artifactId}</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ <http-method>POST</http-method>
+ <http-method>GET</http-method>
+ <http-method>PUT</http-method>
+ <http-method>PATCH</http-method>
+ <http-method>DELETE</http-method>
+ <http-method>HEAD</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>System-Admin</role-name>
+ <role-name>Network-Admin</role-name>
+ <role-name>Network-Operator</role-name>
+ <role-name>Container-User</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <security-role>
+ <role-name>System-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Network-Operator</role-name>
+ </security-role>
+ <security-role>
+ <role-name>Container-User</role-name>
+ </security-role>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>opendaylight</realm-name>
+ </login-config>
+</web-app>
--- /dev/null
+#Fri Mar 07 21:17:20 CST 2014
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
moveToReadyListHi(dst);
}
+ //checking only OF map, since production edge discovery always overwrites any existing edge
+ UpdateType ut = edgeMap.containsKey(dst) ? UpdateType.CHANGED : UpdateType.ADDED;
// notify
- updateEdge(edge, UpdateType.ADDED, props);
+ updateEdge(edge, ut, props);
logger.trace("Add edge {}", edge);
}
return;
}
+
this.discoveryListener.notifyEdge(edge, type, props);
NodeConnector src = edge.getTailNodeConnector(), dst = edge.getHeadNodeConnector();
/**
* The class represents an Edge, the Edge's Property Set and its UpdateType.
+ * If update is on new properties added to an existing edge, appropriate type is CHANGED.
*/
public class TopoEdgeUpdate {
private Edge edge;
*/
public static boolean isMulticastMACAddr(byte[] MACAddress) {
if (MACAddress.length == MACAddrLengthInBytes && !isBroadcastMACAddr(MACAddress)) {
- if (MACAddress[0] % 2 == 1) {
- return true;
- }
+ return (MACAddress[0] & 1) != 0;
}
return false;
}
Assert.assertEquals(32768, NetUtils.getUnsignedShort((short) 0x8000));
Assert.assertEquals(65535, NetUtils.getUnsignedShort((short) 0xffff));
}
+
+ @Test
+ public void testMulticastMACAddr() {
+ byte[] empty = new byte[0];
+ Assert.assertFalse(NetUtils.isUnicastMACAddr(empty));
+ Assert.assertFalse(NetUtils.isMulticastMACAddr(empty));
+
+ byte[] bcast = {
+ (byte)0xff, (byte)0xff, (byte)0xff,
+ (byte)0xff, (byte)0xff, (byte)0xff,
+ };
+ Assert.assertFalse(NetUtils.isUnicastMACAddr(bcast));
+ Assert.assertFalse(NetUtils.isMulticastMACAddr(bcast));
+
+ byte[] firstOctet = {
+ (byte)0x00, (byte)0x20, (byte)0x80, (byte)0xfe,
+ };
+ for (int len = 1; len <= 10; len++) {
+ byte[] ba = new byte[len];
+ boolean valid = (len == 6);
+ for (byte first: firstOctet) {
+ ba[0] = first;
+ Assert.assertFalse(NetUtils.isMulticastMACAddr(ba));
+ Assert.assertEquals(valid, NetUtils.isUnicastMACAddr(ba));
+
+ ba[0] |= (byte)0x01;
+ Assert.assertEquals(valid, NetUtils.isMulticastMACAddr(ba));
+ Assert.assertFalse(NetUtils.isUnicastMACAddr(ba));
+ }
+ }
+ }
}
switch (type) {
case ADDED:
+
+ if (this.edgesDB.containsKey(e)) {
+ // Avoid redundant updates (e.g. cluster switch-over) as notifications trigger expensive tasks
+ log.trace("Skipping redundant edge addition: {}", e);
+ return null;
+ }
+
// Make sure the props are non-null or create a copy
if (props == null) {
props = new HashSet<Property>();
props = new HashSet<Property>(props);
}
- Set<Property> currentProps = this.edgesDB.get(e);
- if (currentProps != null) {
-
- if (currentProps.equals(props)) {
- // Avoid redundant updates as notifications trigger expensive tasks
- log.trace("Skipping redundant edge addition: {}", e);
- return null;
- }
-
- // In case of node switch-over to a different cluster controller,
- // let's retain edge props (e.g. creation time)
- props.addAll(currentProps);
- }
// Ensure that head node connector exists
if (!headNodeConnectorExist(e)) {
case CHANGED:
Set<Property> oldProps = this.edgesDB.get(e);
- // When property changes lets make sure we can change it
+ // When property(s) changes lets make sure we can change it
// all except the creation time stamp because that should
- // be changed only when the edge is destroyed and created
- // again
+ // be set only when the edge is created
TimeStamp timeStamp = null;
for (Property prop : oldProps) {
if (prop instanceof TimeStamp) {
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.opendaylight.controller.connectionmanager.IConnectionManager;
import org.opendaylight.controller.forwarding.staticrouting.IForwardingStaticRouting;
import org.opendaylight.controller.forwarding.staticrouting.StaticRouteConfig;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
for (NodeConnector nodeConnector : nodeConnectorSet) {
String nodeConnectorNumberToStr = nodeConnector.getID().toString();
Name ncName = ((Name) switchManager.getNodeConnectorProp(nodeConnector, Name.NamePropName));
- Config portStatus = ((Config) switchManager.getNodeConnectorProp(nodeConnector,
+ Config portConfig = ((Config) switchManager.getNodeConnectorProp(nodeConnector,
Config.ConfigPropName));
State portState = ((State) switchManager.getNodeConnectorProp(nodeConnector,
State.StatePropName));
String nodeConnectorName = (ncName != null) ? ncName.getValue() : "";
nodeConnectorName += " (" + nodeConnector.getID() + ")";
- if (portStatus != null) {
- if (portStatus.getValue() == Config.ADMIN_UP) {
- if (portState.getValue() == State.EDGE_UP) {
+ if (portConfig != null) {
+ if (portConfig.getValue() == Config.ADMIN_UP) {
+ if (portState != null && portState.getValue() == State.EDGE_UP) {
nodeConnectorName = "<span class='admin-up'>" + nodeConnectorName + "</span>";
- } else if (portState.getValue() == State.EDGE_DOWN) {
+ } else if (portState == null || portState.getValue() == State.EDGE_DOWN) {
nodeConnectorName = "<span class='edge-down'>" + nodeConnectorName + "</span>";
}
- } else if (portStatus.getValue() == Config.ADMIN_DOWN) {
+ } else if (portConfig.getValue() == Config.ADMIN_DOWN) {
nodeConnectorName = "<span class='admin-down'>" + nodeConnectorName + "</span>";
}
}