Module: Gitlab::BitbucketServerImport::ParallelScheduling

Includes:
Loggable
Included in:
Importers::LfsObjectsImporter, Importers::NotesImporter, Importers::PullRequestsImporter
Defined in:
lib/gitlab/bitbucket_server_import/parallel_scheduling.rb

Constant Summary collapse

ALREADY_PROCESSED_CACHE_KEY =

The base cache key to use for tracking already processed objects.

'bitbucket-server-importer/already-processed/%{project}/%{collection}'
JOB_WAITER_CACHE_KEY =

The base cache key to use for storing job waiter key

'bitbucket-server-importer/job-waiter/%{project}/%{collection}'
JOB_WAITER_REMAINING_CACHE_KEY =

The base cache key to use for storing job waiter remaining jobs

'bitbucket-server-importer/job-waiter-remaining/%{project}/%{collection}'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#log_debug, #log_error, #log_info, #log_warn

Instance Attribute Details

#already_processed_cache_keyObject (readonly)

Returns the value of attribute already_processed_cache_key.



8
9
10
# File 'lib/gitlab/bitbucket_server_import/parallel_scheduling.rb', line 8

def already_processed_cache_key
  @already_processed_cache_key
end

#enqueued_job_counterObject

Returns the value of attribute enqueued_job_counter.



11
12
13
# File 'lib/gitlab/bitbucket_server_import/parallel_scheduling.rb', line 11

def enqueued_job_counter
  @enqueued_job_counter
end

#job_waiter_cache_keyObject (readonly)

Returns the value of attribute job_waiter_cache_key.



8
9
10
# File 'lib/gitlab/bitbucket_server_import/parallel_scheduling.rb', line 8

def job_waiter_cache_key
  @job_waiter_cache_key
end

#job_waiter_remaining_cache_keyObject (readonly)

Returns the value of attribute job_waiter_remaining_cache_key.



8
9
10
# File 'lib/gitlab/bitbucket_server_import/parallel_scheduling.rb', line 8

def job_waiter_remaining_cache_key
  @job_waiter_remaining_cache_key
end

#page_counterObject (readonly)

Returns the value of attribute page_counter.



8
9
10
# File 'lib/gitlab/bitbucket_server_import/parallel_scheduling.rb', line 8

def page_counter
  @page_counter
end

#projectObject (readonly)

Returns the value of attribute project.



8
9
10
# File 'lib/gitlab/bitbucket_server_import/parallel_scheduling.rb', line 8

def project
  @project
end

Instance Method Details

#initialize(project) ⇒ Object

project - An instance of Project.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/gitlab/bitbucket_server_import/parallel_scheduling.rb', line 26

def initialize(project)
  @project = project

  @page_counter = Gitlab::Import::PageCounter.new(project, collection_method, 'bitbucket-server-importer')
  @already_processed_cache_key =
    format(ALREADY_PROCESSED_CACHE_KEY, project: project.id, collection: collection_method)
  @job_waiter_cache_key =
    format(JOB_WAITER_CACHE_KEY, project: project.id, collection: collection_method)
  @job_waiter_remaining_cache_key = format(JOB_WAITER_REMAINING_CACHE_KEY, project: project.id,
    collection: collection_method)

  # The enqueued job counter is used to calculate job delays and distribute
  # them over time. When the stage worker restarts, the counter resets to
  # prevent jobs from being queued too far into the future. Such logic may
  # result in more jobs being executed when the stage worker resumes. An
  # alternative solution would complicate the delay logic, so for simplicity
  # we accept more jobs being executed.
  @enqueued_job_counter = 0
end