/// <summary> /// Gets the MetadataPropertyCollection from raw byte array /// </summary> /// <param name="msg">The RelayMessage.</param> /// <returns></returns> internal static MetadataPropertyCollection GetMetadataPropertyCollection(RelayMessage msg) { MetadataPropertyCollection metadataPropertyCollection = null; if (msg.Payload != null) { metadataPropertyCollection = new MetadataPropertyCollection(); msg.GetObject(metadataPropertyCollection); } return(metadataPropertyCollection); }
/// <summary> /// Processes the update message. /// </summary> /// <param name="message">The message.</param> /// <param name="messageContext">The message context.</param> private void ProcessUpdateMessage(RelayMessage message, MessageContext messageContext) { lock (LockingUtil.Instance.GetLock(message.Id)) { try { CacheIndexUpdate cacheIndexUpdate = message.GetObject <CacheIndexUpdate>(); UpdateProcessor.Process(cacheIndexUpdate, messageContext, storeContext); } catch (Exception ex) { LoggingUtil.Log.ErrorFormat("TypeID {0} -- Error processing update message : {1}", message.TypeId, ex); throw new Exception("Error processing update message"); } } }
/// <summary> /// Processes the save message. /// </summary> /// <param name="message">The message.</param> /// <param name="messageContext">The message context.</param> private void ProcessSaveMessage(RelayMessage message, MessageContext messageContext) { SaveProcessor.Process(message.GetObject <CacheIndex>(), messageContext, storeContext); }
/// <summary> /// Gets the CacheIndexInternal. /// </summary> /// <param name="storeContext">The store context.</param> /// <param name="typeId">The type id.</param> /// <param name="primaryId">The primary id.</param> /// <param name="indexId">The index id.</param> /// <param name="extendedIdSuffix">The extended id suffix.</param> /// <param name="indexName">Name of the index.</param> /// <param name="count">The count.</param> /// <param name="filter">The filter.</param> /// <param name="inclusiveFilter">if set to <c>true</c> includes the items that pass the filter; otherwise , <c>false</c>.</param> /// <param name="indexCondition">The index condition.</param> /// <param name="deserializeHeaderOnly">if set to <c>true</c> if just CacheIndexInternal header is to be deserialized; otherwise, <c>false</c>.</param> /// <param name="getFilteredItems">if set to <c>true</c> get filtered items; otherwise, <c>false</c>.</param> /// <param name="primarySortInfo">The primary sort info.</param> /// <param name="localIdentityTagNames">The local identity tag names.</param> /// <param name="stringHashCodeDictionary">The string hash code dictionary.</param> /// <param name="capCondition">The cap condition.</param> /// <returns>CacheIndexInternal</returns> internal static CacheIndexInternal GetCacheIndexInternal(IndexStoreContext storeContext, short typeId, int primaryId, byte[] indexId, short extendedIdSuffix, string indexName, int count, Filter filter, bool inclusiveFilter, IndexCondition indexCondition, bool deserializeHeaderOnly, bool getFilteredItems, PrimarySortInfo primarySortInfo, List<string> localIdentityTagNames, Dictionary<int, bool> stringHashCodeDictionary, CapCondition capCondition) { CacheIndexInternal cacheIndexInternal = null; byte[] extendedId = FormExtendedId(indexId, extendedIdSuffix); RelayMessage getMsg = new RelayMessage(typeId, primaryId, extendedId, MessageType.Get); storeContext.IndexStorageComponent.HandleMessage(getMsg); if (getMsg.Payload != null) //CacheIndex exists { cacheIndexInternal = new CacheIndexInternal { InDeserializationContext = new InDeserializationContext { TypeId = getMsg.TypeId, TagHashCollection = storeContext.TagHashCollection, IndexId = indexId, IndexName = indexName, MaxItemsPerIndex = count, Filter = filter, InclusiveFilter = inclusiveFilter, IndexCondition = indexCondition, DeserializeHeaderOnly = deserializeHeaderOnly, CollectFilteredItems = getFilteredItems, PrimarySortInfo = primarySortInfo, LocalIdentityTagNames = localIdentityTagNames, StringHashCollection = storeContext.StringHashCollection, StringHashCodeDictionary = stringHashCodeDictionary, CapCondition = capCondition } }; // This mess is required until Moods 2.0 migrated to have IVersionSerializable version of CacheIndexInternal // ** TBD - Should be removed later if (LegacySerializationUtil.Instance.IsSupported(getMsg.TypeId)) { MemoryStream stream = new MemoryStream(getMsg.Payload.ByteArray); cacheIndexInternal.Deserialize(new CompactBinaryReader(stream)); } else { getMsg.GetObject(cacheIndexInternal); } } return cacheIndexInternal; }
/// <summary> /// Gets the CacheIndexInternal. /// </summary> /// <param name="storeContext">The store context.</param> /// <param name="typeId">The type id.</param> /// <param name="primaryId">The primary id.</param> /// <param name="indexId">The index id.</param> /// <param name="extendedIdSuffix">The extended id suffix.</param> /// <param name="indexName">Name of the index.</param> /// <param name="count">The count.</param> /// <param name="filter">The filter.</param> /// <param name="inclusiveFilter">if set to <c>true</c> includes the items that pass the filter; otherwise , <c>false</c>.</param> /// <param name="indexCondition">The index condition.</param> /// <param name="deserializeHeaderOnly">if set to <c>true</c> if just CacheIndexInternal header is to be deserialized; otherwise, <c>false</c>.</param> /// <param name="getFilteredItems">if set to <c>true</c> get filtered items; otherwise, <c>false</c>.</param> /// <param name="primarySortInfo">The primary sort info.</param> /// <param name="localIdentityTagNames">The local identity tag names.</param> /// <param name="stringHashCodeDictionary">The string hash code dictionary.</param> /// <param name="capCondition">The cap condition.</param> /// <returns>CacheIndexInternal</returns> internal static CacheIndexInternal GetCacheIndexInternal(IndexStoreContext storeContext, short typeId, int primaryId, byte[] indexId, short extendedIdSuffix, string indexName, int count, Filter filter, bool inclusiveFilter, IndexCondition indexCondition, bool deserializeHeaderOnly, bool getFilteredItems, PrimarySortInfo primarySortInfo, List <string> localIdentityTagNames, Dictionary <int, bool> stringHashCodeDictionary, CapCondition capCondition) { CacheIndexInternal cacheIndexInternal = null; byte[] extendedId = FormExtendedId(indexId, extendedIdSuffix); RelayMessage getMsg = new RelayMessage(typeId, primaryId, extendedId, MessageType.Get); storeContext.IndexStorageComponent.HandleMessage(getMsg); if (getMsg.Payload != null) //CacheIndex exists { cacheIndexInternal = new CacheIndexInternal { InDeserializationContext = new InDeserializationContext { TypeId = getMsg.TypeId, TagHashCollection = storeContext.TagHashCollection, IndexId = indexId, IndexName = indexName, MaxItemsPerIndex = count, Filter = filter, InclusiveFilter = inclusiveFilter, IndexCondition = indexCondition, DeserializeHeaderOnly = deserializeHeaderOnly, CollectFilteredItems = getFilteredItems, PrimarySortInfo = primarySortInfo, LocalIdentityTagNames = localIdentityTagNames, StringHashCollection = storeContext.StringHashCollection, StringHashCodeDictionary = stringHashCodeDictionary, CapCondition = capCondition } }; // This mess is required until Moods 2.0 migrated to have IVersionSerializable version of CacheIndexInternal // ** TBD - Should be removed later if (LegacySerializationUtil.Instance.IsSupported(getMsg.TypeId)) { MemoryStream stream = new MemoryStream(getMsg.Payload.ByteArray); cacheIndexInternal.Deserialize(new CompactBinaryReader(stream)); } else { getMsg.GetObject(cacheIndexInternal); } } return(cacheIndexInternal); }
/// <summary> /// Processes the save message. /// </summary> /// <param name="message">The message.</param> /// <param name="messageContext">The message context.</param> private void ProcessSaveMessage(RelayMessage message, MessageContext messageContext) { SaveProcessor.Process(message.GetObject<CacheIndex>(), messageContext, storeContext); }
/// <summary> /// Processes the update message. /// </summary> /// <param name="message">The message.</param> /// <param name="messageContext">The message context.</param> private void ProcessUpdateMessage(RelayMessage message, MessageContext messageContext) { lock (LockingUtil.Instance.GetLock(message.Id)) { try { CacheIndexUpdate cacheIndexUpdate = message.GetObject<CacheIndexUpdate>(); UpdateProcessor.Process(cacheIndexUpdate, messageContext, storeContext); } catch (Exception ex) { LoggingUtil.Log.ErrorFormat("TypeID {0} -- Error processing update message : {1}", message.TypeId, ex); throw new Exception("Error processing update message"); } } }