Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
schaertl_andreas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
supervision
schaertl_andreas
Commits
35d81214
Commit
35d81214
authored
4 years ago
by
Andreas Schärtl
Browse files
Options
Downloads
Patches
Plain Diff
[x] Comments
parent
a9bb6868
Branches
week20/collector-rebase
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ulocollect/core/collector.go
+10
-10
10 additions, 10 deletions
ulocollect/core/collector.go
with
10 additions
and
10 deletions
ulocollect/core/collector.go
+
10
−
10
View file @
35d81214
...
...
@@ -5,6 +5,9 @@ import (
)
// A Collector schedules the execution of various Jobs.
//
// It also keeps track of all previously submitted jobs. This is
// useful for keeping logs and the like.
type
Collector
struct
{
// The Importer we forward the ULO/RDF bytes to.
Destination
Importer
...
...
@@ -22,19 +25,16 @@ func (c *Collector) Submit(j *Job) error {
return
fmt
.
Errorf
(
"Id=%v already submitted"
,
id
)
}
j
.
mu
.
Lock
()
defer
j
.
mu
.
Unlock
()
go
c
.
execute
(
j
)
return
nil
}
func
(
c
*
Collector
)
execute
(
j
*
Job
)
{
// Aquire lock as we need to set the status initially.
//
(1)
Aquire lock as we need to set the status initially.
j
.
mu
.
Lock
()
// Set state to submitted. Later we'll want to do some kind
//
(2)
Set state to submitted. Later we'll want to do some kind
// of scheduling at which point a job can spend a lot of time
// in this state. But in the current version we don't do any
// clever scheduling and as such the job enters the Active
...
...
@@ -42,19 +42,19 @@ func (c *Collector) execute(j *Job) {
j
.
state
=
Submitted
//
Yep, we are starting already!
//
(3) There is no scheduling. Start right away.
j
.
state
=
Active
// Now we give up the lock as we run the actual payload.
//
(4)
Now we give up the lock as we run the actual payload.
j
.
mu
.
Unlock
()
// Run the actual payload.
//
(5)
Run the actual payload.
err
:=
j
.
Collect
(
c
)
// Set completion state.
//
(6)
Set completion state.
j
.
mu
.
Lock
()
...
...
@@ -67,7 +67,7 @@ func (c *Collector) execute(j *Job) {
j
.
wr
.
Release
()
// We are done mutating the Job.
//
(7)
We are done mutating the Job.
j
.
mu
.
Unlock
()
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment