SDN Controller Programming Guide

158
Figure 53 Controller-Controller Communication via REST (Sideway API)
For example assume there is a need to retrieve all the open flow switches controlled by a remote
system. A sideway (or transfer) API could be defined to take care of such communication as shown
in the following listing.
SwitchTransferService.java:
package com.hp.hm.api;
...
public interface SwitchTransferService {
public Set<Switch> getControlledDevices(IpAddress system);
}
The following listing shows an extract of the communication service implementation using the
facilities provided by the HP VAN SDN Controller framework to handle HTTP requests and
responses.
SwitchTransferManager.java:
package com.hp.hm.impl;
import javax.ws.rs.core.Response.Status;
import com.hp.hm.api.SwitchTransferService;
import com.hp.sdn.json.JsonService;
import com.hp.sdn.misc.ResponseData;
import com.hp.sdn.misc.ServiceRest;
import com.hp.util.StringUtils;
...
@Component
@Service
public class SwitchTransferManager implements SwitchTransferService {
// Some specific dependencies (like javax.ws.rs.core.Response) are needed
// to implement transfer services that use RESTful web services as the
// underlying mechanism to achieve communication. It is recommended to
// locate transfer services in a separated module.
static final String BASE_DESTINATION_PATH = "sdn/hm/v1.0/switches";