コード例 #1
0
        //PROTOBUF
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            CommandInfo cmdInfo;

            try
            {
                cmdInfo = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
                return;
            }

            //TODO
            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                ClusteredList <ReaderResultSet>            resultSetList    = null;
                Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                //client id
                operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID);
                resultSetList = nCache.Cache.ExecuteReader(cmdInfo.Query, cmdInfo.Values, cmdInfo.GetData, cmdInfo.ChunkSize, false, operationContext);
                ReaderResponseBuilder.Cache = nCache.Cache;
                ReaderResponseBuilder.BuildExecuteReaderResponse(resultSetList, cmdInfo.RequestId, _serializedResponsePackets);
            }
            catch (Exception exc)
            {
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID));
            }
        }
コード例 #2
0
 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;
 }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        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);
                }
            }
        }
コード例 #5
0
        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;
        }
コード例 #6
0
        public static void BuildResponse(IDictionary <string, IList <object> > getResult, int commandVersion, string requestStringId, IList serializedResponse, int commandId, Cache cache)
        {
            Util.KeyPackageBuilder.Cache = cache;
            int  numberOfChunks = 0;
            int  sequenceId     = 1;
            long requestId      = Convert.ToInt64(requestStringId);

            HashVector <string, ClusteredList <List <Message> > > resultInChunks = new HashVector <string, ClusteredList <List <Message> > >();

            foreach (var pair in getResult)
            {
                var messageListChunks = Util.KeyPackageBuilder.GetMessages(pair.Value);

                if (resultInChunks.ContainsKey(pair.Key))
                {
                    ClusteredList <List <Message> > messageList = resultInChunks[pair.Key];
                    messageList.AddRange(messageListChunks);
                }
                else
                {
                    resultInChunks.Add(pair.Key, messageListChunks);
                }

                numberOfChunks += messageListChunks.Count;
            }

            Response response = new Response();

            response.requestId = requestId;
            response.commandID = commandId;

            response.responseType = Response.Type.GET_MESSAGE;
            GetMessageResponse getMessageResponse = null;

            if (resultInChunks.Count == 0)
            {
                getMessageResponse          = new GetMessageResponse();
                response.getMessageResponse = getMessageResponse;
                serializedResponse.Add(Common.Util.ResponseHelper.SerializeResponse(response));
                return;
            }

            getMessageResponse = new GetMessageResponse();
            foreach (var pair in resultInChunks)
            {
                TopicMessages topicMessage = new TopicMessages();
                topicMessage.topic = pair.Key;

                for (int i = 0; i < pair.Value.Count; i++)
                {
                    topicMessage.messageList.AddRange(pair.Value[i]);
                }
                getMessageResponse.topicMessages.Add(topicMessage);
            }

            response.getMessageResponse = getMessageResponse;
            serializedResponse.Add(Common.Util.ResponseHelper.SerializeResponse(response));
        }
コード例 #7
0
        private void AckStateTransferCompeleted(ArrayList bucketIds)
        {
            if (_isTransferCompleted)
            {
                LoggerManager.Instance.StateXferLogger.Info("AckStateTransferCompeleted", "State Transfer Ended " + bucketIds[0]);
            }

            switch (CorresponderIdentity.DistributionType)
            {
            case Common.Toplogies.Impl.Distribution.DistributionMethod.HashDistribution:
            case Common.Toplogies.Impl.Distribution.DistributionMethod.RangeDistribution:
            case Common.Toplogies.Impl.Distribution.DistributionMethod.TagDistribution:
            {
                try
                {
                    IEnumerator ie = bucketIds.GetEnumerator();

                    while (ie.MoveNext())
                    {
                        //muds:
                        //remove this bucket from the local buckets.
                        //this bucket has been transfered to some other node.
                        /// Remove the bucket if this node is no longer owner of this bucket.
                        int bucketId = (int)ie.Current;

                        //if (!VerifyFinalOwnership(bucketId, new NodeIdentity(Context.LocalShardName, Context.LocalAddress)))
                        {
                            lock (transferedBuckets)
                            {
                                IEnumerable <DocumentKey> bucketKeys = new ClusteredList <DocumentKey>(_currentBucketkeys);      //GetBucketKeys(bucketId, false).Clone() as ClusteredList<DocumentKey>;
                                transferedBuckets.Enqueue(new BucketRemovalInfo(corresponderIdentity.DBName, corresponderIdentity.ColName, bucketId, bucketKeys.GetEnumerator()));
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LoggerManager.Instance.StateXferLogger.Error("AckStateTransferCompeleted.BucketKeysEnumerator", ex.Message);
                }
            }
            break;

            case Common.Toplogies.Impl.Distribution.DistributionMethod.NonShardedDistribution:
                try
                {
                    lock (transferedBuckets)
                    {
                        IEnumerable <DocumentKey> bucketKeys = new ClusteredList <DocumentKey>(_currentBucketkeys);
                        //GetBucketKeys(bucketId, false).Clone() as ClusteredList<DocumentKey>;
                        transferedBuckets.Enqueue(new CollectionRemvoalInfo(CorresponderIdentity.DBName, CorresponderIdentity.ColName));
                    }
                }
                catch (Exception)
                {
                }
                break;
            }
        }
コード例 #8
0
 public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
 {
     _isPartial = reader.ReadBoolean();
     _typeSpecificPredicates           = reader.ReadObject() as HashVector;
     _registeredTypes                  = reader.ReadObject() as ClusteredList <string>;
     _cqManagerState                   = reader.ReadObject() as ContinuousQueryManagerState;
     _typeSpecificRegisteredPredicates = reader.ReadObject() as HashVector;
     _typeSpecificEvalIndexes          = reader.ReadObject() as HashVector;
 }
コード例 #9
0
        public override void ExecuteCommand(ClientManager clientManager, Alachisoft.NCache.Common.Protobuf.Command command)
        {
            int       overload;
            string    exception = null;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            try
            {
                overload = command.MethodOverload;
                cmdInfo  = ParseCommand(command, clientManager);
            }
            catch (Exception exc)
            {
                //PROTOBUF:RESPONSE
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
                return;
            }
            int resultCount = 0;

            try
            {
                NCache nCache = clientManager.CmdExecuter as NCache;
                ClusteredList <ReaderResultSet>            resultSetList    = null;
                Alachisoft.NCache.Caching.OperationContext operationContext = new Alachisoft.NCache.Caching.OperationContext(Alachisoft.NCache.Caching.OperationContextFieldName.OperationType, Alachisoft.NCache.Caching.OperationContextOperationType.CacheOperation);
                operationContext.Add(OperationContextFieldName.ClientLastViewId, cmdInfo.ClientLastViewId);
                //client id
                operationContext.Add(OperationContextFieldName.ClientId, clientManager.ClientID);
                resultSetList = nCache.Cache.ExecuteReader(cmdInfo.Query, cmdInfo.Values, cmdInfo.GetData, cmdInfo.ChunkSize, false, operationContext);
                stopWatch.Stop();
                ReaderResponseBuilder.Cache = nCache.Cache;
                ReaderResponseBuilder.BuildExecuteReaderResponse(resultSetList, cmdInfo.CommandVersion, cmdInfo.RequestId, _serializedResponsePackets, command.commandID, clientManager.ClientVersion < 4620, out resultCount);
            }
            catch (Exception exc)
            {
                //PROTOBUF:RESPONSE
                exception = exc.ToString();
                _serializedResponsePackets.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeExceptionResponse(exc, command.requestID, command.commandID));
            }
            finally
            {
                TimeSpan executionTime = stopWatch.Elapsed;
                try
                {
                    if (Alachisoft.NCache.Management.APILogging.APILogManager.APILogManger != null && Alachisoft.NCache.Management.APILogging.APILogManager.EnableLogging)
                    {
                        APILogItemBuilder log = new APILogItemBuilder(MethodsName.ExecuteReader.ToLower());
                        log.GenerateExecuteReaderAPILogItem(cmdInfo.Query, cmdInfo.Values, cmdInfo.GetData, cmdInfo.ChunkSize, overload, exception, executionTime, clientManager.ClientID.ToLower(), clientManager.ClientSocketId.ToString(), resultCount);
                    }
                }
                catch
                {
                }
            }
        }
コード例 #10
0
ファイル: CacheBase.cs プロジェクト: usamabintariq/NCache
        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);
        }
コード例 #11
0
ファイル: MetadataIndex.cs プロジェクト: waqashaneef/NosDB
        public ClusteredList <DocumentKey> GetKeysForBucket(int bucketId)
        {
            ClusteredList <DocumentKey> list = null;

            lock (_bucketKeyIndex)
                if (!_bucketKeyIndex.TryGetValue(bucketId, out list))
                {
                    list = new ClusteredList <DocumentKey>();
                }
            return(list);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public static IList BuildExecuteReaderResponse(ClusteredList <Alachisoft.NCache.Common.DataReader.ReaderResultSet> resultSetList, int commandVersion, string RequestId, IList _serializedResponse, int commandId, Boolean isOldClient, out int resultCount)
        {
            resultCount = 0;
            if (resultSetList == null)
            {
                return(null);
            }
            long requestId  = Convert.ToInt64(RequestId);
            int  sequenceId = 1;

            Alachisoft.NCache.Common.Protobuf.Response response = new Alachisoft.NCache.Common.Protobuf.Response();
            response.requestId    = requestId;
            response.commandID    = commandId;
            response.responseType = Common.Protobuf.Response.Type.EXECUTE_READER;

            ClusteredArrayList responseChunks = new ClusteredArrayList();

            foreach (Alachisoft.NCache.Common.DataReader.ReaderResultSet resultSet in resultSetList)
            {
                if (resultSet != null)
                {
                    responseChunks.AddRange(ToProtobufReaderResultSet(resultSet, isOldClient));
                    if (resultSet.RecordSet != null)
                    {
                        resultCount += resultSet.RecordSet.RowCount;
                    }
                }
            }

            if (responseChunks != null && responseChunks.Count > 0)
            {
                foreach (Alachisoft.NCache.Common.Protobuf.ReaderResultSet readerResult in responseChunks)
                {
                    response.sequenceId      = sequenceId++;
                    response.numberOfChuncks = responseChunks.Count;
                    Alachisoft.NCache.Common.Protobuf.ExecuteReaderResponse executeReaderResponse = new Common.Protobuf.ExecuteReaderResponse();
                    executeReaderResponse.readerResultSets.Add(readerResult);
                    response.executeReaderResponse = executeReaderResponse;
                    _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            else
            {
                Alachisoft.NCache.Common.Protobuf.ExecuteReaderResponse executeReaderResponse = new Common.Protobuf.ExecuteReaderResponse();
                response.executeReaderResponse = executeReaderResponse;
                _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
            return(_serializedResponse);
        }
コード例 #14
0
        internal void SetState(ContinuousQueryManagerState state)
        {
            registeredQueries   = state.RegisteredQueries;
            clientRefs          = state.ClientRefs;
            addNotifications    = state.AddNotifications;
            updateNotifications = state.UpdateNotifications;
            removeNotifications = state.RemoveNotifications;

            maxAddDFAgainstCID       = state.MaxAddDFAgainstCID;
            maxUpdateDFAgainstCID    = state.MaxUpdateDFAgainstCID;
            maxRemoveDFAgainstCID    = state.MaxRemoveDFAgainstCID;
            addDFAgainstCUniqueID    = state.AddDFAgainstCUID;
            updateDFAgainstCUniqueID = state.UpdateDFAgainstCUID;
            removeDFAgainstCUniqueID = state.RemoveDFAgainstCUID;
        }
コード例 #15
0
        public new void Deserialize(CompactReader reader)
        {
            base.Deserialize(reader);

            int length = reader.ReadInt32();

            if (_hints == null)
            {
                _hints = new ClusteredList <ExpirationHint>(length);
            }

            for (int i = 0; i < length; i++)
            {
                _hints.Insert(i, (ExpirationHint)reader.ReadObject());
            }
        }
コード例 #16
0
        public ContinuousQueryManager()
        {
            registeredQueries   = new ClusteredList <ContinuousQuery>();
            clientRefs          = new HashVector();
            addNotifications    = new HashVector();
            updateNotifications = new HashVector();
            removeNotifications = new HashVector();

            maxAddDFAgainstCID    = new HashVector();
            addDFAgainstCUniqueID = new HashVector();

            maxUpdateDFAgainstCID    = new HashVector();
            updateDFAgainstCUniqueID = new HashVector();

            maxRemoveDFAgainstCID    = new HashVector();
            removeDFAgainstCUniqueID = new HashVector();
        }
コード例 #17
0
        public void Deserialize(Runtime.Serialization.IO.CompactReader reader)
        {
            _registeredQueries = Common.Util.SerializationUtility.DeserializeClusteredList <ContinuousQuery>(reader);
            _clientRefs        = reader.ReadObject() as HashVector;

            _addNotifications    = reader.ReadObject() as HashVector;
            _updateNotifications = reader.ReadObject() as HashVector;
            _removeNotifications = reader.ReadObject() as HashVector;

            maxAddDFAgainstCID    = reader.ReadObject() as HashVector;
            maxUpdateDFAgainstCID = reader.ReadObject() as HashVector;
            maxRemoveDFAgainstCID = reader.ReadObject() as HashVector;

            addDFAgainstCUniqueID    = reader.ReadObject() as HashVector;
            updateDFAgainstCUniqueID = reader.ReadObject() as HashVector;
            removeDFAgainstCUniqueID = reader.ReadObject() as HashVector;
        }
コード例 #18
0
 public static void SerializeClusteredList <T>(ClusteredList <T> list, Runtime.Serialization.IO.CompactWriter writer)
 {
     if (list == null)
     {
         writer.Write(false);
         return;
     }
     else
     {
         writer.Write(true);
         writer.Write(list.Count);
         for (int i = 0; i < list.Count; i++)
         {
             writer.WriteObject(list[i]);
         }
     }
 }
コード例 #19
0
        public bool UnRegister(string serverUniqueId, string clientUniqueId, string clientId)
        {
            lock (this)
            {
                if (clientRefs.ContainsKey(serverUniqueId))
                {
                    HashVector cRefs = (HashVector)clientRefs[serverUniqueId];
                    if (cRefs.ContainsKey(clientId))
                    {
                        ClusteredList <string> refs = (ClusteredList <string>)cRefs[clientId];
                        if (refs.Count > 0)
                        {
                            refs.Remove(clientUniqueId);

                            UnRegisterNotifications(serverUniqueId, clientUniqueId, clientId, addNotifications, maxAddDFAgainstCID, addDFAgainstCUniqueID);
                            UnRegisterNotifications(serverUniqueId, clientUniqueId, clientId, updateNotifications, maxUpdateDFAgainstCID, updateDFAgainstCUniqueID);
                            UnRegisterNotifications(serverUniqueId, clientUniqueId, clientId, removeNotifications, maxRemoveDFAgainstCID, removeDFAgainstCUniqueID);

                            if (refs.Count == 0)
                            {
                                cRefs.Remove(clientId);
                            }
                        }
                        if (cRefs.Count == 0)
                        {
                            int qIndex = -1;
                            foreach (ContinuousQuery query in registeredQueries)
                            {
                                if (query.UniqueId.Equals(serverUniqueId))
                                {
                                    qIndex = registeredQueries.IndexOf(query);
                                    break;
                                }
                            }
                            if (qIndex != -1)
                            {
                                registeredQueries.RemoveAt(qIndex);
                            }
                            return(true);
                        }
                    }
                }
                return(false);
            }
        }
コード例 #20
0
        public static void BuildExecuteReaderResponse(ClusteredList <ReaderResultSet> resultSetList, string RequestId, IList <byte[]> _serializedResponse)
        {
            if (resultSetList == null)
            {
                return;
            }
            long requestId  = Convert.ToInt64(RequestId);
            int  sequenceId = 1;

            Common.Protobuf.Response response = new Common.Protobuf.Response();
            response.requestId    = requestId;
            response.responseType = Common.Protobuf.Response.Type.EXECUTE_READER;

            ClusteredArrayList responseChunks = new ClusteredArrayList();

            foreach (ReaderResultSet resultSet in resultSetList)
            {
                if (resultSet != null)
                {
                    responseChunks.AddRange(ToProtobufReaderResultSet(resultSet));
                }
            }

            if (responseChunks != null && responseChunks.Count > 0)
            {
                foreach (Common.Protobuf.ReaderResultSet readerResult in responseChunks)
                {
                    response.sequenceId      = sequenceId++;
                    response.numberOfChuncks = responseChunks.Count;
                    Common.Protobuf.ExecuteReaderResponse executeReaderResponse = new Common.Protobuf.ExecuteReaderResponse();
                    executeReaderResponse.readerResultSets.Add(readerResult);
                    response.executeReaderResponse = executeReaderResponse;
                    _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
                }
            }
            else
            {
                Alachisoft.NCache.Common.Protobuf.ExecuteReaderResponse executeReaderResponse = new Common.Protobuf.ExecuteReaderResponse();
                response.executeReaderResponse = executeReaderResponse;
                _serializedResponse.Add(Alachisoft.NCache.Common.Util.ResponseHelper.SerializeResponse(response));
            }
        }
コード例 #21
0
        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);
        }
コード例 #22
0
        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);
            }
        }
コード例 #23
0
        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);
            }
        }
コード例 #24
0
        internal StateTxfrCorresponder(NodeContext context, IDispatcher dispatcher, StateTransferIdentity identity, bool isLocal)//,String dbName,String colName,NodeIdentity requestingShard, StateTransferType transferType)
        {
            _context    = context;
            _dispatcher = dispatcher;
            _isLocal    = isLocal;
            if (_context != null)
            {
                _databasesManager = _context.DatabasesManager;
            }

            corresponderIdentity = identity;
            _currentBucketkeys   = new ClusteredList <DocumentKey>();
            // Create Collection for keeping keys being transfered
            collectionCreated = CreateBucketKeysCollection();

            transferedBuckets = new ConcurrentQueue <IResourceRemovalInfo>();

            _statsIdentity = new StatsIdentity(context.LocalShardName, corresponderIdentity.DBName);
            loggingModule  = corresponderIdentity.DBName + ":" + corresponderIdentity.ColName + ":" + GetType().ToString();

            _resourceID = Guid.NewGuid().ToString();
        }
コード例 #25
0
        public void Dispose()
        {
            Clear();

            if (registeredQueries != null)
            {
                registeredQueries = null;
            }

            if (clientRefs != null)
            {
                clientRefs = null;
            }

            if (addNotifications != null)
            {
                addNotifications = null;
            }

            if (updateNotifications != null)
            {
                updateNotifications = null;
            }

            if (removeNotifications != null)
            {
                removeNotifications = null;
            }

            maxRemoveDFAgainstCID    = null;
            removeDFAgainstCUniqueID = null;

            maxAddDFAgainstCID    = null;
            addDFAgainstCUniqueID = null;

            maxUpdateDFAgainstCID    = null;
            updateDFAgainstCUniqueID = null;
        }
コード例 #26
0
        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);
            }
        }
コード例 #27
0
        private void UnRegisterNotifications(string serverUniqueId, string clientUniqueId, string clientId, HashVector notifications
                                             , HashVector CID, HashVector CUID)
        {
            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);
        }
コード例 #28
0
ファイル: PollingResult.cs プロジェクト: yongwuhou/NCache
 public void Deserialize(CompactReader reader)
 {
     _removedKeys = SerializationUtility.DeserializeClusteredList <string>(reader);
     _updatedKeys = SerializationUtility.DeserializeClusteredList <string>(reader);
 }
コード例 #29
0
 public ListedResultSet()
 {
     _results = new ClusteredList <T>();
 }
コード例 #30
0
 public void Dispose()
 {
     _results.Clear();
     _results = null;
 }
コード例 #31
0
 public void Deserialize(Common.Serialization.IO.CompactReader reader)
 {
     _results = SerializationUtility.DeserializeClusteredList <T>(reader);
 }