Beispiel #1
0
        private void fetch(Entry[] entries)
        {
            var requests = entries.ToDictionary(x => x.Request.RequestId, x => x);
            var parameter = requests.Values.Select(x => x.Request).ToArray();

            try
            {
                var results = _storage.FetchEvent(parameter);

                //these can't fail as they're try operations.
                foreach (var requestId in requests.Keys)
                {
                    if (results.ContainsKey(requestId) == false)
                        requests[requestId].SignalNotFound();
                    else
                        requests[requestId].SignalResult(results[requestId]);
                }
            }
            catch (Exception e)
            {
                foreach (var entry in entries)
                    entry.Fail(e);
            }
        }
Beispiel #2
0
        private void store(Entry[] entries)
        {
            Logger.Debug("[StorageWriter] Writing entries.");
            var commits = entries.ToDictionary(x => x.Commit.CommitId, x => x);
            var commit = new CommitsForStorage(commits.Values.Select(x => x.Commit).ToArray());

            try
            {
                Logger.Debug("[StorageWriter] Storing {0} commits.", commit.Commits.Length);
                var results = _storage.Store(commit);
                Logger.Debug("[StorageWriter] Entries stored.");

                //these can't fail as they're try operations.
                foreach (var c in results.SuccessfulCommits)
                    commits[c].signalCompletion();

                foreach (var c in results.FailedDueToConcurrencyCommits)
                    commits[c].signalConcurrencyFailure();
            }
            catch (Exception e)
            {
                foreach (var entry in entries)
                    entry.Fail(e);
            }
            finally
            {
                commits.Clear();
            }
        }