X-Git-Url: https://code.grnet.gr/git/pithos-ms-client/blobdiff_plain/732276d38a005d6f9f9e65f86df1dcef6f3dfa0c..76686dfe41f0300129799b81716d715406703cd6:/trunk/Pithos.Core/Agents/PollAgent.cs
diff --git a/trunk/Pithos.Core/Agents/PollAgent.cs b/trunk/Pithos.Core/Agents/PollAgent.cs
index 3336406..476f904 100644
--- a/trunk/Pithos.Core/Agents/PollAgent.cs
+++ b/trunk/Pithos.Core/Agents/PollAgent.cs
@@ -204,11 +204,13 @@ namespace Pithos.Core.Agents
///
/// Start a manual synchronization
///
- public void SynchNow()
+ public void SynchNow(IEnumerable paths=null)
{
+ _batchQueue.Enqueue(paths);
_syncEvent.Set();
}
+ readonly ConcurrentQueue> _batchQueue=new ConcurrentQueue>();
///
/// Remote files are polled periodically. Any changes are processed
@@ -233,8 +235,23 @@ namespace Pithos.Core.Agents
await _unPauseEvent.WaitAsync();
UpdateStatus(PithosStatus.PollSyncing);
- var tasks = from accountInfo in _accounts.Values
- select ProcessAccountFiles(accountInfo, since);
+ var accountBatches=new Dictionary>();
+ IEnumerable batch = null;
+ if (_batchQueue.TryDequeue(out batch) && batch != null)
+ foreach (var account in _accounts.Values)
+ {
+ var accountBatch = batch.Where(path => path.IsAtOrBelow(account.AccountPath));
+ accountBatches[account.AccountKey] = accountBatch;
+ }
+
+
+ IEnumerable> tasks = new List>();
+ foreach(var accountInfo in _accounts.Values)
+ {
+ IEnumerable accountBatch ;
+ accountBatches.TryGetValue(accountInfo.AccountKey,out accountBatch);
+ ProcessAccountFiles (accountInfo, accountBatch, since);
+ }
var nextTimes=await TaskEx.WhenAll(tasks.ToList());
@@ -298,7 +315,7 @@ namespace Pithos.Core.Agents
return since;
}
- public async Task ProcessAccountFiles(AccountInfo accountInfo, DateTime? since = null)
+ public async Task ProcessAccountFiles(AccountInfo accountInfo, IEnumerable accountBatch, DateTime? since = null)
{
if (accountInfo == null)
throw new ArgumentNullException("accountInfo");
@@ -414,8 +431,9 @@ namespace Pithos.Core.Agents
var tuples = MergeSources(infos, files, states).ToList();
-
- foreach (var tuple in tuples)
+
+ var stateTuples = accountBatch==null?tuples:tuples.Where(t => accountBatch.Contains(t.FilePath));
+ foreach (var tuple in stateTuples)
{
await _unPauseEvent.WaitAsync();