Package org.btrplace.json.plan
Interface ActionConverter<E extends Action>
- All Known Implementing Classes:
AllocateConverter
,BootNodeConverter
,BootVMConverter
,KillVMConverter
,MigrateVMConverter
,ResumeVMConverter
,ShutdownNodeConverter
,ShutdownVMConverter
,SuspendVMConverter
public interface ActionConverter<E extends Action>
Specify a JSON converter for a
Action
.- Author:
- Fabien Hermenier
-
Field Summary
Fields Modifier and Type Field Description static String
END_LABEL
Key that indicates the end an action.static String
ID_LABEL
Key that indicate the action identifierstatic String
NODE_LABEL
Key that indicates a node identifier.static String
ON_LABEL
Key that indicates the current position of a VM.static String
RC_AMOUNT_LABEL
Key to indicate a resource amount.static String
RC_LABEL
Key to indicate a resource identifier.static String
START_LABEL
Key that indicates the beginning an action.static String
VM_DESTINATION_LABEL
static String
VM_LABEL
Key that indicates a VM identifier.static String
VM_LOCATION_LABEL
-
Method Summary
Modifier and Type Method Description default int
end(net.minidev.json.JSONObject json)
Get the end moment for the given JSON action.void
fillJSON(E action, net.minidev.json.JSONObject ob)
Fill the JSON skeleton that will represent this action.E
fromJSON(Model mo, net.minidev.json.JSONObject ob)
Create an action from a JSON Object.String
id()
The JSON identifier for the action.default int
start(net.minidev.json.JSONObject json)
Get the start moment for the given JSON action.Class<E>
supportedAction()
The action that is supported by this converter.default net.minidev.json.JSONObject
toJSON(E action)
Create a JSON from an action.
-
Field Details
-
START_LABEL
Key that indicates the beginning an action.- See Also:
- Constant Field Values
-
END_LABEL
Key that indicates the end an action.- See Also:
- Constant Field Values
-
ID_LABEL
Key that indicate the action identifier- See Also:
- Constant Field Values
-
VM_LABEL
Key that indicates a VM identifier.- See Also:
- Constant Field Values
-
NODE_LABEL
Key that indicates a node identifier.- See Also:
- Constant Field Values
-
ON_LABEL
Key that indicates the current position of a VM.- See Also:
- Constant Field Values
-
VM_LOCATION_LABEL
- See Also:
- Constant Field Values
-
VM_DESTINATION_LABEL
- See Also:
- Constant Field Values
-
RC_LABEL
Key to indicate a resource identifier.- See Also:
- Constant Field Values
-
RC_AMOUNT_LABEL
Key to indicate a resource amount.- See Also:
- Constant Field Values
-
-
Method Details
-
id
String id()The JSON identifier for the action.- Returns:
- a String that will be written inside the field
ID_LABEL
-
supportedAction
The action that is supported by this converter.- Returns:
- the action class.
-
fillJSON
Fill the JSON skeleton that will represent this action. The events will be added in a later stage.- Parameters:
action
- the action.ob
- the object to fill.
-
fromJSON
Create an action from a JSON Object. The events attached to the hooks will be parsed in a later stage.- Parameters:
mo
- the model to use to parse elements.ob
- the object to convert- Returns:
- the resulting action.
- Throws:
JSONConverterException
- if the conversion failed.
-
start
Get the start moment for the given JSON action.- Parameters:
json
- the JSON to analyse.- Returns:
- the parsed start moment.
- Throws:
JSONConverterException
- in case it was not possible to get the moment.
-
end
Get the end moment for the given JSON action.- Parameters:
json
- the JSON to analyse.- Returns:
- the parsed end moment.
- Throws:
JSONConverterException
- in case it was not possible to get the moment.
-
toJSON
Create a JSON from an action. First, a skeleton is created to mention the action identifier, the start and the end moments. Second,fillJSON(E, net.minidev.json.JSONObject)
is called.- Parameters:
action
- the action to convert.- Returns:
- the resulting JSON message.
-