Interface MastershipStore

    • Method Detail

      • requestRole

        CompletableFuture<MastershipRole> requestRole​(DeviceId deviceId)
        Requests role of the local node for the specified device.
        Parameters:
        deviceId - device identifier
        Returns:
        established or newly negotiated mastership role
      • getRole

        MastershipRole getRole​(NodeId nodeId,
                               DeviceId deviceId)
        Returns the role of a device for a specific controller instance.
        Parameters:
        nodeId - the instance identifier
        deviceId - the device identifiers
        Returns:
        the role
      • getMaster

        NodeId getMaster​(DeviceId deviceId)
        Returns the master for a device.
        Parameters:
        deviceId - the device identifier
        Returns:
        the instance identifier of the master
      • getNodes

        RoleInfo getNodes​(DeviceId deviceId)
        Returns the master and backup nodes for a device.
        Parameters:
        deviceId - the device identifier
        Returns:
        a RoleInfo containing controller IDs
      • getDevices

        Set<DeviceId> getDevices​(NodeId nodeId)
        Returns the devices that a controller instance is master of.
        Parameters:
        nodeId - the instance identifier
        Returns:
        a set of device identifiers
      • setMaster

        CompletableFuture<MastershipEvent> setMaster​(NodeId nodeId,
                                                     DeviceId deviceId)
        Sets a device's role for a specified controller instance.
        Parameters:
        nodeId - controller instance identifier
        deviceId - device identifier
        Returns:
        a mastership event
      • getTermFor

        MastershipTerm getTermFor​(DeviceId deviceId)
        Returns the current master and number of past mastership hand-offs (terms) for a device.
        Parameters:
        deviceId - the device identifier
        Returns:
        the current master's ID and the term value for device, or null
      • getMastership

        MastershipInfo getMastership​(DeviceId deviceId)
        Returns the mastership info for the given device.
        Parameters:
        deviceId - the device for which to return the mastership info
        Returns:
        the mastership info for the given device
      • setStandby

        CompletableFuture<MastershipEvent> setStandby​(NodeId nodeId,
                                                      DeviceId deviceId)
        Sets a controller instance's mastership role to STANDBY for a device. If the role is MASTER, another controller instance will be selected as a candidate master.
        Parameters:
        nodeId - the controller instance identifier
        deviceId - device to revoke mastership role for
        Returns:
        a mastership event
      • relinquishRole

        CompletableFuture<MastershipEvent> relinquishRole​(NodeId nodeId,
                                                          DeviceId deviceId)
        Allows a controller instance to give up its current role for a device. If the role is MASTER, another controller instance will be selected as a candidate master.
        Parameters:
        nodeId - the controller instance identifier
        deviceId - device to revoke mastership role for
        Returns:
        a mastership event
      • relinquishAllRole

        void relinquishAllRole​(NodeId nodeId)
        Removes all the roles for the specified controller instance. If the role was MASTER, another controller instance will be selected as a candidate master.
        Parameters:
        nodeId - the controller instance identifier