Ejemplo n.º 1
0
        public Task <QueueInfo> GetQueueInfo(GetQueueInfoArgs args)
        {
            var queueInfo = new QueueInfo();
            var commands  = _commandQueue.Items.ToList();

            queueInfo.TotalCount = commands.Count;

            if (args.Include(GetQueueInfoArgs.Commands))
            {
                //(IList<object>)xxx => InvalidCastException: 'IList<ICommand>' to type 'IList<Object>'.
                queueInfo.Commands = commands.Cast <object>().ToList();
            }

            if (args.Include(GetQueueInfoArgs.CommandSums))
            {
                var commandSums = commands.GroupBy(x => x.CommandType).Select(g =>
                {
                    var commandSum          = new CommandSum();
                    commandSum.CommandType  = g.Key;
                    commandSum.CommandCount = g.Count();
                    return(commandSum);
                }).ToList();

                queueInfo.CommandSums = commandSums;
            }
            return(Task.FromResult(queueInfo));
        }
        public void verify_job_parameters_contains_mime_type()
        {
            var             info = new QueueInfo("test", "", "docx");
            QueueHandler    sut  = new QueueHandler(info, _db);
            StreamReadModel rm   = new StreamReadModel()
            {
                Filename   = new FileNameWithExtension("test.docx"),
                FormatInfo = new FormatInfo()
                {
                    DocumentFormat = new DocumentFormat("thumb.small"),
                    BlobId         = new BlobId("blob.1"),
                    PipelineId     = new PipelineId("thumbnail"),
                },
                DocumentDescriptorId = new DocumentDescriptorId(1),
            };

            sut.Handle(rm, new TenantId("test_tenant"));
            var collection = _db.GetCollection <QueuedJob>("queue.test");

            Assert.That(collection.AsQueryable().Count(), Is.EqualTo(1));
            var job = collection.AsQueryable().Single();

            Assert.That(job.BlobId, Is.EqualTo(new BlobId("blob.1")));
            Assert.That(job.Parameters[JobKeys.MimeType], Is.EqualTo(MimeTypes.GetMimeTypeByExtension("docx")));
        }
Ejemplo n.º 3
0
        public Task ProcessQueueInfo(QueueInfo queueInfo)
        {
            var clientSpanEntities = GetClientSpanEntities(queueInfo);
            var jaegerTraceSender  = new JaegerTraceSender();

            return(jaegerTraceSender.Send(clientSpanEntities));
        }
Ejemplo n.º 4
0
        private void CalculateQueueEstimatedMeetTime(QueueInfo queueInfo, Queue queue)
        {
            double estimatedAddTime  = queueInfo.YourNumberInQueue / queueInfo.NumbersPerMinute;
            var    estimatedMeetTime = queue.QueueTime.AddMinutes((int)Math.Ceiling(estimatedAddTime));

            _queueData.UpdateEstimatedMeetTime(queue.CountryId, queue.CompanyGuid, queue.ActitityGuid, queue.UserGuid, estimatedMeetTime);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 创建队列
        /// </summary>
        /// <param name="queueInfo"></param>
        /// <returns></returns>
        private int createQueue(QueueInfo queueInfo)
        {
            int retVal = 0;

            retVal = AnyChatServerSDK.BRAS_ObjectControl(AnyChatServerSDK.ANYCHAT_OBJECT_TYPE_QUEUE, queueInfo.QueueID, AnyChatServerSDK.ANYCHAT_OBJECT_CTRL_CREATE, queueInfo.AreaID, 0, 0, 0, "");

            retVal = AnyChatServerSDK.BRAS_ObjectSetValue(AnyChatServerSDK.ANYCHAT_OBJECT_TYPE_QUEUE, queueInfo.QueueID, AnyChatServerSDK.ANYCHAT_OBJECT_INFO_NAME, queueInfo.QueueName, queueInfo.QueueName.ToCharArray().Length);

            retVal = AnyChatServerSDK.BRAS_ObjectSetValue(AnyChatServerSDK.ANYCHAT_OBJECT_TYPE_QUEUE, queueInfo.QueueID, AnyChatServerSDK.ANYCHAT_OBJECT_INFO_DESCRIPTION, queueInfo.QueueDescription, queueInfo.QueueDescription.ToCharArray().Length);

            int queuePriority = queueInfo.QueuePriority;

            retVal = AnyChatServerSDK.BRAS_ObjectSetValue(AnyChatServerSDK.ANYCHAT_OBJECT_TYPE_QUEUE, queueInfo.QueueID, AnyChatServerSDK.ANYCHAT_OBJECT_INFO_PRIORITY, ref queuePriority, sizeof(int));

            int businessType = (int)queueInfo.businessType;

            retVal = AnyChatServerSDK.BRAS_ObjectSetValue(AnyChatServerSDK.ANYCHAT_OBJECT_TYPE_QUEUE, queueInfo.QueueID, AnyChatServerSDK.ANYCHAT_OBJECT_INFO_ATTRIBUTE, ref businessType, sizeof(int));

            int intTag = queueInfo.intTag;

            retVal = AnyChatServerSDK.BRAS_ObjectSetValue(AnyChatServerSDK.ANYCHAT_OBJECT_TYPE_QUEUE, queueInfo.QueueID, AnyChatServerSDK.ANYCHAT_OBJECT_INFO_INTTAG, ref intTag, sizeof(int));

            if (!string.IsNullOrEmpty(queueInfo.stringTag))
            {
                retVal = AnyChatServerSDK.BRAS_ObjectSetValue(AnyChatServerSDK.ANYCHAT_OBJECT_TYPE_QUEUE, queueInfo.QueueID, AnyChatServerSDK.ANYCHAT_OBJECT_INFO_STRINGTAG, queueInfo.stringTag, queueInfo.stringTag.ToCharArray().Length);
            }

            return(retVal);
        }
            public CheckForMessagesShould()
            {
                expectedQueueUrl = "QueueUrl";
                queueInfo        = new QueueInfo(typeof(TestMessage), expectedQueueUrl);
                var queues = new Dictionary <string, QueueInfo>();

                queues.Add("", queueInfo);

                var messageBusMock = new Mock <IMessageBus>();

                sqsServiceMock = new Mock <ISqsService>();
                var messageDeserializerMock = new Mock <IMessageDeserializer>();

                handlerMock = new Mock <IHandlerAsync <TestMessage> >();

                messageBusMock.Setup(x => x.Queues).Returns(queues);
                messageBusMock.Setup(x => x.GetHandler <TestMessage>()).Returns(handlerMock.Object);

                expectedMessage = new TestMessage();
                var response = new Amazon.SQS.Model.ReceiveMessageResponse();

                busMessage = new Amazon.SQS.Model.Message();
                busMessage.ReceiptHandle = "Recipt001";
                response.Messages.Add(busMessage);
                sqsServiceMock.Setup(x => x.ReceiveMessageAsync(expectedQueueUrl)).Returns(Task.FromResult(response));
                messageDeserializerMock.Setup(x => x.Deserialize <TestMessage>(busMessage)).Returns(expectedMessage);

                sut = new MessageBusListener(messageBusMock.Object, sqsServiceMock.Object, messageDeserializerMock.Object);
            }
Ejemplo n.º 7
0
 private void Retry(QueueInfo <T> info)
 {
     Trace.WriteLine("Retry");
     _queue.Enqueue(info);
     Trace.WriteLine("Retry: Set Event");
     _autoEvent.Set();
 }
Ejemplo n.º 8
0
    public static void SendSms(string cellNo, string taxrefNo, string year, string message)
    {
        var correspondance = new CorrespondenceManagementRequestStructure
        {
            RequestOperation = RequestOperation.ISSUE_CORRESPONDENCE,
            OutChannel       = CorrespondenceManagementRequestStructureOutChannel.SMS,
            SMS = new CorrespondenceManagementRequestStructureSMS
            {
                CellularNos = new[] { cellNo },
                Message     = message
            }
        };

        var messageId   = Guid.NewGuid();
        var corXml      = Sars.Systems.Serialization.XmlObjectSerializer.GetXmlWithNoDeclaration(correspondance);
        var soapMessage = FdrCommon.CreateSoapSms(corXml, taxrefNo, messageId.ToString());

        soapMessage = FdrCommon.FormatXml(soapMessage);
        var queueInfo = new QueueInfo
        {
            Manager        = MQConfigurationSettings.CorrespondenceOutQManagerName,
            Channel        = MQConfigurationSettings.CorrespondenceOutQChannelName,
            UseManagerName = false,
            Port           = MQConfigurationSettings.CorrespondenceOutPortNumber,
            HostName       = MQConfigurationSettings.CorrespondenceOutHostName,
            QueueName      = MQConfigurationSettings.CorrespondenceOutQName,
            CorrelationId  = messageId.ToString(),
            Message        = soapMessage
        };

        FdrMessaging.SendMessageToQueue(queueInfo);
    }
Ejemplo n.º 9
0
        /// <summary>
        /// 根据文件信息生成队列信息
        /// </summary>
        /// <param name="info"></param>
        private static QueueInfo[] generatequeueinfo(ref FilePackageInfo info, FileQueue instance)
        {
            QueueInfo[] infos        = new QueueInfo[info.ThreadsCounts];
            var         FilePackages = (long)Math.Round((double)(info.FileSize / instance._packsize)) + 1;
            int         queuelength  = (int)Math.Round((double)(FilePackages / info.ThreadsCounts)) + 1;

            for (int i = 0; i < info.ThreadsCounts; i++)
            {
                QueueInfo qinfo = new QueueInfo();
                if (i == info.ThreadsCounts - 1)
                {
                    qinfo.PackCount = (int)(FilePackages - i * queuelength);
                    qinfo.Offset    = i * queuelength * instance._packsize;
                    qinfo.Length    = info.FileSize - qinfo.Offset;
                }
                else
                {
                    qinfo.PackCount = queuelength;
                    qinfo.Offset    = i * queuelength * instance._packsize;
                    qinfo.Length    = qinfo.PackCount * instance._packsize;
                }
                infos[i] = qinfo;
            }
            return(infos);
        }
Ejemplo n.º 10
0
        public Task AbandonAsync(string id)
        {
            QueueInfo <T> info = null;

            if (!_dequeued.TryRemove(id, out info) || info == null)
            {
                throw new ApplicationException("Unable to remove item from the dequeued list.");
            }

            Interlocked.Increment(ref _abandonedCounter);
            if (info.Attempts < _retries + 1)
            {
                if (_retryDelayMilliseconds > 0)
                {
                    Task.Factory.StartNewDelayed(_retryDelayMilliseconds, () => Retry(info));
                }
                else
                {
                    Retry(info);
                }
            }
            else
            {
                _deadletterQueue.Enqueue(info);
            }

            return(Task.FromResult(0));
        }
Ejemplo n.º 11
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.InvalidResourceRequestException
 ///     "/>
 public static void NormalizeAndvalidateRequest(ResourceRequest resReq, Org.Apache.Hadoop.Yarn.Api.Records.Resource
                                                maximumResource, string queueName, YarnScheduler scheduler, RMContext rmContext
                                                , QueueInfo queueInfo)
 {
     NormalizeAndValidateRequest(resReq, maximumResource, queueName, scheduler, false,
                                 rmContext, queueInfo);
 }
        private async Task <Queue> CreateTestQueueInVhost(string queueName, Vhost vhost)
        {
            var queueInfo = new QueueInfo(queueName);
            await managementClient.CreateQueueAsync(queueInfo, vhost).ConfigureAwait(false);

            return(await managementClient.GetQueueAsync(queueName, vhost).ConfigureAwait(false));
        }
Ejemplo n.º 13
0
        public string GetUserId(QueueInfo queue, string user)
        {
            var result = "";

            try
            {
                var pageNumber = 1;
                var pageCount  = 1;

                var allQueueMemberEntityListing = routingApi.GetRoutingQueueUsers(queue.Id, 100, pageNumber++, "name");
                pageCount = allQueueMemberEntityListing.PageCount.Value;
                AddLog("Members: " + allQueueMemberEntityListing.Entities);
                //queue.AllQueueMembers.AddRange(allQueueMemberEntityListing.Entities);

                foreach (var member in allQueueMemberEntityListing.Entities)
                {
                    if (member.Name.Equals(user))
                    {
                        result = member.Id;
                    }
                }
            }
            catch (Exception ex)
            {
                AddLog($"Error in cmbQueues_SelectedIndexChanged: {ex}");
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(result);
        }
Ejemplo n.º 14
0
 public CreateModel(ContosoExpensesWebContext context, IOptions <ConfigValues> config, QueueInfo queueInfo, IMetrics metrics)
 {
     _metrics         = metrics;
     _context         = context;
     _queueInfo       = queueInfo;
     costCenterAPIUrl = config.Value.CostCenterAPIUrl;
 }
Ejemplo n.º 15
0
 public PushForwardQueueClient(PushForwardClient client, QueueClient queueClient, QueueInfo queueInfo, PushForwardConfig config)
 {
     QueueInfo    = queueInfo;
     _client      = client;
     _queueClient = queueClient;
     _config      = config;
 }
        public void verify_filtering_on_mime_types()
        {
            var             mimeTypeDocx = MimeTypes.GetMimeTypeByExtension("docx");
            var             info         = new QueueInfo("test", mimeTypes: mimeTypeDocx);
            QueueHandler    sut          = new QueueHandler(info, _db);
            StreamReadModel rm           = new StreamReadModel()
            {
                Filename   = new FileNameWithExtension("test.pdf"),
                FormatInfo = new FormatInfo()
                {
                    DocumentFormat = new DocumentFormat("thumb.small"),
                    BlobId         = new BlobId("blob.1"),
                    PipelineId     = new PipelineId("thumbnail")
                }
            };

            sut.Handle(rm, new TenantId("test"));
            var collection = _db.GetCollection <QueuedJob>("queue.test");

            Assert.That(collection.AsQueryable().Count(), Is.EqualTo(0));

            rm = new StreamReadModel()
            {
                Filename   = new FileNameWithExtension("test.docx"),
                FormatInfo = new FormatInfo()
                {
                    DocumentFormat = new DocumentFormat("thumb.small"),
                    BlobId         = new BlobId("blob.1"),
                    PipelineId     = new PipelineId("thumbnail")
                }
            };
            sut.Handle(rm, new TenantId("test"));

            Assert.That(collection.AsQueryable().Count(), Is.EqualTo(1));
        }
Ejemplo n.º 17
0
        public FifoSchedulerInfo(ResourceManager rm)
        {
            // JAXB needs this
            RMContext     rmContext = rm.GetRMContext();
            FifoScheduler fs        = (FifoScheduler)rm.GetResourceScheduler();

            qName = fs.GetQueueInfo(string.Empty, false, false).GetQueueName();
            QueueInfo qInfo = fs.GetQueueInfo(qName, true, true);

            this.usedCapacity           = qInfo.GetCurrentCapacity();
            this.capacity               = qInfo.GetCapacity();
            this.minQueueMemoryCapacity = fs.GetMinimumResourceCapability().GetMemory();
            this.maxQueueMemoryCapacity = fs.GetMaximumResourceCapability().GetMemory();
            this.qstate            = qInfo.GetQueueState();
            this.numNodes          = rmContext.GetRMNodes().Count;
            this.usedNodeCapacity  = 0;
            this.availNodeCapacity = 0;
            this.totalNodeCapacity = 0;
            this.numContainers     = 0;
            foreach (RMNode ni in rmContext.GetRMNodes().Values)
            {
                SchedulerNodeReport report = fs.GetNodeReport(ni.GetNodeID());
                this.usedNodeCapacity  += report.GetUsedResource().GetMemory();
                this.availNodeCapacity += report.GetAvailableResource().GetMemory();
                this.totalNodeCapacity += ni.GetTotalCapability().GetMemory();
                this.numContainers     += fs.GetNodeReport(ni.GetNodeID()).GetNumContainers();
            }
        }
Ejemplo n.º 18
0
 /// <summary>
 /// Determine whether the queue can be used based on the pool provider's settings
 /// </summary>
 /// <param name="queueInfo">Queue information</param>
 /// <returns>True if the queue can be used, false otherwise</returns>
 private bool IsAllowableQueue(QueueInfo queueInfo)
 {
     if (_configuration.AllowedTargetQueues == AllowableHelixQueues.Any)
     {
         return(true);
     }
     else if (_configuration.AllowedTargetQueues == AllowableHelixQueues.Specific)
     {
         return(_configuration.AllowedTargetQueueNames.Any(queueName => queueName.Equals(queueInfo.QueueId, StringComparison.OrdinalIgnoreCase)));
     }
     else if (_configuration.AllowedTargetQueues == AllowableHelixQueues.NoInternal ||
              _configuration.AllowedTargetQueues == AllowableHelixQueues.OnlyInternal)
     {
         if (!queueInfo.IsInternalOnly.HasValue)
         {
             _logger.LogWarning($"Warning, unknown whether {queueInfo.QueueId} is internal only or not");
             return(false);
         }
         return((_configuration.AllowedTargetQueues == AllowableHelixQueues.NoInternal && !queueInfo.IsInternalOnly.Value) ||
                (_configuration.AllowedTargetQueues == AllowableHelixQueues.OnlyInternal && queueInfo.IsInternalOnly.Value));
     }
     else
     {
         throw new NotImplementedException($"Unexpected allowed target queue setting '{_configuration.AllowedTargetQueues}'");
     }
 }
Ejemplo n.º 19
0
 public CreateModel(ContosoExpensesWebContext context, IOptions <ConfigValues> config, QueueInfo queueInfo, IHostingEnvironment env)
 {
     _context         = context;
     costCenterAPIUrl = config.Value.CostCenterAPIUrl;
     _queueInfo       = queueInfo;
     _env             = env;
 }
Ejemplo n.º 20
0
        public override async Task <string> EnqueueAsync(T data)
        {
            string id = Guid.NewGuid().ToString("N");

#if DEBUG
            Logger.Trace().Message("Queue {0} enqueue item: {1}", typeof(T).Name, id).Write();
#endif
            if (!await OnEnqueuingAsync(data).AnyContext())
            {
                return(null);
            }

            var info = new QueueInfo <T> {
                Data         = data.Copy(),
                Id           = id,
                TimeEnqueued = DateTime.UtcNow
            };

            _queue.Enqueue(info);
#if DEBUG
            Logger.Trace().Message("Enqueue: Set Event").Write();
#endif
            using (await _monitor.EnterAsync())
                _monitor.Pulse();
            Interlocked.Increment(ref _enqueuedCount);

            await OnEnqueuedAsync(data, id).AnyContext();

#if DEBUG
            Logger.Trace().Message("Enqueue done").Write();
#endif

            return(id);
        }
Ejemplo n.º 21
0
        public void AddQueue(int y)
        {
            QueueInfo queueInfo = new QueueInfo();

            queueInfo.listcount = y;
            ListQueue.Enqueue(queueInfo);
        }
Ejemplo n.º 22
0
        public async Task Should_be_able_to_create_a_queue_with_plus_char_in_the_name()
        {
            var queueInfo = new QueueInfo(testQueueWithPlusChar);
            var queue     = await managementClient.CreateQueueAsync(queueInfo, Configuration.RabbitMqVirtualHost).ConfigureAwait(false);

            queue.Name.ShouldEqual(testQueueWithPlusChar);
        }
Ejemplo n.º 23
0
        public void Handle(AddQueueItemCommand command)
        {
            Tuple <Guid, Guid> searchCriteria    = new Tuple <Guid, Guid>(command.ServiceProviderId, command.UserId);
            QueueInfo          existingQueueItem = m_QueryRepository.Search(searchCriteria).FirstOrDefault();

            if (existingQueueItem != null && existingQueueItem.Status != QueueStatus.Serviced)
            {
                throw new InvalidOperationException(ErrorMessages.AlreadyInQueue);
            }

            QueueInfo queueItem = new QueueInfo();

            queueItem.CreatedBy       = command.UserId.ToString();
            queueItem.CreatedDateTime = DateTime.UtcNow;
            queueItem.DateAdded       = DateTime.UtcNow;
            queueItem.Expiration      = DateTime.UtcNow.AddHours(6);
            queueItem.Id                = command.QueueItemId;
            queueItem.Name              = command.Name;
            queueItem.PartySize         = command.PartySize;
            queueItem.Requests          = command.Requests;
            queueItem.ServiceProviderId = command.ServiceProviderId;
            queueItem.Status            = QueueStatus.Waiting;
            queueItem.UserId            = command.UserId;

            m_QueueRepository.Add(queueItem);
        }
Ejemplo n.º 24
0
        private void ScanQueue()
        {
            while (ListQueue.Count > 0)
            {
                try
                {
                    QueueInfo queueInfo = new QueueInfo();

                    queueInfo.listcount = ListQueue.Count;
                    queueInfo           = ListQueue.Dequeue();


                    ArrayList list = new ArrayList();

                    for (int i = 0; i < queueInfo.listcount; i++)
                    {
                        list.Add(i);
                        list.Add(i.ToString());
                    }

                    IList <int> ilist = new List <int>();

                    for (int i = 0; i < list.Count; i++)
                    {
                        ilist.Add(Convert.ToInt32(list[i]));
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
            }

            return;
        }
        private QueueHandler CreateAGenericJob(QueueInfo info, String tenant = "test", Dictionary <String, Object> customData = null)
        {
            QueueHandler sut = GetSut(info);

            HandleStreamToCreateJob(sut, tenant, customData);
            return(sut);
        }
        public void verify_id_is_opaque_and_not_contains_blob_id()
        {
            var             info = new QueueInfo("test", "", "docx");
            QueueHandler    sut  = new QueueHandler(info, _db);
            StreamReadModel rm   = new StreamReadModel()
            {
                Filename   = new FileNameWithExtension("test.docx"),
                FormatInfo = new FormatInfo()
                {
                    DocumentFormat = new DocumentFormat("thumb.small"),
                    BlobId         = new BlobId("blob.1"),
                    PipelineId     = new PipelineId("thumbnail"),
                },
                DocumentDescriptorId = new DocumentDescriptorId(1),
                Handle = new DocumentHandle("Revision_2"),
            };

            sut.Handle(rm, new TenantId("test_tenant"));
            var collection = _db.GetCollection <QueuedJob>("queue.test");

            Assert.That(collection.AsQueryable().Count(), Is.EqualTo(1));
            var job = collection.AsQueryable().Single();

            Assert.That(job.BlobId, Is.EqualTo(new BlobId("blob.1")));
            Assert.That(job.TenantId, Is.EqualTo(new TenantId("test_tenant")));
            Assert.That(job.DocumentDescriptorId, Is.EqualTo(new DocumentDescriptorId(1)));
            Assert.That(job.Handle.ToString(), Is.EqualTo(rm.Handle));
            Assert.That(job.Id.ToString(), Is.Not.Contains("blob.1"), "Id should not contains internal concempts like blob id");
            Assert.That(job.Id.ToString(), Is.Not.Contains("tenant"), "Id should not contains internal concempts like tenant id");
            Assert.That(job.Parameters.Keys, Is.Not.Contains(JobKeys.BlobId));
            Assert.That(job.Parameters.Keys, Is.Not.Contains(JobKeys.DocumentId));
        }
        public void verify_max_number_of_falure()
        {
            var info = new QueueInfo("test", "tika", "");

            info.MaxNumberOfFailure = 2;
            QueueHandler sut = CreateAGenericJob(info);

            var nextJob = sut.GetNextJob("", "handle", null, null);

            Assert.That(nextJob, Is.Not.Null);
            var jobId = nextJob.Id;

            sut.SetJobExecuted(nextJob.Id, "Error 42", null);
            nextJob = sut.GetNextJob("", "handle", null, null);
            Assert.That(nextJob, Is.Not.Null);
            sut.SetJobExecuted(nextJob.Id, "Error 42", null);
            nextJob = sut.GetNextJob("", "handle", null, null);
            Assert.That(nextJob, Is.Null, "After two failure the job should not be returned anymore");

            var collection = _db.GetCollection <QueuedJob>("queue.test");
            var job        = collection.Find(Builders <QueuedJob> .Filter.Eq(j => j.Id, jobId)).SingleOrDefault();

            Assert.That(job.ExecutionError, Is.EqualTo("Error 42"));
            Assert.That(job.ErrorCount, Is.EqualTo(2));
            Assert.That(job.Status, Is.EqualTo(QueuedJobExecutionStatus.Failed));
        }
        public void verify_job_created_with_handle_metadata()
        {
            var          info       = new QueueInfo("test", "", "pdf|docx");
            QueueHandler sut        = new QueueHandler(info, _db);
            var          customData = new DocumentCustomData()
            {
                { "test", "value" },
                { "complex", 42 },
            };
            StreamReadModel rm = new StreamReadModel()
            {
                Id         = 1L,
                Handle     = "FirstHandle",
                Filename   = new FileNameWithExtension("test.docx"),
                EventType  = HandleStreamEventTypes.DocumentHasNewFormat,
                FormatInfo = new FormatInfo()
                {
                    PipelineId     = new PipelineId("soffice"),
                    DocumentFormat = new DocumentFormat("office"),
                    BlobId         = new BlobId("soffice.1")
                },
                DocumentDescriptorId = new DocumentDescriptorId(1),
                DocumentCustomData   = customData,
            };

            sut.Handle(rm, new TenantId("test"));

            var collection = _db.GetCollection <QueuedJob>("queue.test");

            Assert.That(collection.AsQueryable().Single().HandleCustomData, Is.EquivalentTo(customData));
        }
        public void verify_get_next_job_set_identity()
        {
            var             info = new QueueInfo("test", "", "pdf|docx");
            QueueHandler    sut  = new QueueHandler(info, _db);
            StreamReadModel rm   = new StreamReadModel()
            {
                Id         = 1L,
                Handle     = "FirstHandle",
                Filename   = new FileNameWithExtension("test.docx"),
                EventType  = HandleStreamEventTypes.DocumentHasNewFormat,
                FormatInfo = new FormatInfo()
                {
                    PipelineId     = new PipelineId("soffice"),
                    DocumentFormat = new DocumentFormat("office"),
                    BlobId         = new BlobId("soffice.1")
                },
                DocumentDescriptorId = new DocumentDescriptorId(1),
            };

            sut.Handle(rm, new TenantId("test"));
            rm.Handle = "SecondHandle";
            rm.Id     = 2L;
            //This is typical situation when handle is de-duplicated, because
            //and handle is assigned to another document, but the underling blob id is the same.
            sut.Handle(rm, new TenantId("test"));
            var collection = _db.GetCollection <QueuedJob>("queue.test");

            //no need to schedule another job
            Assert.That(collection.AsQueryable().Count(), Is.EqualTo(1));
        }
        public void verify_pipeline_id_filter()
        {
            var             info = new QueueInfo("test", "tika", "");
            QueueHandler    sut  = new QueueHandler(info, _db);
            StreamReadModel rm   = new StreamReadModel()
            {
                Filename   = new FileNameWithExtension("test.docx"),
                EventType  = HandleStreamEventTypes.DocumentHasNewFormat,
                FormatInfo = new FormatInfo()
                {
                    PipelineId = new PipelineId("soffice")
                }
            };

            sut.Handle(rm, new TenantId("test"));
            var collection = _db.GetCollection <QueuedJob>("queue.test");

            Assert.That(collection.AsQueryable().Count(), Is.EqualTo(0), "pipeline filter is not filtering out unwanted pipeline");

            rm = new StreamReadModel()
            {
                Filename   = new FileNameWithExtension("test.docx"),
                FormatInfo = new FormatInfo()
                {
                    PipelineId     = new PipelineId("tika"),
                    DocumentFormat = new DocumentFormat("tika"),
                    BlobId         = new BlobId("tika.1")
                }
            };
            sut.Handle(rm, new TenantId("test"));

            Assert.That(collection.AsQueryable().Count(), Is.EqualTo(1), "pipeline filter is not filtering in admitted pipeline");
        }
Ejemplo n.º 31
0
        //private int cnt = 0;
        //private static int counter = 0;
        /// <summary>
        /// Constructs a new <c>FileQueue</c> with the specified properties.
        /// </summary>
        /// <param name="location">The absolute path to the directory for the queue.</param>
        /// <param name="checkInterval">The interval, in minutes, at which to process
        ///			entries in the queue.</param>
        /// <param name="processMethod">The method to call to process entries in
        ///			the queue.</param>
        public FileQueue(
            String location,
            int checkInterval,
            QueueProcessor processMethod)
        {
            this.queueInfo = new QueueInfo();
            this.queueInfo.queueLocation = location;
            this.queueInfo.checkInterval = checkInterval;
            this.queueInfo.processingMethod = processMethod;

            //  make sure the path to the queue directory ends with \
            if (!this.queueInfo.queueLocation.EndsWith("\\")) {
                this.queueInfo.queueLocation += "\\";
            }

            this.SetTimer();
            //cnt = ++counter;
        }
Ejemplo n.º 32
0
 /// <summary>
 /// Constructs a new <c>FileQueue</c> with the properties of the given <c>QueueInfo</c>.
 /// </summary>
 /// <param name="queueInfo"></param>
 private FileQueue(
     QueueInfo queueInfo)
 {
     this.queueInfo = queueInfo;
     //cnt = ++counter;
 }