add sets up
This commit is contained in:
		@@ -83,7 +83,7 @@ func (w *Workflow) GetPricedItem(
 | 
			
		||||
	for _, item := range w.Graph.Items {
 | 
			
		||||
		if f(item) {
 | 
			
		||||
			dt, res := item.GetResource()
 | 
			
		||||
			ord := res.ConvertToPricedResource(dt, request, buyingStrategy, pricingStrategy)
 | 
			
		||||
			ord := res.ConvertToPricedResource(dt, request)
 | 
			
		||||
			list_datas[res.GetID()] = ord
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
@@ -166,12 +166,11 @@ func (wfa *Workflow) CheckBooking(caller *tools.HTTPCaller) (bool, error) {
 | 
			
		||||
	return true, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIRequest, buyingStrategy int, pricingStrategy int) (float64, map[tools.DataType]map[string]pricing.PricedItemITF, *Workflow, error) {
 | 
			
		||||
func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIRequest) (float64, map[tools.DataType]map[string]pricing.PricedItemITF, *Workflow, error) {
 | 
			
		||||
	priceds := map[tools.DataType]map[string]pricing.PricedItemITF{}
 | 
			
		||||
	ps, priceds, err := plan[*resources.ProcessingResource](tools.PROCESSING_RESOURCE, wf, priceds, request,
 | 
			
		||||
		buyingStrategy, pricingStrategy, wf.Graph.IsProcessing,
 | 
			
		||||
	ps, priceds, err := plan[*resources.ProcessingResource](tools.PROCESSING_RESOURCE, wf, priceds, request, wf.Graph.IsProcessing,
 | 
			
		||||
		func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
 | 
			
		||||
			return start.Add(time.Duration(wf.Graph.GetAverageTimeProcessingBeforeStart(0, res.GetID(), request, buyingStrategy, pricingStrategy)) * time.Second), priced.GetExplicitDurationInS()
 | 
			
		||||
			return start.Add(time.Duration(wf.Graph.GetAverageTimeProcessingBeforeStart(0, res.GetID(), request)) * time.Second), priced.GetExplicitDurationInS()
 | 
			
		||||
		}, func(started time.Time, duration float64) *time.Time {
 | 
			
		||||
			s := started.Add(time.Duration(duration))
 | 
			
		||||
			return &s
 | 
			
		||||
@@ -179,7 +178,7 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return 0, priceds, nil, err
 | 
			
		||||
	}
 | 
			
		||||
	if _, priceds, err = plan[resources.ResourceInterface](tools.DATA_RESOURCE, wf, priceds, request, buyingStrategy, pricingStrategy,
 | 
			
		||||
	if _, priceds, err = plan[resources.ResourceInterface](tools.DATA_RESOURCE, wf, priceds, request,
 | 
			
		||||
		wf.Graph.IsData, func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
 | 
			
		||||
			return start, 0
 | 
			
		||||
		}, func(started time.Time, duration float64) *time.Time {
 | 
			
		||||
@@ -188,14 +187,14 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
		return 0, priceds, nil, err
 | 
			
		||||
	}
 | 
			
		||||
	for k, f := range map[tools.DataType]func(graph.GraphItem) bool{tools.STORAGE_RESOURCE: wf.Graph.IsStorage, tools.COMPUTE_RESOURCE: wf.Graph.IsCompute} {
 | 
			
		||||
		if _, priceds, err = plan[resources.ResourceInterface](k, wf, priceds, request, buyingStrategy, pricingStrategy,
 | 
			
		||||
		if _, priceds, err = plan[resources.ResourceInterface](k, wf, priceds, request,
 | 
			
		||||
			f, func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
 | 
			
		||||
				nearestStart, longestDuration := wf.Graph.GetAverageTimeRelatedToProcessingActivity(start, ps, res, func(i graph.GraphItem) (r resources.ResourceInterface) {
 | 
			
		||||
					if f(i) {
 | 
			
		||||
						_, r = i.GetResource()
 | 
			
		||||
					}
 | 
			
		||||
					return r
 | 
			
		||||
				}, request, buyingStrategy, pricingStrategy)
 | 
			
		||||
				}, request)
 | 
			
		||||
				return start.Add(time.Duration(nearestStart) * time.Second), longestDuration
 | 
			
		||||
			}, func(started time.Time, duration float64) *time.Time {
 | 
			
		||||
				s := started.Add(time.Duration(duration))
 | 
			
		||||
@@ -205,8 +204,7 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	longest := common.GetPlannerLongestTime(end, priceds, request)
 | 
			
		||||
	if _, priceds, err = plan[resources.ResourceInterface](tools.WORKFLOW_RESOURCE, wf, priceds, request,
 | 
			
		||||
		buyingStrategy, pricingStrategy, wf.Graph.IsWorkflow,
 | 
			
		||||
	if _, priceds, err = plan[resources.ResourceInterface](tools.WORKFLOW_RESOURCE, wf, priceds, request, wf.Graph.IsWorkflow,
 | 
			
		||||
		func(res resources.ResourceInterface, priced pricing.PricedItemITF) (time.Time, float64) {
 | 
			
		||||
			start := start.Add(time.Duration(common.GetPlannerNearestStart(start, priceds, request)) * time.Second)
 | 
			
		||||
			longest := float64(-1)
 | 
			
		||||
@@ -214,7 +212,7 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
			if code != 200 || err != nil {
 | 
			
		||||
				return start, longest
 | 
			
		||||
			}
 | 
			
		||||
			if neoLongest, _, _, err := r.(*Workflow).Planify(start, end, request, buyingStrategy, pricingStrategy); err != nil {
 | 
			
		||||
			if neoLongest, _, _, err := r.(*Workflow).Planify(start, end, request); err != nil {
 | 
			
		||||
				return start, longest
 | 
			
		||||
			} else if neoLongest > longest {
 | 
			
		||||
				longest = neoLongest
 | 
			
		||||
@@ -231,7 +229,6 @@ func (wf *Workflow) Planify(start time.Time, end *time.Time, request *tools.APIR
 | 
			
		||||
 | 
			
		||||
func plan[T resources.ResourceInterface](
 | 
			
		||||
	dt tools.DataType, wf *Workflow, priceds map[tools.DataType]map[string]pricing.PricedItemITF, request *tools.APIRequest,
 | 
			
		||||
	buyingStrategy int, pricingStrategy int,
 | 
			
		||||
	f func(graph.GraphItem) bool, start func(resources.ResourceInterface, pricing.PricedItemITF) (time.Time, float64), end func(time.Time, float64) *time.Time) ([]T, map[tools.DataType]map[string]pricing.PricedItemITF, error) {
 | 
			
		||||
	resources := []T{}
 | 
			
		||||
	for _, item := range wf.GetGraphItems(f) {
 | 
			
		||||
@@ -242,7 +239,10 @@ func plan[T resources.ResourceInterface](
 | 
			
		||||
		if realItem == nil {
 | 
			
		||||
			return resources, priceds, errors.New("could not load the processing resource")
 | 
			
		||||
		}
 | 
			
		||||
		priced := realItem.ConvertToPricedResource(dt, request, buyingStrategy, pricingStrategy)
 | 
			
		||||
		priced := realItem.ConvertToPricedResource(dt, request)
 | 
			
		||||
		if priced.SelectPricing() == nil {
 | 
			
		||||
			return resources, priceds, errors.New("no pricings are selected... can't proceed")
 | 
			
		||||
		}
 | 
			
		||||
		started, duration := start(realItem, priced)
 | 
			
		||||
		priced.SetLocationStart(started)
 | 
			
		||||
		if duration >= 0 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user