Skip to content

Commit 90b49d4

Browse files
fix(lcm): Decrease default thread count using for lcm bricks
1 parent 2d777f1 commit 90b49d4

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

lib/gooddata/lcm/actions/import_object_collections.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class ImportObjectCollections < BaseAction
2020

2121
description 'Synchronization Info'
2222
param :synchronize, array_of(instance_of(Type::SynchronizationInfoType)), required: true, generated: true
23+
24+
description 'Number Of Threads'
25+
param :number_of_threads, instance_of(Type::StringType), required: false, default: '10'
2326
end
2427

2528
class << self
@@ -28,15 +31,16 @@ def call(params)
2831

2932
client = params.gdc_gd_client
3033
development_client = params.development_client
34+
number_of_threads = Integer(params.number_of_threads || '10')
3135

32-
params.synchronize.peach do |info|
36+
params.synchronize.peach(number_of_threads) do |info|
3337
from = info.from
3438
to_projects = info.to
3539
transfer_uris = info.transfer_uris
3640

3741
from_project = development_client.projects(from) || fail("Invalid 'from' project specified - '#{from}'")
3842

39-
to_projects.peach do |entry|
43+
to_projects.peach(number_of_threads) do |entry|
4044
pid = entry[:pid]
4145
to_project = client.projects(pid) || fail("Invalid 'to' project specified - '#{pid}'")
4246

lib/gooddata/lcm/actions/synchronize_dataset_mappings.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class SynchronizeDataSetMapping < BaseAction
3333

3434
description 'Sync failed list'
3535
param :sync_failed_list, instance_of(Type::HashType), required: false
36+
37+
description 'Number Of Threads'
38+
param :number_of_threads, instance_of(Type::StringType), required: false, default: '10'
3639
end
3740

3841
RESULT_HEADER = %i[from to count status]
@@ -45,8 +48,9 @@ def call(params)
4548

4649
client = params.gdc_gd_client
4750
development_client = params.development_client
51+
number_of_threads = Integer(params.number_of_threads || '10')
4852

49-
params.synchronize.peach do |info|
53+
params.synchronize.peach(number_of_threads) do |info|
5054
from_project = info.from
5155
to_projects = info.to
5256

@@ -60,7 +64,7 @@ def call(params)
6064
if dataset_mapping&.dig('datasetMappings', 'items').nil? || dataset_mapping['datasetMappings']['items'].empty?
6165
params.gdc_logger.info "Project: '#{from.title}', PID: '#{from.pid}' has no model mapping, skip synchronizing model mapping."
6266
else
63-
to_projects.peach do |to|
67+
to_projects.peach(number_of_threads) do |to|
6468
pid = to[:pid]
6569
next if sync_failed_project(pid, params)
6670

lib/gooddata/lcm/actions/synchronize_user_filters.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ class SynchronizeUserFilters < BaseAction
7474

7575
description 'Makes the brick run without altering user filters'
7676
param :dry_run, instance_of(Type::StringType), required: false, default: false
77+
78+
description 'Number Of Threads'
79+
param :number_of_threads, instance_of(Type::StringType), required: false, default: '10'
7780
end
7881

7982
class << self
@@ -104,6 +107,7 @@ def call(params)
104107
symbolized_config = GoodData::Helpers.symbolize_keys(symbolized_config)
105108
symbolized_config[:labels] = symbolized_config[:labels].map { |l| GoodData::Helpers.symbolize_keys(l) }
106109
multiple_projects_column = params.multiple_projects_column
110+
number_of_threads = Integer(params.number_of_threads || '10')
107111

108112
mode = params.sync_mode
109113
unless MODES.include?(mode)
@@ -196,7 +200,7 @@ def call(params)
196200

197201
unless run_params[:do_not_touch_filters_that_are_not_mentioned]
198202
to_be_deleted_clients = UserBricksHelper.non_working_clients(domain_clients, working_client_ids)
199-
to_be_deleted_clients.peach do |c|
203+
to_be_deleted_clients.peach(number_of_threads) do |c|
200204
begin
201205
current_project = c.project
202206
users = users_by_project[c.client_id]

lib/gooddata/lcm/lcm2.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ def print_actions_result(actions, results)
295295
end
296296

297297
def perform(mode, params = {})
298+
# Default setting for $pmap_default_thread_count = 20 in gooddata.rb file. We are going to decrease default
299+
# number of threads count to 10 for LCM bricks only
300+
$pmap_default_thread_count = 10 # rubocop:disable GlobalVars
301+
298302
params = convert_params(params)
299303

300304
GoodData.gd_logger.brick = mode

0 commit comments

Comments
 (0)