/// <summary> /// This method find the index update generator of a given index /// identified by the indexed grain interface type and the name of the index /// </summary> /// <typeparam name="T">type of the indexed grain interface</typeparam> /// <param name="gf">the grain factory instance</param> /// <param name="indexName">>the name of the index</param> /// <returns>the index update generator of the index</returns> internal static IIndexUpdateGenerator GetIndexUpdateGenerator <T>(this IGrainFactory gf, string indexName) where T : IIndexableGrain { Tuple <object, object, object> output; if (!(IndexHandler.GetIndexes <T>()).TryGetValue(indexName, out output)) { throw new Exception(string.Format("Index \"{0}\" does not exist on {1}.", indexName, typeof(T))); } return((IIndexUpdateGenerator)output.Item3); }
private IDictionary <string, Tuple <object, object, object> > InitIndexes() { __indexes = IndexHandler.GetIndexes(_iGrainType); foreach (var idxInfo in __indexes.Values) { if (idxInfo.Item1 is TotalIndex) { _hasAnyTotalIndex = true; return(__indexes); } } return(__indexes); }
private bool InitHasAnyTotalIndex() { var indexes = IndexHandler.GetIndexes(_iGrainType); foreach (var idxInfo in indexes.Values) { if (idxInfo.Item1 is TotalIndex) { __hasAnyTotalIndex = 1; return(true); } } __hasAnyTotalIndex = -1; return(false); }
/// <summary> /// Upon activation, the list of index update generators /// is retrieved from the index handler. It is cached in /// this grain for use in creating before-images, and also /// for later calls to UpdateIndexes. /// /// Then, the before-images are created and stored in memory. /// </summary> public override Task OnActivateAsync() { if (logger.IsVerbose) { logger.Verbose("Activating indexable grain {0} of type {1} in silo {2}.", Orleans.GrainExtensions.GetGrainId(this), GetIIndexableGrainTypes()[0], RuntimeAddress); } //load indexes _iUpdateGens = IndexHandler.GetIndexes(GetIIndexableGrainTypes()[0]); //initialized _isThereAnyUniqueIndex field InitUniqueIndexCheck(); //Initialize before images _beforeImages = new Dictionary <string, object>().AsImmutable <IDictionary <string, object> >(); AddMissingBeforeImages(); //insert the current grain to the active indexes defined on this grain //and at the same time call OnActivateAsync of the base class return(Task.WhenAll(InsertIntoActiveIndexes(), base.OnActivateAsync())); }