Package org.onosproject.net.intent
Class IntentData
- java.lang.Object
-
- org.onosproject.net.intent.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 Summary
Constructors Modifier Constructor Description protected
IntentData()
IntentData(Intent intent, IntentState state, Timestamp version)
Deprecated.in 1.11.0
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IntentData
assign(IntentData data, Timestamp timestamp, NodeId node)
Creates updated IntentData after assigning task to a node.static IntentData
compiled(IntentData data, java.util.List<Intent> installables)
Creates updated IntentData with compilation result.static IntentData
copy(IntentData data)
Creates a copy of given IntentData.static IntentData
copy(IntentData data, Timestamp reqVersion)
Creates a copy of given IntentData, and update request version.static IntentData
corrupt(IntentData data)
Creates a copy of IntentData in corrupt state, incrementing error count.boolean
equals(java.lang.Object obj)
int
errorCount()
Returns the number of times that this intent has encountered an error during installation or withdrawal.int
hashCode()
void
incrementErrorCount()
Increments the error count for this intent.java.util.List<Intent>
installables()
Returns the installables associated with this intent.Intent
intent()
Returns the intent this metadata references.int
internalStateVersion()
static boolean
isUpdateAcceptable(IntentData currentData, IntentData newData)
Determines whether an intent data update is allowed.Key
key()
Returns the intent key.static IntentData
nextState(IntentData data, IntentState nextState)
Create a copy of IntentData in next state.NodeId
origin()
Returns the origin node that created this intent.static IntentData
purge(Intent intent)
Creates IntentData for Intent purge request.IntentState
request()
void
setErrorCount(int newCount)
Sets the error count for this intent.void
setState(IntentState newState)
Updates the state of the intent to the given new state.IntentState
state()
Returns the state of the intent.static IntentData
submit(Intent intent)
Creates IntentData for Intent submit request.java.lang.String
toString()
Timestamp
version()
Returns the request version of the intent for this key.static IntentData
withdraw(Intent intent)
Creates IntentData for Intent withdraw request.
-
-
-
Constructor Detail
-
IntentData
@Deprecated public IntentData(Intent intent, IntentState state, Timestamp version)
Deprecated.in 1.11.0Creates a new intent data object.- Parameters:
intent
- intent this metadata referencesstate
- intent stateversion
- 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 assignmenttimestamp
- to assign to current requestnode
- 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 copyreqVersion
- 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 copynextState
- 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 updateinstallables
- 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
-
request
public IntentState request()
-
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 storenewData
- new intent data update proposal- Returns:
- true if we can apply the update, otherwise false
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-