Improved doc
This commit is contained in:
parent
2767ac4158
commit
28ed951ee5
@ -2,4 +2,11 @@
|
|||||||
|
|
||||||
- [ ] In most of the components from 'models/' we have a method to add input and output to the model, however this linking of components is already done in oc-schedule when parsing the MxGraph. We need to determine if adding relations between components inside the objects themself is necessary.
|
- [ ] In most of the components from 'models/' we have a method to add input and output to the model, however this linking of components is already done in oc-schedule when parsing the MxGraph. We need to determine if adding relations between components inside the objects themself is necessary.
|
||||||
- When running in debug mode with a breakpoint inside the first line of computing.addLink it is only called once
|
- When running in debug mode with a breakpoint inside the first line of computing.addLink it is only called once
|
||||||
- [ ]
|
- [ ]
|
||||||
|
|
||||||
|
## MxGraph
|
||||||
|
|
||||||
|
- [ ] The ConsumeMxGraphModel is way too long, it should refactored and broken down in different sub methods
|
||||||
|
- mxcell are put inside an <object> tag when the settings have been opened, wether values have been set or not. Maybe we could find a way to make mxgraph add these whenever we add a component to the graph.
|
||||||
|
- then identify the links only
|
||||||
|
- [ ] It is unclear what are the inputs and the ouputs. It seems like they were implemented to link two components, but it seems redundant with the identification of links
|
6
docs/lexicon.md
Normal file
6
docs/lexicon.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
- rType : ressource type, can only be :
|
||||||
|
- rtype.DATA
|
||||||
|
- rtype.COMPUTING
|
||||||
|
- rtype.STORAGE
|
||||||
|
- rtype.DATACENTER
|
||||||
|
- rtype.INVALID if it doesn't match with any of the previous type
|
@ -564,9 +564,9 @@ func FindSliceInSlice(slice1 []string, slice2 []string) (int, int, bool) {
|
|||||||
return -1, -1, false
|
return -1, -1, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, err error, issues []error) {
|
func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Workflow, err error, issues []error) {
|
||||||
|
|
||||||
ret = &Workflow{}
|
returned_wf = &Workflow{}
|
||||||
|
|
||||||
// When we will iterate over the full array of cells, we first will register the resources
|
// When we will iterate over the full array of cells, we first will register the resources
|
||||||
// and after the linkage between them
|
// and after the linkage between them
|
||||||
@ -574,6 +574,18 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
return xmlmodel.Root.MxCell[i].RID != nil
|
return xmlmodel.Root.MxCell[i].RID != nil
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// For each cell of the xml graph,
|
||||||
|
// in the case cell has a rID retrieve its rType from the value of rID of the componant in the worfklow
|
||||||
|
// retrieve the componant's type
|
||||||
|
// create an object from the rType
|
||||||
|
// update the existing workflow with the new componant
|
||||||
|
// or by defautlt : the cell represents an arrow
|
||||||
|
// if the source or the target of the arrow is a datacenter
|
||||||
|
// define which end of the arrow is the DC
|
||||||
|
// if the other other end of the arrow is a computing component
|
||||||
|
// create a computing object
|
||||||
|
// attach the DC to it
|
||||||
|
// update the workflow with the object : create the list of this type of component or update the list with the id of the component with the object
|
||||||
for _, cell := range xmlmodel.Root.MxCell {
|
for _, cell := range xmlmodel.Root.MxCell {
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
@ -595,10 +607,11 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
nil
|
nil
|
||||||
}
|
}
|
||||||
|
|
||||||
resObj := ret.CreateResourceObject(rType)
|
resObj := returned_wf.CreateResourceObject(rType)
|
||||||
resObj.setReference(rIDObj)
|
resObj.setReference(rIDObj)
|
||||||
|
|
||||||
ret.UpdateObj(resObj, cell.ID)
|
returned_wf.UpdateObj(resObj, cell.ID)
|
||||||
|
|
||||||
case cell.ID == "0" || cell.ID == "1":
|
case cell.ID == "0" || cell.ID == "1":
|
||||||
// ID 0 and 1 are special cases of mxeditor
|
// ID 0 and 1 are special cases of mxeditor
|
||||||
continue
|
continue
|
||||||
@ -606,8 +619,8 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
// Not root nor resource. Should be only links
|
// Not root nor resource. Should be only links
|
||||||
sourceObj := ret.GetResource(cell.Source)
|
sourceObj := returned_wf.GetResource(cell.Source)
|
||||||
targetObj := ret.GetResource(cell.Target)
|
targetObj := returned_wf.GetResource(cell.Target)
|
||||||
|
|
||||||
if sourceObj == nil || targetObj == nil {
|
if sourceObj == nil || targetObj == nil {
|
||||||
if sourceObj == nil && targetObj == nil {
|
if sourceObj == nil && targetObj == nil {
|
||||||
@ -633,18 +646,18 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
datacenterLinked = cell.Source
|
datacenterLinked = cell.Source
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ret.GetResource(datacenterLinked).getRtype() {
|
switch returned_wf.GetResource(datacenterLinked).getRtype() {
|
||||||
case rtype.COMPUTING:
|
case rtype.COMPUTING:
|
||||||
computingObj := ret.GetResource(datacenterLinked).(*ComputingObject)
|
computingObj := returned_wf.GetResource(datacenterLinked).(*ComputingObject)
|
||||||
|
|
||||||
// We should always get a ID because we already registered resources and discarded which doesn't correspond to existent models
|
// We should always get a ID because we already registered resources and discarded which doesn't correspond to existent models
|
||||||
computingObj.DataCenterID = *datacenter
|
computingObj.DataCenterID = *datacenter
|
||||||
ret.UpdateObj(computingObj, *datacenterLinked)
|
returned_wf.UpdateObj(computingObj, *datacenterLinked)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
targetObj.addLink(INPUT, *cell.Source)
|
targetObj.addLink(INPUT, *cell.Source)
|
||||||
ret.UpdateObj(targetObj, *cell.Target) // save back
|
returned_wf.UpdateObj(targetObj, *cell.Target) // save back
|
||||||
|
|
||||||
// If we have a relationship of:
|
// If we have a relationship of:
|
||||||
// Source ----> Target
|
// Source ----> Target
|
||||||
@ -653,7 +666,7 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
// But we also must make sure that the Target will be in the OUTPUTs of the Source
|
// But we also must make sure that the Target will be in the OUTPUTs of the Source
|
||||||
|
|
||||||
sourceObj.addLink(OUTPUT, *cell.Target)
|
sourceObj.addLink(OUTPUT, *cell.Target)
|
||||||
ret.UpdateObj(sourceObj, *cell.Source)
|
returned_wf.UpdateObj(sourceObj, *cell.Source)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -663,7 +676,9 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
dataslist := make(map[string]bool)
|
dataslist := make(map[string]bool)
|
||||||
// datalist := make(map[string]bool)
|
// datalist := make(map[string]bool)
|
||||||
|
|
||||||
for _, comp := range ret.Computing {
|
|
||||||
|
// Test wether the computing componants are linked with a DC
|
||||||
|
for _, comp := range returned_wf.Computing {
|
||||||
if comp.DataCenterID == "" {
|
if comp.DataCenterID == "" {
|
||||||
issues = append(issues, errors.New("Computing "+*comp.getName()+" without a Datacenter"))
|
issues = append(issues, errors.New("Computing "+*comp.getName()+" without a Datacenter"))
|
||||||
} else {
|
} else {
|
||||||
@ -673,14 +688,14 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, dcin := range comp.Inputs {
|
for _, dcin := range comp.Inputs {
|
||||||
switch ret.GetResource(&dcin).getRtype() {
|
switch returned_wf.GetResource(&dcin).getRtype() {
|
||||||
case rtype.DATA:
|
case rtype.DATA:
|
||||||
dataslist[dcin] = true
|
dataslist[dcin] = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, dcout := range comp.Outputs {
|
for _, dcout := range comp.Outputs {
|
||||||
switch ret.GetResource(&dcout).getRtype() {
|
switch returned_wf.GetResource(&dcout).getRtype() {
|
||||||
case rtype.DATA:
|
case rtype.DATA:
|
||||||
dataslist[dcout] = true
|
dataslist[dcout] = true
|
||||||
}
|
}
|
||||||
@ -688,23 +703,23 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, va := range ret.Storage {
|
for _, storage_component := range returned_wf.Storage {
|
||||||
if va.Inputs == nil && va.Outputs == nil {
|
if storage_component.Inputs == nil && storage_component.Outputs == nil {
|
||||||
issues = append(issues, errors.New("Storage "+*va.getName()+" without compatible inputs and outputs"))
|
issues = append(issues, errors.New("Storage "+*storage_component.getName()+" without compatible inputs and outputs"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for dcID, va := range ret.Datacenter {
|
for dcID, dc_component := range returned_wf.Datacenter {
|
||||||
// if rID doesn't exist in the list, it means that it's not used
|
// if rID doesn't exist in the list, it means that it's not used
|
||||||
if _, ok := dcslist[dcID]; !ok {
|
if _, ok := dcslist[dcID]; !ok {
|
||||||
issues = append(issues, errors.New("DC "+*va.getName()+" not atached to any Computing"))
|
issues = append(issues, errors.New("DC "+*dc_component.getName()+" not atached to any Computing"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for dcID, va := range ret.Data {
|
for dcID, data_component := range returned_wf.Data {
|
||||||
// if rID doesn't exist in the list, it means that it's not used
|
// if rID doesn't exist in the list, it means that it's not used
|
||||||
if _, ok := dataslist[dcID]; !ok {
|
if _, ok := dataslist[dcID]; !ok {
|
||||||
issues = append(issues, errors.New("Data "+*va.getName()+" not atached to any Computing"))
|
issues = append(issues, errors.New("Data "+*data_component.getName()+" not atached to any Computing"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -722,7 +737,7 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
// inputs AND Comp2 inputs with Comp1 outputs, since we are
|
// inputs AND Comp2 inputs with Comp1 outputs, since we are
|
||||||
// iterating over all existent Computing models in the Graph
|
// iterating over all existent Computing models in the Graph
|
||||||
|
|
||||||
for _, comp := range ret.Computing {
|
for _, comp := range returned_wf.Computing {
|
||||||
|
|
||||||
compModel, err2 := comp.getModel()
|
compModel, err2 := comp.getModel()
|
||||||
if err = err2; err != nil {
|
if err = err2; err != nil {
|
||||||
@ -744,7 +759,7 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
|
|
||||||
//TODO: We should allow heterogenous inputs?
|
//TODO: We should allow heterogenous inputs?
|
||||||
for _, objIn := range comp.Inputs {
|
for _, objIn := range comp.Inputs {
|
||||||
resIn := ret.GetResource(&objIn)
|
resIn := returned_wf.GetResource(&objIn)
|
||||||
resInType := resIn.getRtype()
|
resInType := resIn.getRtype()
|
||||||
switch resInType {
|
switch resInType {
|
||||||
case rtype.DATA:
|
case rtype.DATA:
|
||||||
@ -781,7 +796,7 @@ func (w Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (ret *Workflow, er
|
|||||||
|
|
||||||
//TODO: We should allow heterogenous outputs?
|
//TODO: We should allow heterogenous outputs?
|
||||||
for _, objOut := range comp.Outputs {
|
for _, objOut := range comp.Outputs {
|
||||||
resOut := ret.GetResource(&objOut)
|
resOut := returned_wf.GetResource(&objOut)
|
||||||
resOutType := resOut.getRtype()
|
resOutType := resOut.getRtype()
|
||||||
switch resOutType {
|
switch resOutType {
|
||||||
case rtype.COMPUTING:
|
case rtype.COMPUTING:
|
||||||
|
Loading…
Reference in New Issue
Block a user