コード例 #1
0
ファイル: TitanicMemoryIO.cs プロジェクト: zhouji0212/Samples
        /// <summary>
        ///     save a new request under a GUID and the request data itself as well
        /// </summary>
        /// <param name="id">the id of the request</param>
        /// <param name="request">the request to save</param>
        /// <exception cref="OverflowException">max. number of elements exceeded, <see cref="F:System.Int32.MaxValue" />.</exception>
        public void SaveNewRequestEntry(Guid id, NetMQMessage request)
        {
            var entry = new RequestEntry {
                RequestId = id, Position = -1, State = RequestEntry.Is_Pending, Request = request
            };

            SaveRequestEntry(entry);
        }
コード例 #2
0
        /// <summary>
        ///     save a new request under a GUID
        /// </summary>
        /// <param name="id">the id of the request</param>
        public void SaveNewRequestEntry(Guid id)
        {
            var entry = new RequestEntry()
            {
                RequestId = id, Position = -1, State = RequestEntry.Is_Pending
            };

            SaveRequestEntry(entry);
        }
コード例 #3
0
ファイル: TitanicMemoryIO.cs プロジェクト: zhouji0212/Samples
        /// <summary>
        ///     saves a request entry to the infrastructure
        /// </summary>
        /// <param name="entry">the request entry to save</param>
        /// <exception cref="OverflowException">max. number of elements exceeded, <see cref="F:System.Int32.MaxValue" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="entry.RequestId" /> is a 'null' reference.</exception>
        public void SaveRequestEntry(RequestEntry entry)
        {
            if (ReferenceEquals(entry, null))
            {
                throw new ArgumentNullException(nameof(entry), "The RequestEntry to save must not be null!");
            }

            m_titanicQueue.AddOrUpdate(entry.RequestId, entry, (id, e) => entry);
        }
コード例 #4
0
        /// <summary>
        ///     save a new request under a GUID and saves the request data as well
        /// </summary>
        /// <param name="id">the id of the request</param>
        /// <param name="request">the request data to save</param>
        public void SaveNewRequestEntry(Guid id, NetMQMessage request)
        {
            // save the request data to file first and then
            SaveMessage(TitanicOperation.Request, id, request);
            // create the appropriate entry and
            var entry = new RequestEntry()
            {
                RequestId = id, Position = -1, State = RequestEntry.Is_Pending
            };

            // save the request to queue
            SaveRequestEntry(entry);
        }
コード例 #5
0
ファイル: TitanicMemoryIO.cs プロジェクト: zhouji0212/Samples
        /// <summary>
        ///     save a NetMQ message under a GUID
        /// </summary>
        /// <param name="op">defines whether it is a REQUEST or REPLY message</param>
        /// <param name="id">the guid of the message to save</param>
        /// <param name="message">the message to save</param>
        /// <exception cref="OverflowException">max. number of elements exceeded, <see cref="F:System.Int32.MaxValue" />.</exception>
        public bool SaveMessage(TitanicOperation op, Guid id, NetMQMessage message)
        {
            var entry = new RequestEntry
            {
                RequestId = id,
                Request   = message,
                State     = GetStateFromOperation(op)
            };

            m_titanicQueue.AddOrUpdate(id, entry, (i, oldValue) => entry);

            return(true);
        }
コード例 #6
0
        /// <summary>
        ///     saves a request entry to the infrastructure
        /// </summary>
        /// <param name="entry">the request entry to save</param>
        public void SaveRequestEntry(RequestEntry entry)
        {
            lock (m_syncRoot)
            {
                using (var file = File.OpenWrite(m_titanicQueue))
                {
                    var source = CreateFileEntry(entry.RequestId, entry.State);

                    var position = entry.Position == -1 ? file.Seek(0, SeekOrigin.End) : entry.Position;

                    WriteRequest(file, source, file.Seek(position, SeekOrigin.Begin));
                }
            }
        }
コード例 #7
0
        /// <summary>
        ///     save a processed request entry and mark it as such
        /// </summary>
        /// <param name="entry">the entry to save</param>
        public void SaveProcessedRequestEntry([NotNull] RequestEntry entry)
        {
            entry.State = RequestEntry.Is_Processed;

            SaveRequestEntry(entry);
        }