-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve listing performance for transfer whose source is Azure File D…
…irectory.
- Loading branch information
Showing
31 changed files
with
2,124 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
//------------------------------------------------------------------------------ | ||
// <copyright file="DirectoryListingScheduler.cs" company="Microsoft"> | ||
// Copyright (c) Microsoft Corporation | ||
// </copyright> | ||
//------------------------------------------------------------------------------ | ||
|
||
|
||
namespace Microsoft.Azure.Storage.DataMovement | ||
{ | ||
using System; | ||
using System.Collections.Concurrent; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1001:TypesThatOwnDisposableFieldsShouldBeDisposable")] | ||
class DirectoryListingScheduler | ||
{ | ||
SemaphoreSlim semaphore = null; | ||
private static DirectoryListingScheduler SchedulerInstance = null; | ||
private static object SingletonLock = new object(); | ||
|
||
private DirectoryListingScheduler() | ||
{ | ||
int parallelLevel = TransferManager.Configurations.ParallelOperations; | ||
parallelLevel = (int)Math.Ceiling(((double)parallelLevel) / 8); | ||
semaphore = new SemaphoreSlim(parallelLevel, parallelLevel); | ||
} | ||
|
||
public static DirectoryListingScheduler Instance() | ||
{ | ||
if (null == SchedulerInstance) | ||
{ | ||
lock (SingletonLock) | ||
{ | ||
if (null == SchedulerInstance) | ||
{ | ||
SchedulerInstance = new DirectoryListingScheduler(); | ||
} | ||
} | ||
} | ||
|
||
return SchedulerInstance; | ||
} | ||
|
||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] | ||
public Task Schedule( | ||
SubDirectoryTransfer directoryTransfer, | ||
CancellationToken cancellationToken, | ||
Action persistDirTransfer, | ||
int timeOut) | ||
{ | ||
if (this.semaphore.Wait(timeOut, cancellationToken)) | ||
{ | ||
try | ||
{ | ||
if (null != persistDirTransfer) | ||
{ | ||
persistDirTransfer(); | ||
} | ||
} | ||
catch | ||
{ | ||
this.semaphore.Release(); | ||
throw; | ||
} | ||
|
||
Task task = directoryTransfer.ExecuteAsync(null, cancellationToken); | ||
task.ContinueWith((sourceTask) => | ||
{ | ||
this.semaphore.Release(); | ||
return sourceTask; | ||
}); | ||
|
||
return task; | ||
} | ||
else | ||
{ | ||
return null; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.