예제 #1
0
        public static QueueHost Parse(string address)
        {
            QueueHost host = new QueueHost();

            host.Create(address);
            return(host);
        }
예제 #2
0
        public PriorityFsQueue(QueueHost qp)
            : base(qp.HostName)
        {
            int numProcs         = Environment.ProcessorCount;
            int concurrencyLevel = numProcs * 2;
            int initialCapacity  = 101;

            QueueList = new ConcurrentDictionary <Ptr, IQueueItem>(concurrencyLevel, initialCapacity);

            //CommitMode = qp.CommitMode;
            //CoverMode = qp.Mode;
            RootPath   = qp.RootPath;
            CommitMode = qp.CommitMode;
            CoverMode  = qp.CoverMode;

            if (qp.CoverMode == CoverMode.FileStream)
            {
                CoverMode = CoverMode.FileStream;
                //DbLiteSettings settings = new DbLiteSettings()
                //{
                //    Name = qp.QueueName,
                //    CommitMode = (CommitMode)(int)qp.CommitMode,
                //    DbPath = AgentManager.Settings.QueuesPath
                //};
                //settings.SetFast();
                //QueueHost queueHost = qp.GetRoutHost();
                m_fs        = new FileMessage(qp);
                m_fs.Logger = Logger;
                //InitRecoverQueue();

                //m_db = new PersistentBinary<IQueueItem>(settings);
                ////m_db = new PersistentDictionary(settings);
                //m_db.BeginLoading += M_db_BeginLoading;
                //m_db.LoadCompleted += M_db_LoadCompleted;
                //m_db.ErrorOcurred += M_db_ErrorOcurred;
                //m_db.ClearCompleted += M_db_ClearCompleted;
                ////m_db.ItemChanged += M_db_ItemChanged;

                //m_db.ItemLoaded = (item) =>
                //{
                //    this.ReEnqueue(item);
                //};

                if (qp.ReloadOnStart)
                {
                    Logger.Info("PriorityFsQueue will load items to : {0}", qp.HostName);
                    m_fs.ReloadItemsAsync(FolderType.Queue, 0, (IQueueItem item) =>
                    {
                        this.ReEnqueue(item);
                    });
                }
                else
                {
                    Logger.Info("PriorityFsQueue will clear all items from : {0}", qp.HostName);
                    m_fs.ClearItems(FolderType.Queue);
                }
            }
        }
예제 #3
0
        public PriorityFsQueue(IQProperties qp)
            : base(qp.QueueName)
        {
            int numProcs         = Environment.ProcessorCount;
            int concurrencyLevel = numProcs * 2;
            int initialCapacity  = 101;

            QueueList = new ConcurrentDictionary <Ptr, IQueueItem>(concurrencyLevel, initialCapacity);

            CommitMode = (CommitMode)(int)qp.CommitMode;
            CoverMode  = qp.Mode;

            if (CoverMode == CoverMode.FileStream)
            {
                DbLiteSettings settings = new DbLiteSettings()
                {
                    Name       = qp.QueueName,
                    CommitMode = (CommitMode)(int)qp.CommitMode,
                    DbPath     = AgentManager.Settings.QueuesPath
                };
                //settings.SetFast();
                QueueHost queueHost = qp.GetRoutHost();
                m_fs = new FileMessage(queueHost);

                //m_db = new PersistentBinary<IQueueItem>(settings);
                ////m_db = new PersistentDictionary(settings);
                //m_db.BeginLoading += M_db_BeginLoading;
                //m_db.LoadCompleted += M_db_LoadCompleted;
                //m_db.ErrorOcurred += M_db_ErrorOcurred;
                //m_db.ClearCompleted += M_db_ClearCompleted;
                ////m_db.ItemChanged += M_db_ItemChanged;

                //m_db.ItemLoaded = (item) =>
                //{
                //    this.ReEnqueue(item);
                //};

                if (qp.ReloadOnStart)
                {
                    QLogger.InfoFormat("PriorityComplexQueue will load items to : {0}", qp.QueueName);
                }
                else
                {
                    QLogger.InfoFormat("PriorityComplexQueue will clear all items from : {0}", qp.QueueName);
                }

                //m_db.ReloadOrClearPersist(qp.ReloadOnStart);

                m_fs.ReloadItemsTo(0, (IQueueItem item) =>
                {
                    this.ReEnqueue(item);
                });
            }
        }
예제 #4
0
 public QueueHost GetRoutHost()
 {
     if (Mode == CoverMode.Rout)
     {
         if (TargetPath == null || TargetPath == "")
         {
             return(null);
         }
         return(QueueHost.Parse(TargetPath));
     }
     return(null);
 }
예제 #5
0
        public static TopicSubscriber Create(string s, string topicId)
        {
            var qh = QueueHost.Parse(s);

            return(new TopicSubscriber()
            {
                Host = qh.HostAddress,
                Protocol = qh.NetProtocol,
                HostName = qh.HostName,
                TopicId = topicId,
                QHost = qh
            });
        }