Beispiel #1
0
func GetNumAliveWorkers(tx *hood.Hood) int {
	var results []IntStruct
	err := tx.FindSql(&results,
		`select count(*) as value
    from worker
    where status=$1`, WORKER_ALIVE)
	if err != nil {
		panic(err)
	}

	return results[0].Value
}
Beispiel #2
0
func (rdd *Rdd) GetNumSegmentsComplete(tx *hood.Hood, include *Segment) int {
	var results []IntStruct
	err := tx.FindSql(&results,
		`select count(*) as value
    from segment
    where (rdd_id = $1 and status=$3)
    or id = $2`, rdd.Id, include.Id, SEGMENT_COMPLETE)
	if err != nil {
		panic(err)
	}

	return results[0].Value
}
Beispiel #3
0
func GetRandomAliveWorker(tx *hood.Hood) *Worker {
	var results []Worker
	err := tx.FindSql(&results,
		`select *
    from worker
    where status=$1
    order by random()
    limit 1`, WORKER_ALIVE)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		return nil
	} else {
		return &results[0]
	}
}
Beispiel #4
0
func GetPendingRdds(tx *hood.Hood) []*Rdd {
	var results []Rdd
	err := tx.FindSql(&results,
		`select rdd.*
    from rdd
    where rdd.state = $1`, RDD_PENDING)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*Rdd, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
Beispiel #5
0
func GetRddByStartTime(tx *hood.Hood, protojobId int64, startTime int64) *Rdd {
	var results []Rdd
	err := tx.FindSql(&results,
		`select rdd.*
  from rdd
  inner join workflow_batch
  on rdd.workflow_batch_id = workflow_batch.id
  where rdd.protojob_id = $1
  and workflow_batch.start_time = $2`, protojobId, startTime)
	if err != nil {
		panic(err)
	}

	if len(results) == 0 {
		return nil
	} else {
		return &results[0]
	}
}
Beispiel #6
0
// Get all Rdd edges whose dest Rdd is in the given workflow batch. Note that
// the source and dest Rdds may be produced in different batches.
func (workflowBatch *WorkflowBatch) GetRddEdges(tx *hood.Hood) []*RddEdge {
	var results []RddEdge
	err := tx.FindSql(&results,
		`select rdd_edge.*
    from rdd_edge
    inner join rdd dest_rdd
    on rdd_edge.dest_rdd_id = dest_rdd.id
    where dest_rdd.workflow_batch_id = $1`, workflowBatch.Id)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*RddEdge, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
Beispiel #7
0
func (rdd *Rdd) GetDestRdds(tx *hood.Hood) []*Rdd {
	var results []Rdd
	err := tx.FindSql(&results,
		`select dest_rdd.*
    from rdd_edge
    inner join rdd dest_rdd
    on rdd_edge.dest_rdd_id = dest_rdd.id
    where rdd_edge.source_rdd_id = $1`, rdd.Id)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*Rdd, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
Beispiel #8
0
// Select all workflow edges whose dest_protojob is in the given
// workflow (this also imlies that the source_protojob is in the workflow)
func (workflow *Workflow) GetWorkflowEdges(tx *hood.Hood) []*WorkflowEdge {
	var results []WorkflowEdge
	err := tx.FindSql(&results,
		`select workflow_edge.*
    from workflow_edge
    inner join protojob dest_job
    on workflow_edge.dest_job_id = dest_job.id
    where dest_job.workflow_id = $1`, workflow.Id)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*WorkflowEdge, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
Beispiel #9
0
func (protojob *Protojob) GetSourceProtojobs(tx *hood.Hood) []*Protojob {
	var results []Protojob
	err := tx.FindSql(&results,
		`select source_job.*
    from workflow_edge
    inner join protojob source_job
    on workflow_edge.source_job_id = source_job.id
    where workflow_edge.dest_job_id = $1`, protojob.Id)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*Protojob, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
Beispiel #10
0
func (rdd *Rdd) GetSegmentCopies(tx *hood.Hood) []*SegmentCopy {
	var results []SegmentCopy
	err := tx.FindSql(&results,
		`select segment_copy.*
    from segment_copy
    inner join segment
    on segment_copy.segment_id = segment.id
    where segment.rdd_id = $1`, rdd.Id)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*SegmentCopy, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}