Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8c59221f
Commit
8c59221f
authored
Jul 13, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move schedule_jobs method to the Geo::BaseSchedulerWorker
parent
d7922319
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
22 deletions
+17
-22
app/workers/geo/base_scheduler_worker.rb
app/workers/geo/base_scheduler_worker.rb
+11
-0
app/workers/geo_file_download_dispatch_worker.rb
app/workers/geo_file_download_dispatch_worker.rb
+3
-12
app/workers/geo_repository_sync_worker.rb
app/workers/geo_repository_sync_worker.rb
+3
-10
No files found.
app/workers/geo/base_scheduler_worker.rb
View file @
8c59221f
...
...
@@ -105,6 +105,17 @@ module Geo
@scheduled_jobs
=
@scheduled_jobs
.
zip
(
status
).
map
{
|
(
job
,
completed
)
|
job
if
completed
}.
compact
end
def
schedule_jobs
num_to_schedule
=
[
max_capacity
-
scheduled_job_ids
.
size
,
pending_resources
.
size
].
min
return
unless
resources_remain?
num_to_schedule
.
times
do
job
=
schedule_job
(
*
pending_resources
.
shift
)
scheduled_jobs
<<
job
if
job
&
.
fetch
(
:job_id
).
present?
end
end
def
scheduled_job_ids
scheduled_jobs
.
map
{
|
data
|
data
[
:job_id
]
}
end
...
...
app/workers/geo_file_download_dispatch_worker.rb
View file @
8c59221f
...
...
@@ -7,19 +7,10 @@ class GeoFileDownloadDispatchWorker < Geo::BaseSchedulerWorker
LEASE_KEY
end
def
schedule_job
s
num_to_schedule
=
[
max_capacity
-
scheduled_job_ids
.
size
,
pending_resources
.
size
].
min
def
schedule_job
(
object_db_id
,
object_type
)
job_id
=
GeoFileDownloadWorker
.
perform_async
(
object_type
,
object_db_id
)
return
unless
resources_remain?
num_to_schedule
.
times
do
object_db_id
,
object_type
=
pending_resources
.
shift
job_id
=
GeoFileDownloadWorker
.
perform_async
(
object_type
,
object_db_id
)
if
job_id
@scheduled_jobs
<<
{
id:
object_db_id
,
type:
object_type
,
job_id:
job_id
}
end
end
{
id:
object_db_id
,
type:
object_type
,
job_id:
job_id
}
if
job_id
end
def
load_pending_resources
...
...
app/workers/geo_repository_sync_worker.rb
View file @
8c59221f
...
...
@@ -13,17 +13,10 @@ class GeoRepositorySyncWorker < Geo::BaseSchedulerWorker
MAX_CAPACITY
end
def
schedule_job
s
num_to_schedule
=
[
max_capacity
-
scheduled_job_ids
.
size
,
pending_resources
.
size
].
min
def
schedule_job
(
project_id
)
job_id
=
Geo
::
ProjectSyncWorker
.
perform_in
(
BACKOFF_DELAY
,
project_id
,
Time
.
now
)
return
unless
resources_remain?
num_to_schedule
.
times
do
project_id
=
pending_resources
.
shift
job_id
=
Geo
::
ProjectSyncWorker
.
perform_in
(
BACKOFF_DELAY
,
project_id
,
Time
.
now
)
scheduled_jobs
<<
{
id:
project_id
,
job_id:
job_id
}
if
job_id
end
{
id:
project_id
,
job_id:
job_id
}
if
job_id
end
def
load_pending_resources
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment