Class HttpSBControllerImpl

  • All Implemented Interfaces:
    HttpSBController

    public class HttpSBControllerImpl
    extends java.lang.Object
    implements HttpSBController
    The implementation of HttpSBController.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static java.lang.String COLON  
      protected static java.lang.String DOUBLESLASH  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addDevice​(RestSBDevice device)
      Adds a device to the device map.
      int cancelServerSentEvents​(org.onosproject.net.DeviceId deviceId)
      Cancels a Server Sent Events listener to a device.
      int delete​(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)
      Does a HTTP DELETE request with specified parameters to the device.
      java.io.InputStream get​(org.onosproject.net.DeviceId device, java.lang.String request, javax.ws.rs.core.MediaType mediaType)
      Does a HTTP GET request with specified parameters to the device.
      java.util.Map<org.onosproject.net.DeviceId,​javax.ws.rs.client.Client> getClientMap()  
      RestSBDevice getDevice​(org.onlab.packet.IpAddress ip, int port)
      Returns a device by Ip and Port.
      RestSBDevice getDevice​(org.onosproject.net.DeviceId deviceInfo)
      Returns a device by node identifier.
      java.util.Map<org.onosproject.net.DeviceId,​RestSBDevice> getDeviceMap()  
      java.util.Map<org.onosproject.net.DeviceId,​RestSBDevice> getDevices()
      Returns all the devices known to this controller.
      int getServerSentEvents​(org.onosproject.net.DeviceId deviceId, java.lang.String request, java.util.function.Consumer<javax.ws.rs.sse.InboundSseEvent> onEvent, java.util.function.Consumer<java.lang.Throwable> onError)
      Does a HTTP GET against a Server Sent Events (SSE_INBOUND) resource on the device.
      java.util.Map<org.onosproject.net.DeviceId,​javax.ws.rs.sse.SseEventSource> getSseEventSourceMap()  
      protected java.lang.String getUrlString​(org.onosproject.net.DeviceId deviceId, java.lang.String request)  
      protected javax.ws.rs.client.WebTarget getWebTarget​(org.onosproject.net.DeviceId device, java.lang.String request)  
      int patch​(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)
      Does a HTTP PATCH request with specified parameters to the device.
      int post​(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)
      Does a HTTP POST request with specified parameters to the device.
      <T> T post​(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType, java.lang.Class<T> responseClass)
      Does a HTTP POST request with specified parameters to the device and extracts an object of type T from the response entity field.
      int put​(org.onosproject.net.DeviceId device, java.lang.String request, java.io.InputStream payload, javax.ws.rs.core.MediaType mediaType)
      Does a HTTP PUT request with specified parameters to the device.
      void removeDevice​(org.onosproject.net.DeviceId deviceId)
      Removes the device from the devices map.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpSBControllerImpl

        public HttpSBControllerImpl()
    • Method Detail

      • getDeviceMap

        public java.util.Map<org.onosproject.net.DeviceId,​RestSBDevice> getDeviceMap()
      • getClientMap

        public java.util.Map<org.onosproject.net.DeviceId,​javax.ws.rs.client.Client> getClientMap()
      • getSseEventSourceMap

        public java.util.Map<org.onosproject.net.DeviceId,​javax.ws.rs.sse.SseEventSource> getSseEventSourceMap()
      • getDevices

        public java.util.Map<org.onosproject.net.DeviceId,​RestSBDevice> getDevices()
        Description copied from interface: HttpSBController
        Returns all the devices known to this controller.
        Specified by:
        getDevices in interface HttpSBController
        Returns:
        map of devices
      • getDevice

        public RestSBDevice getDevice​(org.onosproject.net.DeviceId deviceInfo)
        Description copied from interface: HttpSBController
        Returns a device by node identifier.
        Specified by:
        getDevice in interface HttpSBController
        Parameters:
        deviceInfo - node identifier
        Returns:
        RestSBDevice rest device
      • getDevice

        public RestSBDevice getDevice​(org.onlab.packet.IpAddress ip,
                                      int port)
        Description copied from interface: HttpSBController
        Returns a device by Ip and Port.
        Specified by:
        getDevice in interface HttpSBController
        Parameters:
        ip - device ip
        port - device port
        Returns:
        RestSBDevice rest device
      • removeDevice

        public void removeDevice​(org.onosproject.net.DeviceId deviceId)
        Description copied from interface: HttpSBController
        Removes the device from the devices map.
        Specified by:
        removeDevice in interface HttpSBController
        Parameters:
        deviceId - to be removed
      • post

        public int post​(org.onosproject.net.DeviceId device,
                        java.lang.String request,
                        java.io.InputStream payload,
                        javax.ws.rs.core.MediaType mediaType)
        Description copied from interface: HttpSBController
        Does a HTTP POST request with specified parameters to the device.
        Specified by:
        post in interface HttpSBController
        Parameters:
        device - device to make the request to
        request - url of the request
        payload - payload of the request as an InputStream
        mediaType - type of content in the payload i.e. application/json
        Returns:
        status Commonly used status codes defined by HTTP
      • post

        public <T> T post​(org.onosproject.net.DeviceId device,
                          java.lang.String request,
                          java.io.InputStream payload,
                          javax.ws.rs.core.MediaType mediaType,
                          java.lang.Class<T> responseClass)
        Description copied from interface: HttpSBController
        Does a HTTP POST request with specified parameters to the device and extracts an object of type T from the response entity field.
        Specified by:
        post in interface HttpSBController
        Type Parameters:
        T - post return type
        Parameters:
        device - device to make the request to
        request - url of the request
        payload - payload of the request as an InputStream
        mediaType - type of content in the payload i.e. application/json
        responseClass - the type of response object we are interested in, such as String, InputStream.
        Returns:
        Object of type requested via responseClass.
      • put

        public int put​(org.onosproject.net.DeviceId device,
                       java.lang.String request,
                       java.io.InputStream payload,
                       javax.ws.rs.core.MediaType mediaType)
        Description copied from interface: HttpSBController
        Does a HTTP PUT request with specified parameters to the device.
        Specified by:
        put in interface HttpSBController
        Parameters:
        device - device to make the request to
        request - resource path of the request
        payload - payload of the request as an InputStream
        mediaType - type of content in the payload i.e. application/json
        Returns:
        status Commonly used status codes defined by HTTP
      • get

        public java.io.InputStream get​(org.onosproject.net.DeviceId device,
                                       java.lang.String request,
                                       javax.ws.rs.core.MediaType mediaType)
        Description copied from interface: HttpSBController
        Does a HTTP GET request with specified parameters to the device.
        Specified by:
        get in interface HttpSBController
        Parameters:
        device - device to make the request to
        request - url of the request
        mediaType - format to retrieve the content in
        Returns:
        an inputstream of data from the reply.
      • patch

        public int patch​(org.onosproject.net.DeviceId device,
                         java.lang.String request,
                         java.io.InputStream payload,
                         javax.ws.rs.core.MediaType mediaType)
        Description copied from interface: HttpSBController
        Does a HTTP PATCH request with specified parameters to the device.
        Specified by:
        patch in interface HttpSBController
        Parameters:
        device - device to make the request to
        request - url of the request
        payload - payload of the request as an InputStream
        mediaType - format to retrieve the content in
        Returns:
        status Commonly used status codes defined by HTTP
      • delete

        public int delete​(org.onosproject.net.DeviceId device,
                          java.lang.String request,
                          java.io.InputStream payload,
                          javax.ws.rs.core.MediaType mediaType)
        Description copied from interface: HttpSBController
        Does a HTTP DELETE request with specified parameters to the device.
        Specified by:
        delete in interface HttpSBController
        Parameters:
        device - device to make the request to
        request - url of the request
        payload - payload of the request as an InputStream
        mediaType - type of content in the payload i.e. application/json
        Returns:
        status Commonly used status codes defined by HTTP
      • getServerSentEvents

        public int getServerSentEvents​(org.onosproject.net.DeviceId deviceId,
                                       java.lang.String request,
                                       java.util.function.Consumer<javax.ws.rs.sse.InboundSseEvent> onEvent,
                                       java.util.function.Consumer<java.lang.Throwable> onError)
        Description copied from interface: HttpSBController
        Does a HTTP GET against a Server Sent Events (SSE_INBOUND) resource on the device. This is a low level function that can take callbacks. For a higher level function that emits events based on this callback see startServerSentEvents() in the RestSBController
        Specified by:
        getServerSentEvents in interface HttpSBController
        Parameters:
        deviceId - device to make the request to
        request - url of the request
        onEvent - A consumer of inbound SSE_INBOUND events
        onError - A consumer of inbound SSE_INBOUND errors
        Returns:
        status Commonly used status codes defined by HTTP
      • cancelServerSentEvents

        public int cancelServerSentEvents​(org.onosproject.net.DeviceId deviceId)
        Description copied from interface: HttpSBController
        Cancels a Server Sent Events listener to a device.
        Specified by:
        cancelServerSentEvents in interface HttpSBController
        Parameters:
        deviceId - device to cancel the listener for
        Returns:
        status Commonly used status codes defined by HTTP
      • getWebTarget

        protected javax.ws.rs.client.WebTarget getWebTarget​(org.onosproject.net.DeviceId device,
                                                            java.lang.String request)
      • getUrlString

        protected java.lang.String getUrlString​(org.onosproject.net.DeviceId deviceId,
                                                java.lang.String request)