public void Add(string storeName, IIndexStore store, INodeReference node) { IndexStoreInformation ni = new IndexStoreInformation(storeName, store, node); if (_nodeInfo == null) { _nodeInfo = ni; _nodeInfoMaxCount = _nodeInfoMaxCount < 1 ? (ushort)1 : _nodeInfoMaxCount; } else { if (_nodeInfo is IndexStoreInformation) { ClusteredList <IndexStoreInformation> _list = new ClusteredList <IndexStoreInformation>(); _list.Add((IndexStoreInformation)_nodeInfo); _list.Add(ni); _nodeInfo = _list; if (_list.Count > _nodeInfoMaxCount) { _nodeInfoMaxCount = (ushort)_list.Count; } } else { ClusteredList <IndexStoreInformation> _list = ((ClusteredList <IndexStoreInformation>)_nodeInfo); _list.Add(ni); if (_list.Count > _nodeInfoMaxCount) { _nodeInfoMaxCount = (ushort)_list.Count; } } } _indexInformationSize += (ushort)ni.IndexInMemorySize; }
public void Add(string storeName, IIndexStore store, INodeReference node) { IndexStoreInformation ni = new IndexStoreInformation(storeName, store, node); if (_nodeInfo == null) { _nodeInfo = ni; _nodeInfoMaxCount = _nodeInfoMaxCount < 1 ? (ushort)1 : _nodeInfoMaxCount; } else { if (_nodeInfo is IndexStoreInformation) { ClusteredList<IndexStoreInformation> _list = new ClusteredList<IndexStoreInformation>(); _list.Add((IndexStoreInformation)_nodeInfo); _list.Add(ni); _nodeInfo = _list; if (_list.Count > _nodeInfoMaxCount) _nodeInfoMaxCount = (ushort)_list.Count; } else { ClusteredList<IndexStoreInformation> _list = ((ClusteredList<IndexStoreInformation>)_nodeInfo); _list.Add(ni); if (_list.Count > _nodeInfoMaxCount) _nodeInfoMaxCount = (ushort)_list.Count; } } _indexInformationSize += (ushort)ni.IndexInMemorySize; }
public void Update(ContinuousQuery query, string clientId, string clientUniqueId, bool notifyAdd, bool notifyUpdate, bool notifyRemove, QueryDataFilters datafilters) { lock (this) { if (clientRefs.ContainsKey(query.UniqueId)) { HashVector cRefs = (HashVector)clientRefs[query.UniqueId]; if (cRefs.ContainsKey(clientId)) { ClusteredList <string> refs = (ClusteredList <string>)cRefs[clientId]; if (!refs.Contains(clientUniqueId)) { refs.Add(clientUniqueId); } } else { ClusteredList <string> clientUniqueIds = new ClusteredList <string>(); clientUniqueIds.Add(clientUniqueId); cRefs[clientId] = clientUniqueIds; } UpdateNotifications(notifyAdd, clientId, query.UniqueId, clientUniqueId, addNotifications, datafilters.AddDataFilter, maxAddDFAgainstCID, addDFAgainstCUniqueID); UpdateNotifications(notifyUpdate, clientId, query.UniqueId, clientUniqueId, updateNotifications, datafilters.UpdateDataFilter, maxUpdateDFAgainstCID, updateDFAgainstCUniqueID); UpdateNotifications(notifyRemove, clientId, query.UniqueId, clientUniqueId, removeNotifications, datafilters.RemoveDataFilter, maxRemoveDFAgainstCID, removeDFAgainstCUniqueID); } } }
public void Register(ContinuousQuery query, string clientId, string clientUniqueId, bool notifyAdd, bool notifyUpdate, bool notifyRemove, QueryDataFilters datafilters) { lock (this) { if (!Exists(query)) { registeredQueries.Add(query); HashVector refs = new HashVector(); ClusteredList <string> clientUniqueIds = new ClusteredList <string>(); clientUniqueIds.Add(clientUniqueId); refs[clientId] = clientUniqueIds; clientRefs[query.UniqueId] = refs; RegisterNotifications(notifyAdd, clientId, query.UniqueId, clientUniqueId, addNotifications, datafilters.AddDataFilter, maxAddDFAgainstCID, addDFAgainstCUniqueID); RegisterNotifications(notifyUpdate, clientId, query.UniqueId, clientUniqueId, updateNotifications, datafilters.UpdateDataFilter, maxUpdateDFAgainstCID, updateDFAgainstCUniqueID); RegisterNotifications(notifyRemove, clientId, query.UniqueId, clientUniqueId, removeNotifications, datafilters.RemoveDataFilter, maxRemoveDFAgainstCID, removeDFAgainstCUniqueID); } else { Update(query, clientId, clientUniqueId, notifyAdd, notifyUpdate, notifyRemove, datafilters); } } }
/// <summary> /// Add an expiration hint to the hints /// </summary> /// <param name="eh"></param> public void Add(ExpirationHint eh) { lock (this) { if (!eh.IsRoutable) { this.SetBit(NON_ROUTABLE); } if (eh.IsVariant) { this.SetBit(IS_VARIANT); } eh.SetExpirationEventSink(this); AggregateExpirationHint aggregate = eh as AggregateExpirationHint; if (aggregate != null) { foreach (ExpirationHint expirationHint in aggregate._hints) { _hints.Add(expirationHint); } } else { _hints.Add(eh); } bool isFixed = false; for (int i = _hints.Count - 1; i >= 0; i--) { if (isFixed && _hints[i] is FixedExpiration) { var previousFixedExpiration = _hints[i]; _hints.RemoveAt(i); previousFixedExpiration.ReturnLeasableToPool(); break; } if (!isFixed && _hints[i] is FixedExpiration) { isFixed = true; } } } }
public virtual ClusteredList <ReaderResultSet> ExecuteReader(string query, IDictionary values, bool getData, int chunkSize, bool isInproc, OperationContext operationContext) { ReaderResultSet result = InternalCache.Local_ExecuteReader(query, values, getData, chunkSize, isInproc, operationContext); ClusteredList <ReaderResultSet> resultList = new ClusteredList <ReaderResultSet>(); if (result != null) { resultList.Add(result); } return(resultList); }
internal static IList PackageKeys(IEnumerator enumerator) { int estimatedSize = 0; IList ListOfKeyPackage = new ClusteredArrayList(); IList <string> keysChunkList = new ClusteredList <string>(); if (enumerator is IDictionaryEnumerator) { IDictionaryEnumerator ide = enumerator as IDictionaryEnumerator; while (ide.MoveNext()) { keysChunkList.Add((string)ide.Key); estimatedSize = estimatedSize + (((string)ide.Key).Length * sizeof(Char)); if (estimatedSize >= ServiceConfiguration.ResponseDataSize) //If size is greater than specified size then add it and create new chunck { ListOfKeyPackage.Add(keysChunkList); keysChunkList = new ClusteredList <string>(); estimatedSize = 0; } } if (estimatedSize != 0) { ListOfKeyPackage.Add(keysChunkList); } } else { while (enumerator.MoveNext()) { keysChunkList.Add((string)enumerator.Current); estimatedSize = estimatedSize + (((string)enumerator.Current).Length * sizeof(Char)); if (estimatedSize >= ServiceConfiguration.ResponseDataSize) //If size is greater than specified size then add it and create new chunck { ListOfKeyPackage.Add(keysChunkList); keysChunkList = new ClusteredList <string>(); estimatedSize = 0; } } if (estimatedSize != 0) { ListOfKeyPackage.Add(keysChunkList); } } if (ListOfKeyPackage.Count <= 0) { ListOfKeyPackage.Add(keysChunkList); } return(ListOfKeyPackage); }
internal ClusteredList <string> GetExpiredKeys() { ClusteredList <string> selectedKeys = new ClusteredList <string>(); IEnumerator <KeyValuePair <string, DateTime> > em = _expirationIndex.GetEnumerator(); if (em != null) { while (em.MoveNext()) { DateTime absoluteExpiration = em.Current.Value; if (absoluteExpiration <= DateTime.UtcNow) { selectedKeys.Add(em.Current.Key); } } } return(selectedKeys); }
public static ClusteredList <T> DeserializeClusteredList <T>(Runtime.Serialization.IO.CompactReader reader) { bool flag = reader.ReadBoolean(); if (flag) { int length = reader.ReadInt32(); ClusteredList <T> list = new ClusteredList <T>(); for (int i = 0; i < length; i++) { list.Add((T)reader.ReadObject()); } return(list); } else { return(null); } }
private void RegisterNotifications(bool notify, string clientId, string serverUniqueId, string clientUniqueId, HashVector notifications , EventDataFilter datafilter, HashVector CID, HashVector CUID) { if (notify) { HashVector clients = new HashVector(); ClusteredList <string> clientUniqueIds = new ClusteredList <string>(); clientUniqueIds.Add(clientUniqueId); clients[clientId] = clientUniqueIds; notifications[serverUniqueId] = clients; //Adding the max datafilter requirement CID[serverUniqueId] = new HashVector(); ((IDictionary)CID[serverUniqueId]).Add(clientId, datafilter); //Adding the cid in the datafilter requirements CUID[clientId] = new HashVector(); ((IDictionary)CUID[clientId]).Add(clientUniqueId, datafilter); } }
public void PersistOperation(long operationId) { IList <IndexOp <long> > opToCommit; if (opsToCommit.TryGetValue(operationId, out opToCommit)) { foreach (var op in opToCommit) { switch (op.OperationType) { case OpType.Insert: _tree.Add(op.Key, op.RowId); break; case OpType.Remove: _tree.TryRemove(op.Key, op.RowId); break; } } appliedOps.Add(operationId); } }
protected sealed override void DeepCloneInternal(PoolManager poolManager, ExpirationHint clonedHint) { if (clonedHint == null) { return; } base.DeepCloneInternal(poolManager, clonedHint); if (clonedHint is AggregateExpirationHint clonedAggregateExpirationHint) { if (_hints != null) { var clonedHints = new ClusteredList <ExpirationHint>(_hints.Count); foreach (var hint in _hints) { clonedHints.Add(hint.DeepClone(poolManager)); } clonedAggregateExpirationHint._hints = clonedHints; } clonedAggregateExpirationHint._expiringHint = _expiringHint?.DeepClone(poolManager); } }
public void Add(T result) { _results.Add(result); }
internal static ClusteredList <List <Common.Protobuf.Message> > GetMessages(IList <object> result, NCache nCache, string clientId) { int estimatedSize = 0; var listOfMessages = new ClusteredList <List <Common.Protobuf.Message> >(); if (result != null && result.Count > 0) { var messagesList = new List <Common.Protobuf.Message>(); var enu = result.GetEnumerator(); while (enu.MoveNext()) { if (enu.Current == null) { continue; } var cachingMessage = (Message)enu.Current; var protobufMessage = new Common.Protobuf.Message(); if (cachingMessage.PayLoad != null) // Message is a user'smessage and not an event message { var value = new Common.Protobuf.Value(); var ubObject = default(UserBinaryObject); var binaryObject = cachingMessage.PayLoad as UserBinaryObject; if (binaryObject != null) { ubObject = binaryObject; } if (ubObject != default(UserBinaryObject)) { value.data.AddRange(ubObject.DataList); estimatedSize = ubObject.Size + cachingMessage.MessageId.Length * sizeof(char); } protobufMessage.payload = value; } else // Message is an event message and not a user's message { protobufMessage.internalPayload = new Common.Protobuf.InternalPayload(); estimatedSize = estimatedSize + cachingMessage.MessageId.Length * sizeof(char); if (cachingMessage is EventMessage) { var cachingEventMessage = (EventMessage)cachingMessage; var protobufEventMessage = CreateProtobufEventMessage(nCache, cachingEventMessage, clientId); protobufMessage.internalPayload.eventMessage = protobufEventMessage; protobufMessage.internalPayload.payloadType = Common.Protobuf.InternalPayload.PayloadType.CACHE_ITEM_EVENTS; } } protobufMessage.flag = cachingMessage.FlagMap.Data; protobufMessage.messageId = cachingMessage.MessageId; protobufMessage.creationTime = cachingMessage.CreationTime.Ticks; protobufMessage.expirationTime = cachingMessage.MessageMetaData.ExpirationTime; protobufMessage.deliveryOption = (int)cachingMessage.MessageMetaData.DeliveryOption; protobufMessage.subscriptionType = (int)cachingMessage.MessageMetaData.SubscriptionType; protobufMessage.messageRemoveReason = (int)cachingMessage.MessageMetaData.MessgeFailureReason; if (cachingMessage.MessageMetaData.RecepientList != null) { protobufMessage.recipientList.AddRange(cachingMessage.MessageMetaData.RecepientList); } if (cachingMessage.MessageMetaData.SubscriptionIdentifierList != null) { protobufMessage.subscriptionIdentifiers.AddRange(GetSubscriptionIds(cachingMessage.MessageMetaData.SubscriptionIdentifierList)); } messagesList.Add(protobufMessage); if (estimatedSize >= ServiceConfiguration.ResponseDataSize) // If size is greater than specified size then add it and create new chunk { listOfMessages.Add(messagesList); messagesList = new List <Common.Protobuf.Message>(); estimatedSize = 0; } } if (estimatedSize != 0) { listOfMessages.Add(messagesList); } } else { listOfMessages.Add(new List <Common.Protobuf.Message>()); } return(listOfMessages); }
private void UpdateNotifications(bool notify, string clientId, string serverUniqueId, string clientUniqueId, HashVector notifications , EventDataFilter datafilters, HashVector CID, HashVector CUID) { if (notify) { if (notifications.ContainsKey(serverUniqueId)) { HashVector clients = notifications[serverUniqueId] as HashVector; if (clients.ContainsKey(clientId)) //New Query from same client { ClusteredList <string> clientQueries = clients[clientId] as ClusteredList <string>; if (!clientQueries.Contains(clientUniqueId)) { clientQueries.Add(clientUniqueId); } } else //new client { ClusteredList <string> clientUniqueIds = new ClusteredList <string>(); clientUniqueIds.Add(clientUniqueId); clients[clientId] = clientUniqueIds; } } else //New Query altogether { HashVector clients = new HashVector(); ClusteredList <string> clientUniqueIds = new ClusteredList <string>(); clientUniqueIds.Add(clientUniqueId); clients[clientId] = clientUniqueIds; notifications[serverUniqueId] = clients; } #region DataFilters registration //updating clientUIDs HashVector clientUIDs = null; if (CUID.ContainsKey(clientId)) { clientUIDs = CUID[clientId] as HashVector; } else { CUID[clientId] = clientUIDs = new HashVector(); } clientUIDs[clientUniqueId] = datafilters; //updating Max values HashVector clientDF = null; if (CID.ContainsKey(serverUniqueId)) { clientDF = CID[serverUniqueId] as HashVector; } else { CID[serverUniqueId] = clientDF = new HashVector(); } EventDataFilter max = EventDataFilter.None; IDictionaryEnumerator ide = clientUIDs.GetEnumerator(); while (ide.MoveNext()) { if (((EventDataFilter)ide.Value) > max) { max = (EventDataFilter)ide.Value; } } if (!clientDF.ContainsKey(clientId) || ((EventDataFilter)clientDF[clientId]) < max) { clientDF[clientId] = max; } #endregion } else //Not to be notified then remove it { if (notifications.ContainsKey(serverUniqueId)) { HashVector clients = notifications[serverUniqueId] as HashVector; if (clients.ContainsKey(clientId)) { ClusteredList <string> clientQueries = clients[clientId] as ClusteredList <string>; if (clientQueries.Contains(clientUniqueId)) { clientQueries.Remove(clientUniqueId); if (clientQueries.Count == 0) { clients.Remove(clientId); } } } } UnregisterDataFilter(serverUniqueId, clientId, clientUniqueId, CID, CUID); } }
internal static ClusteredList <List <Common.Protobuf.Message> > GetMessages(IList <object> result) { int estimatedSize = 0; ClusteredList <List <Common.Protobuf.Message> > ListOfMessagesResponse = new ClusteredList <List <Common.Protobuf.Message> >(); if (result != null && result.Count > 0) { List <Common.Protobuf.Message> messagesList = new List <Common.Protobuf.Message>(); IEnumerator <object> enu = result.GetEnumerator(); while (enu.MoveNext()) { var message = new Common.Protobuf.Message(); var value = new Common.Protobuf.Value(); var entry = (Message)enu.Current; BitSet flag = entry.FlagMap; UserBinaryObject ubObject = null; if (entry != null) { var binaryObject = entry.PayLoad as UserBinaryObject; if (binaryObject != null) { ubObject = binaryObject; } } if (ubObject != null) { value.data.AddRange(ubObject.DataList); estimatedSize = estimatedSize + ubObject.Size + entry.MessageId.Length * sizeof(char); } message.messageId = entry.MessageId; message.flag = flag.Data; message.payload = value; message.creationTime = entry.CreationTime.Ticks; message.expirationTime = entry.MessageMetaData.ExpirationTime; message.deliveryOption = (int)entry.MessageMetaData.DeliveryOption; message.subscriptionType = (int)entry.MessageMetaData.SubscriptionType; message.messageRemoveReason = (int)entry.MessageMetaData.MessgeFailureReason; if (entry.MessageMetaData.RecepientList != null) { message.recipientList.AddRange(entry.MessageMetaData.RecepientList); } messagesList.Add(message); if (estimatedSize >= ServiceConfiguration.ResponseDataSize) // If size is greater than specified size then add it and create new chunck { ListOfMessagesResponse.Add(messagesList); messagesList = new List <Common.Protobuf.Message>(); estimatedSize = 0; } } if (estimatedSize != 0) { ListOfMessagesResponse.Add(messagesList); } } else { ListOfMessagesResponse.Add(new List <Common.Protobuf.Message>()); } return(ListOfMessagesResponse); }