Changed the retry function in PithosClient to use the TPL
[pithos-ms-client] / trunk / Pithos.Core / InMemStatusChecker.cs
index b5862c6..8bae384 100644 (file)
@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using System.ComponentModel.Composition;
 using System.Diagnostics.Contracts;
 using System.Linq;
+using System.Threading;
 using Pithos.Interfaces;
 
 namespace Pithos.Core
@@ -73,6 +74,38 @@ namespace Pithos.Core
             return _pithosStatus;
         }
 
+    public void SetStatus(string path, Action<FileState> setter)
+        {
+            throw new NotImplementedException();
+        }
+
+        ConcurrentDictionary<string, NetworkState> _networkState = new ConcurrentDictionary<string, NetworkState>();
+
+    
+        public void SetNetworkState(string path, NetworkState state)
+        {
+            _networkState[path.ToLower()] = state;
+            //Removing may fail so we store the "None" value anyway
+            if (state == NetworkState.None)
+            {
+                NetworkState oldState;
+                _networkState.TryRemove(path, out oldState);
+            }
+        }
+
+        public NetworkState GetNetworkState(string path)
+        {
+            NetworkState state;
+            if (_networkState.TryGetValue(path, out state))
+                return state;
+            return NetworkState.None;
+        }
+
+        public void StartProcessing(CancellationToken token)
+        {
+            
+        }
+
         public void SetFileOverlayStatus(string path, FileOverlayStatus overlayStatus)
         {
             _overlayCache[path] = overlayStatus;
@@ -97,6 +130,33 @@ namespace Pithos.Core
             _statusCache[path] = status;
         }
 
+        public void SetFileState(string path, FileStatus fileStatus, FileOverlayStatus overlayStatus)
+        {
+            if (String.IsNullOrWhiteSpace(path))
+                throw new ArgumentNullException("path","path can't be empty");
+            _statusCache[path] = fileStatus;
+            _overlayCache[path] = overlayStatus;
+        }
+
+        public void StoreInfo(string path, ObjectInfo objectInfo)
+        {
+            if (String.IsNullOrWhiteSpace(path))
+                throw new ArgumentNullException("path", "path can't be empty");
+            if (objectInfo == null)
+                throw new ArgumentNullException("objectInfo", "objectInfo can't be empty");
+
+            _statusCache[path] = FileStatus.Unchanged;
+            _overlayCache[path] = FileOverlayStatus.Normal;
+            _checksums[path] = objectInfo.Hash;
+
+
+        }
+
+        public T GetStatus<T>(string path, Func<FileState, T> getter, T defaultValue)
+        {
+            throw new NotImplementedException();
+        }
+
         public FileStatus GetFileStatus(string path)
         {
             if (!_statusCache.ContainsKey(path))