Example #1
0
        private async Task OnDictionaryRebuildNotificationHandlerAsync(
            object sender,
            NotifyDictionaryRebuildEventArgs <long, WinFabPersistence.PersistedData> rebuildNotification)
        {
            var enumerator = rebuildNotification.State.GetAsyncEnumerator();

            await this.ProcessDictionaryRebuild(enumerator);
        }
Example #2
0
        public Task OnDictionaryRebuildNotificationHandlerAsync <TKey, TValue>(
            IReliableDictionary <TKey, TValue> origin,
            NotifyDictionaryRebuildEventArgs <TKey, TValue> rebuildNotification)
            where TKey : IComparable <TKey>, IEquatable <TKey>
        {
            // Not handling Rebuild event now.
            return(Task.CompletedTask);

            // this.changeCollector.CreateNew();
            // var enumerator = rebuildNotification.State.GetAsyncEnumerator();
            // // We will send the event as it is. But the previousLsn and nextLsn would be -1.
            // var rebuildEvent = new NotifyRebuildEvent<TKey, TValue>(origin.Name.ToString(), rebuildNotification.State);
            // Byte[] byteStream = messageConverter.Serialize(rebuildEvent);
            // // handle the error case here.
            // return EventCollector.TransactionApplied(this.partitionId, -1, -1, byteStream);
        }
Example #3
0
        /// <summary>
        /// Called when the dictionary rebuild notification is triggered.
        /// We use this to rebuild our secondary index.
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="rebuildNotification"></param>
        /// <returns></returns>
        private async Task OnDictionaryRebuildNotificationHandlerAsync(
            IReliableDictionary <string, Order> origin,
            NotifyDictionaryRebuildEventArgs <string, Order> rebuildNotification)
        {
            lock (this.lockObject)
            {
                this.SecondaryIndex = this.SecondaryIndex.Clear();
            }

            var enumerator = rebuildNotification.State.GetAsyncEnumerator();

            while (await enumerator.MoveNextAsync(CancellationToken.None))
            {
                lock (this.lockObject)
                {
                    this.SecondaryIndex = this.SecondaryIndex.Add(enumerator.Current.Value);
                }
            }
        }