Exemple #1
0
 private void RevitemOutput(ReceiveDataItem item)
 {
     try
     {
         this._rev(item);
     }
     catch (Exception ex)
     {
         Loger.Error(ex, "外部处理接收的到数据项异常");
     }
 }
Exemple #2
0
        private bool ProMessageMode(SendDataNotifyMessage message)
        {
            var receiveDataItem = new ReceiveDataItem(message);

            if (!this._revItemDic.TryAdd(message.Header.Rid, receiveDataItem))
            {
                receiveDataItem.Close(true);
                Loger.Error("this._revItemDic.TryAdd失败");
                return(false);
            }

            this.SendTransferCompletedMessage(message);
            return(true);
        }
 private void TransferChannelRev(ReceiveDataItem item)
 {
     this._revQueue.Enqueue(item);
 }
Exemple #4
0
        private bool ProResourceMode(SendDataNotifyMessage message)
        {
            lock (this._revItemDicLock)
            {
                var             rid = message.Header.Rid;
                ReceiveDataItem receiveDataItem;
                if (this._revItemDic.TryGetValue(rid, out receiveDataItem))
                {
                    receiveDataItem.UpdateLastAccessTimestamp();
                    //Loger.Warn($"[RID:{rid}]的接收项已存在,忽略");
                    return(false);
                }

                if (MemoryCacheEx.Get(CacheKeyGenerator.GenerateRevTimeoutKey(rid)) != null)
                {
                    //Loger.Warn($"[RID:{rid}]接收已超时,忽略");
                    return(false);
                }

                //Loger.Warn($"处理RID[{rid}]发送通知");
                receiveDataItem = new ReceiveDataItem(message, this._config.LocalFileDirectory, this._config.TransferThreadCount);
                if (!this._revItemDic.TryAdd(rid, receiveDataItem))
                {
                    receiveDataItem.Close(true);
                    Loger.Error("this._revItemDic.TryAdd失败,原因未知");
                    return(false);
                }

                int millisecondsTimeout;
                var revItemCount = this._revItemDic.Count;
                if (revItemCount < 1)
                {
                    millisecondsTimeout = message.Timeout / this._config.TimeoutHeartMul;
                }
                else
                {
                    millisecondsTimeout = message.Timeout / (revItemCount * this._config.TimeoutHeartMul);
                }

                var reqDataSchduleInfoManager = new TransferReqDataSchduleInfoManager(message, this._reqDataThreads, millisecondsTimeout);
                TransferResourceManager resourceTransferManager;
                var priority = message.Priority;
                if (this._priorityResourceTransferManagerSortedList.ContainsKey(priority))
                {
                    resourceTransferManager = this._priorityResourceTransferManagerSortedList[priority];
                }
                else
                {
                    lock (this._priorityResourceTransferManagerSortedListLock)
                    {
                        if (this._priorityResourceTransferManagerSortedList.ContainsKey(priority))
                        {
                            resourceTransferManager = this._priorityResourceTransferManagerSortedList[priority];
                        }
                        else
                        {
                            resourceTransferManager = new TransferResourceManager();
                            this._priorityResourceTransferManagerSortedList.Add(priority, resourceTransferManager);
                        }
                    }
                }

                if (resourceTransferManager.AddReqDataSchduleInfoManager(reqDataSchduleInfoManager))
                {
                    this.SendReqDataThreadsEventHandleNotify();
                    return(true);
                }
                else
                {
                    Loger.Error("AddReqDataSchduleInfoManager失败,原因未知");
                    if (!this._revItemDic.TryRemove(rid, out receiveDataItem))
                    {
                        receiveDataItem.Close(true);
                    }

                    return(false);
                }
            }
        }