com.h3c.sdn.adm.role

## Interface RoleService

-     public interface RoleService

  Service which indicates the role of a controller in relation to its controlled entities. The role personality is conveyed based on the region configuration and any runtime changes of the role due to failover. Note that "System" and "Controller" are used interchangeably in this documentation.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addListener(RoleListener roleListener)` Subscribe to Role change notifications by supplying a `RoleListener` callback implementation.
    `ControllerRole` | `getCurrentRole(ControllerNode controller, IpAddress deviceIp)` Returns the role that the given controller is playing in relation to the specified network element.
    `ControllerNode` | `getMaster(DataPathId dpid)` Returns the controller which is playing the role of MASTER to the given controlled entity.
    `ControllerNode` | `getMaster(DataPathId dpid, boolean teamAware)` Returns the controller which is playing the MASTER role in relation to the given datapath, which need not be necessarily of the local controller.
    `ControllerNode` | `getMaster(IpAddress deviceIp)` Returns the controller which is playing the role of MASTER to the given controlled entity(switch etc).
    `Set<IpAddress>` | `getMasterElements(ControllerNode controller)` Returns list of controlled entities to which the given controller is playing the role of MASTER.
    `Set<IpAddress>` | `getSlaveElements(ControllerNode controller)` Returns list of controlled entities to which the given controller is playing the role of SLAVE.
    `Set<ControllerNode>` | `getSlaves(IpAddress deviceIp)` Returns the controller which are playing the role of SLAVE to the given controlled entity(switch etc).
    `Boolean` | `isMaster(DataPathId dpid)` Indicates if the LOCAL system is the master for the given datapath.
    `boolean` | `isSelfEqual(IpAddress deviceIp)`
    `void` | `removeListener(RoleListener roleListener)` Express withdrawal from the Role change notification by specifying the RoleListener implementation that was used while subscribing.

- - ### Method Detail

    - #### getCurrentRole

          ControllerRole getCurrentRole(ControllerNode controller,
                                      IpAddress deviceIp)

      Returns the role that the given controller is playing in relation to the specified network element.
      Parameters:
        `controller` - the controller whose role has to be determined
        `deviceIp` - the IpAddress of switch to which the controller is associated with
      Returns:
        current controller role

    - #### getMaster

          ControllerNode getMaster(IpAddress deviceIp)

      Returns the controller which is playing the role of MASTER to the given controlled entity(switch etc).
      Parameters:
        `deviceIp` - representing the IpAddress of the switch which the respective controller playing the ControllerRole.MASTER role is to be determined
      Returns:
        IpAddress of the controller which is playing the MASTER role

    - #### getMaster

          ControllerNode getMaster(DataPathId dpid)

      Returns the controller which is playing the role of MASTER to the given controlled entity. If the consumer of the service is cognizant of the fact that a given DataPathId can only emanate from the local controller, then use variant `isMaster`.
      Parameters:
        `dpid` - representing the controlled entity in relation to which the respective controller playing the ControllerRole.MASTER role is to be determined
      Returns:
        ControllerNode which is playing the MASTER role

    - #### getMaster

          ControllerNode getMaster(DataPathId dpid,
                                 boolean teamAware)

      Returns the controller which is playing the MASTER role in relation to the given datapath, which need not be necessarily of the local controller. If the consumer of the service is cognizant of the fact that a given DataPathId can only emanate from the local controller, then use variant `isMaster`. If however the consumer is not knowledgeable about the given DataPathId being of local or of a peer controller, which can be the case for NB REST consumers like TCS, then use this API. NOTE: This should NOT be called from fast-path workflow. There are overheads incurred in answering this query due to team-interactions.
      Parameters:
        `dpid` - datapath for which the master controller is to be determined
        `teamAware` - indicates its a controller-cluster wide lookup.
      Returns:
        ControllerNode which is playing the MASTER role

    - #### isMaster

          Boolean isMaster(DataPathId dpid)

      Indicates if the LOCAL system is the master for the given datapath. Intended to be a replacement for `getMaster`. The answer from this API is expected to be optimized for fast-path, with a constant O(1) time characterization.
      Parameters:
        `dpid` - datapath for which the local controller is assessed on
      Returns:
        true if local controller is the master to the given datapathid, false otherwise

    - #### getSlaves

          Set<ControllerNode> getSlaves(IpAddress deviceIp)

      Returns the controller which are playing the role of SLAVE to the given controlled entity(switch etc).
      Parameters:
        `deviceIp` - representing the IpAddress of the device. which the controller playing the ControllerRole.SLAVE role is to be determined
      Returns:
        Set of controllers which are playing the SLAVE role

    - #### getMasterElements

          Set<IpAddress> getMasterElements(ControllerNode controller)

      Returns list of controlled entities to which the given controller is playing the role of MASTER.
      Parameters:
        `controller` - ip of controller whose MASTER list is solicited
      Returns:
        Set of controlled entities managed in MASTER mode

    - #### getSlaveElements

          Set<IpAddress> getSlaveElements(ControllerNode controller)

      Returns list of controlled entities to which the given controller is playing the role of SLAVE.
      Parameters:
        `controller` - ip of controller whose SLAVE list is solicited
      Returns:
        Set of controlled entities managed in SLAVE mode

    - #### addListener

          void addListener(RoleListener roleListener)

      Subscribe to Role change notifications by supplying a `RoleListener` callback implementation.
      Parameters:
        `roleListener` - a concrete RoleListener implementation.

    - #### removeListener

          void removeListener(RoleListener roleListener)

      Express withdrawal from the Role change notification by specifying the RoleListener implementation that was used while subscribing.
      Parameters:
        `roleListener` - the concrete RoleListener implementation

    - #### isSelfEqual

          boolean isSelfEqual(IpAddress deviceIp)

Copyright © 2014. All Rights Reserved.