4
4
using System ;
5
5
using System . Threading ;
6
6
using System . Threading . Tasks ;
7
- using Microsoft . VisualStudio . Services . BlobStore . WebApi ;
8
- using Microsoft . VisualStudio . Services . Content . Common . Tracing ;
9
- using Microsoft . VisualStudio . Services . WebApi ;
10
- using Microsoft . VisualStudio . Services . Content . Common ;
11
- using Microsoft . VisualStudio . Services . BlobStore . Common . Telemetry ;
12
7
using Agent . Sdk ;
8
+ using BuildXL . Cache . ContentStore . Hashing ;
13
9
using Microsoft . TeamFoundation . DistributedTask . WebApi ;
14
10
using Microsoft . VisualStudio . Services . BlobStore . Common ;
15
- using BuildXL . Cache . ContentStore . Hashing ;
16
- using Microsoft . VisualStudio . Services . BlobStore . WebApi . Contracts ;
17
- using Agent . Sdk . Knob ;
18
- using System . Collections . Generic ;
11
+ using Microsoft . VisualStudio . Services . BlobStore . Common . Telemetry ;
12
+ using Microsoft . VisualStudio . Services . BlobStore . WebApi ;
13
+ using Microsoft . VisualStudio . Services . Content . Common ;
14
+ using Microsoft . VisualStudio . Services . Content . Common . Tracing ;
15
+ using Microsoft . VisualStudio . Services . WebApi ;
19
16
20
17
namespace Microsoft . VisualStudio . Services . Agent . Blob
21
18
{
@@ -36,7 +33,6 @@ public interface IDedupManifestArtifactClientFactory
36
33
bool verbose ,
37
34
Action < string > traceOutput ,
38
35
VssConnection connection ,
39
- int maxParallelism ,
40
36
IDomainId domainId ,
41
37
BlobstoreClientSettings clientSettings ,
42
38
AgentTaskPluginExecutionContext context ,
@@ -74,13 +70,6 @@ public interface IDedupManifestArtifactClientFactory
74
70
bool verbose ,
75
71
Action < string > traceOutput ,
76
72
CancellationToken cancellationToken ) ;
77
-
78
- /// <summary>
79
- /// Gets the maximum parallelism to use for dedup related downloads and uploads.
80
- /// </summary>
81
- /// <param name="context">Context which may specify overrides for max parallelism</param>
82
- /// <returns>max parallelism</returns>
83
- int GetDedupStoreClientMaxParallelism ( AgentTaskPluginExecutionContext context ) ;
84
73
}
85
74
86
75
public class DedupManifestArtifactClientFactory : IDedupManifestArtifactClientFactory
@@ -118,7 +107,6 @@ private DedupManifestArtifactClientFactory()
118
107
context . IsSystemDebugTrue ( ) ,
119
108
( str ) => context . Output ( str ) ,
120
109
connection ,
121
- DedupManifestArtifactClientFactory . Instance . GetDedupStoreClientMaxParallelism ( context ) ,
122
110
domainId ,
123
111
clientSettings ,
124
112
context ,
@@ -129,26 +117,22 @@ private DedupManifestArtifactClientFactory()
129
117
bool verbose ,
130
118
Action < string > traceOutput ,
131
119
VssConnection connection ,
132
- int maxParallelism ,
133
120
IDomainId domainId ,
134
121
BlobstoreClientSettings clientSettings ,
135
122
AgentTaskPluginExecutionContext context ,
136
123
CancellationToken cancellationToken )
137
124
{
138
125
const int maxRetries = 5 ;
139
126
var tracer = CreateArtifactsTracer ( verbose , traceOutput ) ;
140
- if ( maxParallelism == 0 )
141
- {
142
- maxParallelism = DefaultDedupStoreClientMaxParallelism ;
143
- }
127
+ int maxParallelism = DedupManifestArtifactClientFactory . Instance . GetDedupStoreClientMaxParallelism ( context , clientSettings ) ;
144
128
145
129
traceOutput ( $ "Max dedup parallelism: { maxParallelism } ") ;
146
130
traceOutput ( $ "DomainId: { domainId } ") ;
147
131
148
132
IDedupStoreHttpClient dedupStoreHttpClient = GetDedupStoreHttpClient ( connection , domainId , maxRetries , tracer , cancellationToken ) ;
149
133
150
134
var telemetry = new BlobStoreClientTelemetry ( tracer , dedupStoreHttpClient . BaseAddress ) ;
151
- HashType hashType = clientSettings . GetClientHashType ( context ) ;
135
+ HashType hashType = clientSettings . GetClientHashType ( context ) ;
152
136
153
137
if ( hashType == BuildXL . Cache . ContentStore . Hashing . HashType . Dedup1024K )
154
138
{
@@ -222,32 +206,37 @@ private static IDedupStoreHttpClient GetDedupStoreHttpClient(VssConnection conne
222
206
return ( client , telemetry ) ;
223
207
}
224
208
225
- public int GetDedupStoreClientMaxParallelism ( AgentTaskPluginExecutionContext context )
209
+ public int GetDedupStoreClientMaxParallelism ( AgentTaskPluginExecutionContext context , BlobstoreClientSettings clientSettings )
226
210
{
227
211
ConfigureEnvironmentVariables ( context ) ;
228
212
229
- int parallelism = DefaultDedupStoreClientMaxParallelism ;
230
-
231
- if ( context . Variables . TryGetValue ( "AZURE_PIPELINES_DEDUP_PARALLELISM" , out VariableValue v ) )
213
+ // prefer the pipeline variable over the client settings
214
+ if ( context . Variables . TryGetValue ( DedupParallelism , out VariableValue v ) )
232
215
{
233
- if ( ! int . TryParse ( v . Value , out parallelism ) )
234
- {
235
- context . Output ( $ "Could not parse the value of AZURE_PIPELINES_DEDUP_PARALLELISM, '{ v . Value } ', as an integer. Defaulting to { DefaultDedupStoreClientMaxParallelism } ") ;
236
- parallelism = DefaultDedupStoreClientMaxParallelism ;
237
- }
238
- else
216
+ if ( int . TryParse ( v . Value , out int parallelism ) )
239
217
{
240
218
context . Output ( $ "Overriding default max parallelism with { parallelism } ") ;
219
+ return parallelism ;
241
220
}
242
221
}
243
- else
222
+ return GetDedupStoreClientMaxParallelism ( clientSettings , msg => context . Output ( msg ) ) ;
223
+ }
224
+
225
+ public int GetDedupStoreClientMaxParallelism ( BlobstoreClientSettings clientSettings , Action < string > logOutput )
226
+ {
227
+ // if we have a client setting for max parallelism, use that:
228
+ int ? maxParallelism = clientSettings ? . GetMaxParallelism ( ) ;
229
+ if ( maxParallelism . HasValue )
244
230
{
245
- context . Output ( $ "Using default max parallelism.") ;
231
+ logOutput ( $ "Using max parallelism from client settings: { maxParallelism } ") ;
232
+ return maxParallelism . Value ;
246
233
}
247
-
248
- return parallelism ;
234
+ // if we get here, nothing left to do but use the default:
235
+ logOutput ( $ "Using default max parallelism.") ;
236
+ return DefaultDedupStoreClientMaxParallelism ;
249
237
}
250
238
239
+ public static string DedupParallelism = "AZURE_PIPELINES_DEDUP_PARALLELISM" ;
251
240
private static readonly string [ ] EnvironmentVariables = new [ ] { "VSO_DEDUP_REDIRECT_TIMEOUT_IN_SEC" } ;
252
241
253
242
private static void ConfigureEnvironmentVariables ( AgentTaskPluginExecutionContext context )
@@ -269,7 +258,6 @@ private static void ConfigureEnvironmentVariables(AgentTaskPluginExecutionContex
269
258
}
270
259
}
271
260
272
-
273
261
public static IAppTraceSource CreateArtifactsTracer ( bool verbose , Action < string > traceOutput )
274
262
{
275
263
return new CallbackAppTraceSource (
0 commit comments