Reference Guide

Table Of Contents
Using SDN Controller Services
In the following information some of the services provided by the HP VAN SDN Controller will be
consumed to illustrate the philosophy followed by the controller: OSGi declarative services as
depicted in section Consuming Services with OSGi Declarative Services on page 166.
Services published by the controller are meant to be consumed by the application’s business logic.
Some services are available to the RESTful web services, however, as depicted in Domain Service -
REST API Integration o n p a g e 18 0 , web services should not implement any logic but controller
logic. Thus, it is considered a good practice to always delegate to the business logic.
At this point RESTful web services and business logic are fully integrated. A simple in-memory data
structure will be used to store OpenFlow switches data. The following listings illustrate the complete
implementation of SwitchManager and SwitchResource that will be used to consume HP VAN SDN
Controller services. These implementations allow the REST API to be functional for small transient
data (Filtering and sorting still pending).
NOTE
Synchronization on the in
-memory data structure and the fact that
Switch
is a mutable class have been
intentionally ignored. Even though it is important to consider the mult
i-threaded environment nature
of
RESTful web services and data protection (since the same references from the in
-
memory data store are
returned by the busi
ness logic) they are irrelevant for the purpose of the illustration
: Consuming services
published by the controller. A more serious implementation would make use of the synchronization
tools offered by Java and make copies of the objects be
fore they are re
turned (Adding a copy
constructor in
Switch
for example) or even better, use a database
. Complicated code is avoided for
illustration purposes.
SwitchManager.java In-Memory Data Storage:
package com.hp.hm.impl;
...
public class SwitchManager implements SwitchService {
@SuppressWarnings("unused")
private final SystemInformationService systemInformationService;
@SuppressWarnings("unused")
private AlertService alertService;
private Map<Id<Switch, UUID>, Switch> devices;
private AtomicLong idCount;
public SwitchManager(SystemInformationService systemInformationService) {
if (systemInformationService == null) {
throw new NullPointerException(...);
}
this.systemInformationService = systemInformationService;
208