Class IntentData


  • @Beta
    public class IntentData
    extends java.lang.Object
    A wrapper class that contains an intents, its state, and other metadata for internal use.
    • Constructor Detail

      • IntentData

        @Deprecated
        public IntentData​(Intent intent,
                          IntentState state,
                          Timestamp version)
        Deprecated.
        in 1.11.0
        Creates a new intent data object.
        Parameters:
        intent - intent this metadata references
        state - intent state
        version - version of the intent for this key
      • IntentData

        protected IntentData()
    • Method Detail

      • submit

        public static IntentData submit​(Intent intent)
        Creates IntentData for Intent submit request.
        Parameters:
        intent - to request
        Returns:
        IntentData
      • withdraw

        public static IntentData withdraw​(Intent intent)
        Creates IntentData for Intent withdraw request.
        Parameters:
        intent - to request
        Returns:
        IntentData
      • purge

        public static IntentData purge​(Intent intent)
        Creates IntentData for Intent purge request.
        Parameters:
        intent - to request
        Returns:
        IntentData
      • assign

        public static IntentData assign​(IntentData data,
                                        Timestamp timestamp,
                                        NodeId node)
        Creates updated IntentData after assigning task to a node.
        Parameters:
        data - IntentData to update work assignment
        timestamp - to assign to current request
        node - node which was assigned to handle this request (local node id)
        Returns:
        updated IntentData object
      • copy

        public static IntentData copy​(IntentData data)
        Creates a copy of given IntentData.
        Parameters:
        data - intent data to copy
        Returns:
        copy
      • copy

        public static IntentData copy​(IntentData data,
                                      Timestamp reqVersion)
        Creates a copy of given IntentData, and update request version.
        Parameters:
        data - intent data to copy
        reqVersion - request version to be updated
        Returns:
        copy
      • nextState

        public static IntentData nextState​(IntentData data,
                                           IntentState nextState)
        Create a copy of IntentData in next state.
        Parameters:
        data - intent data to copy
        nextState - to transition to
        Returns:
        next state
      • corrupt

        public static IntentData corrupt​(IntentData data)
        Creates a copy of IntentData in corrupt state, incrementing error count.
        Parameters:
        data - intent data to copy
        Returns:
        next state
      • compiled

        public static IntentData compiled​(IntentData data,
                                          java.util.List<Intent> installables)
        Creates updated IntentData with compilation result.
        Parameters:
        data - IntentData to update
        installables - compilation result
        Returns:
        updated IntentData object
      • intent

        public Intent intent()
        Returns the intent this metadata references.
        Returns:
        intent
      • state

        public IntentState state()
        Returns the state of the intent.
        Returns:
        intent state
      • key

        public Key key()
        Returns the intent key.
        Returns:
        intent key
      • version

        public Timestamp version()
        Returns the request version of the intent for this key.
        Returns:
        intent version
      • internalStateVersion

        public int internalStateVersion()
      • origin

        public NodeId origin()
        Returns the origin node that created this intent.
        Returns:
        origin node ID
      • setState

        public void setState​(IntentState newState)
        Updates the state of the intent to the given new state.
        Parameters:
        newState - new state of the intent
      • incrementErrorCount

        public void incrementErrorCount()
        Increments the error count for this intent.
      • setErrorCount

        public void setErrorCount​(int newCount)
        Sets the error count for this intent.
        Parameters:
        newCount - new count
      • errorCount

        public int errorCount()
        Returns the number of times that this intent has encountered an error during installation or withdrawal.
        Returns:
        error count
      • installables

        public java.util.List<Intent> installables()
        Returns the installables associated with this intent.
        Returns:
        list of installable intents
      • isUpdateAcceptable

        public static boolean isUpdateAcceptable​(IntentData currentData,
                                                 IntentData newData)
        Determines whether an intent data update is allowed. The update must either have a higher version than the current data, or the state transition between two updates of the same version must be sane.
        Parameters:
        currentData - existing intent data in the store
        newData - new intent data update proposal
        Returns:
        true if we can apply the update, otherwise false
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object