예제 #1
0
        public override void setUp()
        {
            // TODO Auto-generated method stub
            base.setUp();
            JDFDoc doc = new JDFDoc(ElementName.QUEUE);

            q = (JDFQueue)doc.getRoot();
            JDFQueueEntry qe = q.appendQueueEntry();

            qe.setQueueEntryID("qe1");
            qe.setJobID("j1");
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Waiting);
            qe.setPriority(5);
            qe = q.appendQueueEntry();
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Waiting);
            qe.setPriority(55);
            qe.setQueueEntryID("qe2");
            qe.setJobID("j2");
            qe = q.appendQueueEntry();
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Held);
            qe.setPriority(99);
            qe.setQueueEntryID("qe3");
            qe.setJobID("j3");
            qe = q.appendQueueEntry();
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Completed);
            qe.setQueueEntryID("qe4");
            qe.setJobID("j4");
            qe = q.appendQueueEntry();
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Running);
            qe.setQueueEntryID("qe5");
            qe.setJobID("j5");
            iThread = 0;
        }
예제 #2
0
        ///
        ///	 <summary> * sets the QueueEntry/@Status if the queue is automated, also resorts the queue to reflect the new Status and sets
        ///	 * the Queue/@Status based on the maximum number of concurrently running jobs also sets StartTime and EndTime
        ///	 * appropriately if the queue is automated
        ///	 *  </summary>
        ///	 * <param name="value"> the queuentry status to set
        ///	 *  </param>
        ///	 * <seealso cref= org.cip4.jdflib.auto.JDFAutoQueueEntry#setQueueEntryStatus(org.cip4.jdflib.auto.JDFAutoQueueEntry.EnumQueueEntryStatus) </seealso>
        ///
        public override void setQueueEntryStatus(EnumQueueEntryStatus @value)
        {
            EnumQueueEntryStatus oldVal = getQueueEntryStatus();

            if (isAutomated() && !ContainerUtil.Equals(oldVal, @value))
            {
                JDFQueue queue = (JDFQueue)getParentNode_KElement();
                lock (queue)
                {
                    base.setQueueEntryStatus(@value);
                    if (isCompleted())
                    {
                        if (!hasAttribute(AttributeName.ENDTIME))
                        {
                            base.setEndTime(new JDFDate());
                        }
                        queue.cleanup();
                    }
                    if (EnumQueueEntryStatus.Running.Equals(@value))
                    {
                        if (!hasAttribute(AttributeName.STARTTIME))
                        {
                            base.setStartTime(new JDFDate());
                        }
                        removeAttribute(AttributeName.ENDTIME);
                    }
                    queue.sortChildren();
                    queue.setStatusFromEntries();
                }
            }
            else if (!ContainerUtil.Equals(oldVal, @value)) // non automated
            {
                base.setQueueEntryStatus(@value);
            }
        }
예제 #3
0
        public override void setUp()
        {
            base.setUp();
            JDFDoc d = new JDFDoc(ElementName.QUEUE);

            theQueue = (JDFQueue)d.getRoot();
            d        = new JDFDoc(ElementName.JMF);
            theJMF   = d.getJMFRoot();
            filter   = theJMF.appendCommand(EnumType.AbortQueueEntry).appendQueueFilter();
        }
        public override void setUp()
        {
            base.setUp();
            JDFDoc d = new JDFDoc(ElementName.QUEUE);

            theQueue = (JDFQueue)d.getRoot();
            d        = new JDFDoc(ElementName.JMF);
            theJMF   = d.getJMFRoot();
            qsp      = theJMF.appendCommand(EnumType.SubmitQueueEntry).appendQueueSubmissionParams();
        }
예제 #5
0
        public virtual void testSortQueue()
        {
            q.setAutomated(true);
            JDFQueue      q2 = (JDFQueue) new JDFDoc("Queue").getRoot();
            JDFQueueEntry qe = q2.appendQueueEntry();

            qe.setQueueEntryID("qeNew");
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Waiting);
            qe.setPriority(42);
            // JDFQueueEntry qe2=(JDFQueueEntry)
            q.moveElement(qe, null);
            q.sortChildren();
            Assert.AreEqual(2, q.getQueueEntryPos("qeNew"));
        }
예제 #6
0
파일: JDFQueue.cs 프로젝트: cip4/JDFLibNet
        public virtual JDFQueue copyToResponse(JDFResponse resp, JDFQueueFilter filter)
        {
            if (resp == null)
            {
                return(null);
            }
            resp.removeChildren(ElementName.QUEUE, null, null);
            JDFQueue newQueue = (JDFQueue)resp.copyElement(this, null);

            if (filter != null)
            {
                filter.match(newQueue);
            }
            return(newQueue);
        }
예제 #7
0
        ///
        ///	 <summary> * add a queueentry to a queue based on the parameters of this you can get the new queueentry by {@link}
        ///	 * getQueueEntry(0) on the response
        ///	 *  </summary>
        ///	 * <param name="theQueue"> the queue to submit to, note that the queue IS modified by this call </param>
        ///	 * <param name="responseIn"> the jmf that serves as a container for the new response
        ///	 *  </param>
        ///	 * <returns> the response jmf to the submission message </returns>
        ///
        public virtual JDFResponse addEntry(JDFQueue theQueue, JDFJMF responseIn)
        {
            JDFCommand  command = (JDFCommand)getParentNode_KElement();
            JDFJMF      jmf     = command.createResponse();
            JDFResponse resp    = jmf.getResponse(0);

            if (responseIn != null)
            {
                resp = (JDFResponse)responseIn.copyElement(resp, null);
            }
            if (theQueue == null)
            {
                resp.setErrorText("No Queue specified");
                resp.setReturnCode(2);
                return(resp);
            }

            if (!theQueue.canAccept())
            {
                resp.setReturnCode(112);
                resp.copyElement(theQueue, null);
                return(resp);
            }
            JDFQueueEntry qe = theQueue.createQueueEntry(getHold());

            string[] copyAtts = new string[] { AttributeName.GANGNAME, AttributeName.GANGPOLICY };

            for (int i = 0; i < copyAtts.Length; i++)
            {
                if (hasAttribute(copyAtts[i]))
                {
                    qe.copyAttribute(copyAtts[i], this, null, null, null);
                }
            }

            // TODO more attributes e.g prev. next...
            if (hasAttribute(AttributeName.PRIORITY))
            {
                qe.setPriority(getPriority()); // calls the automated function,
            }
            // therfore not in the list above

            resp.copyElement(theQueue, null);
            resp.copyElement(qe, null);

            return(resp);
        }
예제 #8
0
        //
        //	 * (non-Javadoc)
        //	 *
        //	 * @see org.cip4.jdflib.auto.JDFAutoQueueEntry#setPriority(int)
        //
        public override void setPriority(int @value)
        {
            int oldVal = hasAttribute(AttributeName.PRIORITY) ? getPriority() : -1;

            if (isAutomated() && @value != oldVal)
            {
                JDFQueue queue = (JDFQueue)getParentNode_KElement();
                lock (queue)
                {
                    base.setPriority(@value);
                    queue.sortChildren();
                }
            }
            else if (@value != oldVal) // non automated
            {
                base.setPriority(@value);
            }
        }
예제 #9
0
        public virtual void testCopyToResponse()
        {
            JDFResponse    r  = JDFJMF.createJMF(JDFMessage.EnumFamily.Response, EnumType.AbortQueueEntry).getResponse(0);
            JDFQueueFilter qf = (JDFQueueFilter) new JDFDoc(ElementName.QUEUEFILTER).getRoot();

            qf.setMaxEntries(3);
            JDFQueue q2 = q.copyToResponse(r, qf);

            Assert.AreEqual(r.getQueue(0), q2);
            Assert.AreEqual(3, q2.numEntries(null));
            Assert.AreNotEqual(q, q2);
            Assert.IsTrue(q.numEntries(null) > 3);
            q2 = q.copyToResponse(r, qf);
            Assert.AreEqual(r.getQueue(0), q2);
            Assert.IsNull(r.getElement("Queue", null, 1));
            Assert.AreEqual(3, q2.numEntries(null));
            Assert.AreNotEqual(q, q2);
            Assert.IsTrue(q.numEntries(null) > 3);
        }
예제 #10
0
        public virtual void testMatchesFilter()
        {
            q.setAutomated(true);
            JDFQueue      q2 = (JDFQueue) new JDFDoc("Queue").getRoot();
            JDFQueueEntry qe = q2.appendQueueEntry();

            qe.setQueueEntryID("qeNew");
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Waiting);
            Assert.IsTrue(qe.matchesQueueFilter(null));
            JDFQueueFilter    filter = (JDFQueueFilter)q.appendElement(ElementName.QUEUEFILTER);
            List <ValuedEnum> v      = new List <ValuedEnum>();

            v.Add(EnumQueueEntryStatus.Completed);
            filter.setStatusList(v);
            Assert.IsFalse(qe.matchesQueueFilter(filter));
            v.Add(EnumQueueEntryStatus.Waiting);
            filter.setStatusList(v);
            Assert.IsTrue(qe.matchesQueueFilter(filter));
        }
예제 #11
0
        public virtual void testAddEntry()
        {
            JDFResponse resp = qsp.addEntry(theQueue, null);

            Assert.AreEqual(0, resp.getReturnCode());
            theQueue = resp.getQueue(0);
            Assert.AreEqual(theQueue.getQueueEntry(0).getQueueEntryStatus(), resp.getQueueEntry(0).getQueueEntryStatus());
            Assert.AreEqual(theQueue.getQueueEntry(0).getQueueEntryID(), resp.getQueueEntry(0).getQueueEntryID());
            Assert.AreNotEqual("", theQueue.getQueueEntry(0).getQueueEntryID());
            Assert.AreEqual(1, theQueue.numEntries(null));
            Assert.AreEqual(1, theQueue.numEntries(EnumQueueEntryStatus.Waiting));
            qsp.setHold(true);
            JDFJMF jmfNew = new JDFDoc("JMF").getJMFRoot();

            resp = qsp.addEntry(theQueue, jmfNew);
            Assert.AreEqual(jmfNew.getResponse(0), resp);
            Assert.AreEqual(2, theQueue.numEntries(null));
            Assert.AreEqual(1, theQueue.numEntries(EnumQueueEntryStatus.Waiting));
            Assert.AreEqual(1, theQueue.numEntries(EnumQueueEntryStatus.Held));
            Assert.AreNotEqual(theQueue.getQueueEntry(0).getQueueEntryID(), theQueue.getQueueEntry(1).getQueueEntryID());
        }
예제 #12
0
        ///
        ///	 <summary> * modifies queue to match this filter by removing all non-matching entries
        ///	 *
        ///	 * make sure that this is a copy of any original queue as the incoming queue itself is not cloned
        ///	 *  </summary>
        ///	 * <param name="theQueue"> the queue to modify </param>
        ///
        public virtual void match(JDFQueue theQueue)
        {
            int maxEntries = hasAttribute(AttributeName.MAXENTRIES) ? getMaxEntries() : 999999;

            VElement v = theQueue.getQueueEntryVector();

            if (v != null)
            {
                int size = v.Count;
                theQueue.setQueueSize(size);

                for (int i = 0; i < size; i++)
                {
                    JDFQueueEntry qe = (JDFQueueEntry)v[i];
                    match(qe);
                }
            }

            for (int i = theQueue.numEntries(null) - 1; i >= maxEntries; i--)
            {
                theQueue.removeChild(ElementName.QUEUEENTRY, null, maxEntries);
            }
            // always zapp first - it is faster to find
        }
예제 #13
0
        public virtual void sortQueue(int oldVal)
        {
            JDFQueue queue = (JDFQueue)getParentNode_KElement();

            queue.sortChildren();
        }