Exemple #1
0
        public virtual VString findQueueEntries(string strJobID, string strJobPartID, VJDFAttributeMap vamParts, EnumQueueEntryStatus status)
        {
            VString vsQEntryIDs = new VString();

            int entryCount = getEntryCount();

            for (int i = 0; i < entryCount; i++)
            {
                JDFQueueEntry entry = getQueueEntry(i);

                string strQEJobID     = entry.getJobID();
                string strQEJobPartID = entry.getJobPartID();

                VJDFAttributeMap vamQEParts = entry.getPartMapVector();

                EnumQueueEntryStatus statusQE = entry.getQueueEntryStatus();

                if (strJobID.Equals(strQEJobID) && strJobPartID.Equals(strQEJobPartID) && vamParts.Equals(vamQEParts))
                {
                    if ((status == null) || (status.Equals(statusQE)))
                    {
                        vsQEntryIDs.appendUnique(entry.getQueueEntryID());
                    }
                }
            }

            return(vsQEntryIDs);
        }
Exemple #2
0
        ///
        ///	 <summary> * modifies queueEntry to match this filter by removing all non-matching attributes and elements
        ///	 *
        ///	 * make sure that this is a copy of any original queue as the incoming queue itself is not cloned
        ///	 *  </summary>
        ///	 * <param name="qe"> </param>
        ///
        public virtual void match(JDFQueueEntry qe)
        {
            if (qe == null)
            {
                return;
            }

            if (!matches(qe))
            {
                qe.deleteNode();
            }
            EnumQueueEntryDetails qed = getQueueEntryDetails();

            if (qed == null)
            {
                qed = EnumQueueEntryDetails.Brief;
            }
            if (EnumUtil.aLessEqualsThanB(EnumQueueEntryDetails.Brief, qed))
            {
                qe.removeChildren(ElementName.JOBPHASE, null, null);
            }
            if (EnumUtil.aLessEqualsThanB(EnumQueueEntryDetails.JobPhase, qed))
            {
                qe.removeChildren(ElementName.JDF, null, null);
            }
        }
Exemple #3
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;
        }
Exemple #4
0
        public virtual void testEndTime()
        {
            JDFQueueEntry _qe = (JDFQueueEntry) new JDFDoc(ElementName.QUEUEENTRY).getRoot();
            JDFDate       d   = _qe.getEndTime();

            Assert.IsNull(d);
        }
Exemple #5
0
        public virtual void testSetPriority()
        {
            JDFQueueEntry qe = q.getQueueEntry("qe2");

            Assert.AreEqual(1, q.getQueueEntryPos("qe2"));
            q.setAutomated(true);
            int l = q.numEntries(null);

            qe.setPriority(99);
            Assert.AreEqual(l, q.numEntries(null));
            Assert.AreEqual(1, q.getQueueEntryPos("qe2"));

            qe.setPriority(0);
            Assert.AreEqual(l, q.numEntries(null));
            Assert.AreEqual(2, q.getQueueEntryPos("qe2"));
            q.removeChildren(ElementName.QUEUEENTRY, null, null);
            for (int i = 0; i < 1000; i++)
            {
                qe = q.appendQueueEntry();
                qe.setQueueEntryID("q" + i);
                qe.setPriority((i * 7) % 100);
                qe.setQueueEntryStatus((i % 3 != 0) ? EnumQueueEntryStatus.Waiting : EnumQueueEntryStatus.Running);
            }
            JDFQueueEntry qeLast = null;

            for (int i = 0; i < 1000; i++)
            {
                qe = q.getQueueEntry(i);
                Assert.IsTrue(qe.CompareTo(qeLast) >= 0, "queue is sorted: " + i);
                qeLast = qe;
            }
        }
Exemple #6
0
        public virtual void testGetNextStatusVector()
        {
            JDFQueueEntry qe = (JDFQueueEntry) new JDFDoc(ElementName.QUEUEENTRY).getRoot();

            qe.setQueueEntryStatus(EnumQueueEntryStatus.Aborted);
            Assert.IsTrue(qe.getNextStatusVector().Contains(EnumQueueEntryStatus.PendingReturn));
            Assert.IsTrue(qe.getNextStatusVector().Contains(EnumQueueEntryStatus.Aborted));
            Assert.IsFalse(qe.getNextStatusVector().Contains(EnumQueueEntryStatus.Running));
        }
Exemple #7
0
        public virtual void testGetTimes()
        {
            JDFQueueEntry qe = q.getQueueEntry(0);

            qe.setQueueEntryID("qe1");
            JDFDate d = qe.getEndTime();

            Assert.IsNull(d, "date");
            qe.setEndTime(null);
            d = qe.getEndTime();
            Assert.AreEqual(new JDFDate().TimeInMillis, d.TimeInMillis, 30000, "date");
        }
Exemple #8
0
 //       (non-Javadoc)
 //		 * @see org.cip4.jdflib.jmf.JDFQueue.ExecuteCallback#canExecute(org.cip4.jdflib.jmf.JDFQueueEntry)
 //
 public override bool canExecute(JDFQueueEntry qe)
 {
     if (proxy != null && qe.hasAttribute(proxy))
     {
         return(false);
     }
     if (deviceID != null && !KElement.isWildCard(qe.getDeviceID()) && !deviceID.Equals(qe.getDeviceID()))
     {
         return(false);
     }
     return(true);
 }
Exemple #9
0
            public virtual void Run()
            {
                int t = 1000 * iThread++;

                for (int i = 0; i < 100; i++)
                {
                    JDFQueueEntry qe = q.appendQueueEntry();
                    qe.setQueueEntryID("q" + t + "_" + i);
                    qe.setPriority((i * 7) % 100);
                    qe.setQueueEntryStatus((t % 2000 == 0) ? EnumQueueEntryStatus.Waiting : EnumQueueEntryStatus.Held);
                }
                iThread--;
            }
Exemple #10
0
        ///
        ///	 <summary> * create a queueEntry if this queue is accepting
        ///	 *  </summary>
        ///	 * <param name="bHeld"> , if true, set the qe Status to Held </param>
        ///	 * <returns> the newly created queueEntry, null if failed </returns>
        ///
        public virtual JDFQueueEntry createQueueEntry(bool bHeld)
        {
            if (!canAccept())
            {
                return(null);
            }
            JDFQueueEntry qe = appendQueueEntry();

            qe.setQueueEntryID("qe" + uniqueID(0));
            qe.setSubmissionTime(new JDFDate());
            qe.setQueueEntryStatus(bHeld ? EnumQueueEntryStatus.Held : EnumQueueEntryStatus.Waiting);
            return(qe);
        }
Exemple #11
0
        /////

        ///
        ///	 <summary> * Find the position of a queueEntry by QueueEntryID
        ///	 *  </summary>
        ///	 * <param name="strQEntryID"> the QueueEntryID of the requeste QueueEntry </param>
        ///	 * <returns> the position in the queue, -1 if not there </returns>
        ///
        public virtual int getQueueEntryPos(string strQEntryID)
        {
            VElement v = getChildElementVector(ElementName.QUEUEENTRY, null, null, true, 0, false);

            for (int i = 0; i < v.Count; i++)
            {
                JDFQueueEntry qe = (JDFQueueEntry)v[i];
                if (qe.getQueueEntryID().Equals(strQEntryID))
                {
                    return(i);
                }
            }
            return(-1);
        }
Exemple #12
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"));
        }
Exemple #13
0
        public virtual void testMatch()
        {
            for (int i = 0; i < 100; i++)
            {
                JDFQueueEntry qe = theQueue.appendQueueEntry();
                qe.setQueueEntryID("q" + i);
            }

            filter.setMaxEntries(10);
            filter.match(theQueue);
            Assert.AreEqual(10, theQueue.numEntries(null));
            filter.setQueueEntryDetails(EnumQueueEntryDetails.None);
            filter.match(theQueue);
            Assert.AreEqual(0, theQueue.numEntries(null));
        }
Exemple #14
0
        public virtual void testCreateQueueEntry()
        {
            q.setAutomated(true);
            q.setMaxRunningEntries(2);
            q.setMaxWaitingEntries(3);
            q.flushQueue(null);
            JDFQueueEntry qe = q.createQueueEntry(false);

            Assert.AreEqual(EnumQueueEntryStatus.Waiting, qe.getQueueEntryStatus());
            qe = q.createQueueEntry(true);
            Assert.AreEqual(EnumQueueEntryStatus.Held, qe.getQueueEntryStatus());
            q.setMaxWaitingEntries(1);
            qe = q.createQueueEntry(true);
            Assert.IsNull(qe);
        }
Exemple #15
0
        ///
        ///	 <summary> * return the number of entries
        ///	 *  </summary>
        ///	 * <param name="qeStatus"> the queueentry status of the enries to count, if null, do not filter </param>
        ///	 * <returns> the number of active processors </returns>
        ///
        public virtual int numEntries(EnumQueueEntryStatus qeStatus)
        {
            int           n    = 0;
            JDFQueueEntry qe   = (JDFQueueEntry)getFirstChildElement(ElementName.QUEUEENTRY, null);
            string        stat = qeStatus == null ? null : qeStatus.getName();

            while (qe != null)
            {
                if (stat == null || stat.Equals(qe.getAttribute(AttributeName.STATUS)))
                {
                    n++;
                }
                qe = (JDFQueueEntry)qe.getNextSiblingElement(ElementName.QUEUEENTRY, null);
            }
            return(n);
        }
Exemple #16
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);
        }
Exemple #17
0
        public virtual VElement getQueueEntryVector(JDFAttributeMap attMap, VJDFAttributeMap parts)
        {
            VElement v = getChildElementVector(ElementName.QUEUEENTRY, null, attMap, true, -1, true);

            if (parts != null)
            {
                for (int i = v.Count - 1; i >= 0; i--)
                {
                    JDFQueueEntry qe = (JDFQueueEntry)v[i];
                    if (!parts.Equals(qe.getPartMapVector()))
                    {
                        v.RemoveAt(i);
                    }
                }
            }
            return((v == null || v.Count == 0) ? null : v);
        }
Exemple #18
0
        public virtual void testThreads()
        {
            q.setAutomated(true);
            q.removeChildren(ElementName.QUEUEENTRY, null, null);
            q.setMaxCompletedEntries(999999999);
            for (int i = 0; i < 10; i++)
            {
                QueueTestThread queueTestThread = new QueueTestThread();
                Thread          runThread       = new Thread(new ThreadStart(queueTestThread.Run));
                runThread.Name = "Test Thread_" + i;
                runThread.Start();
            }
            // now also zapp some...
            for (int j = 0; j < 100; j++)
            {
                JDFQueueEntry qex = q.getNextExecutableQueueEntry();
                if (qex != null)
                {
                    qex.setQueueEntryStatus(EnumQueueEntryStatus.Running);
                    qex.setQueueEntryStatus(EnumQueueEntryStatus.Completed);
                }
            }
            while (iThread > 0)
            {
                StatusCounter.sleep(100); // wait for threads to be over
            }
            Assert.AreEqual(q.getQueueSize(), 1000);
            VElement      v      = q.getQueueEntryVector();
            JDFQueueEntry qeLast = null;

            for (int i = 0; i < v.Count; i++)
            {
                JDFQueueEntry qe = (JDFQueueEntry)v[i];
                Console.WriteLine(qe.getPriority() + " " + qe.getQueueEntryID() + " " + qe.getQueueEntryStatus());
                Assert.IsTrue(qe.CompareTo(qeLast) >= 0);
                qeLast = qe;
            }
            v = q.getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, "Completed"), null);
            Assert.AreEqual(100, v.Count);
            v = q.getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, "Running"), null);
            Assert.IsNull(v);
            v = q.getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, "Held"), null);
            Assert.AreEqual(500, v.Count);
            v = q.getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, "Waiting"), null);
            Assert.AreEqual(400, v.Count);
        }
Exemple #19
0
        public virtual void testSetQueueEntryStatus()
        {
            JDFQueueEntry qe = q.getQueueEntry("qe2");

            Assert.AreEqual(q.getQueueEntryPos("qe2"), 1);
            q.setAutomated(true);
            Assert.AreEqual(EnumQueueStatus.Running, q.getQueueStatus());
            q.setMaxRunningEntries(3);
            q.setMaxCompletedEntries(9999);
            int l = q.numEntries(null);

            qe.setQueueEntryStatus(EnumQueueEntryStatus.Completed);
            Assert.AreEqual(l, q.numEntries(null));
            Assert.IsTrue(qe.hasAttribute(AttributeName.ENDTIME));
            Assert.AreEqual(3, q.getQueueEntryPos("qe2"));
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus(), "3 is max");
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Running);
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus(), "3 is max");
            Assert.AreEqual(l, q.numEntries(null));
            Assert.AreEqual(0, q.getQueueEntryPos("qe2"));
            qe = q.getQueueEntry("qe1");
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Running);
            Assert.AreEqual(EnumQueueStatus.Running, q.getQueueStatus(), "3 is max");
            Assert.AreEqual(l, q.numEntries(null));
            Assert.AreEqual(1, q.getQueueEntryPos("qe1"));

            qe = q.getQueueEntry("qe5");
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Aborted);
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus(), "3 is max");
            Assert.AreEqual(l, q.numEntries(null));
            Assert.AreEqual(4, q.getQueueEntryPos("qe5"));

            qe = q.getQueueEntry("qe1");
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Aborted);
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus(), "3 is max");
            Assert.AreEqual(l, q.numEntries(null));
            Assert.AreEqual(3, q.getQueueEntryPos("qe1"));

            qe.setQueueEntryStatus(EnumQueueEntryStatus.Removed);
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus(), "3 is max");
            Assert.AreEqual(l - 1, q.numEntries(null));
            Assert.AreEqual(-1, q.getQueueEntryPos("qe1"));
            Assert.IsNull(q.getQueueEntry("qe1"));
        }
Exemple #20
0
        public virtual void testCleanup()
        {
            JDFQueueEntry qe      = q.appendQueueEntry();
            MyClean       myClean = new MyClean();

            Assert.AreEqual(0, myClean.i);
            q.setCleanupCallback(myClean);
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Removed);
            q.setAutomated(true);
            q.setMaxCompletedEntries(1);
            Assert.IsFalse(q.getQueueEntryVector().Contains(qe));
            Assert.AreEqual(1, myClean.i);
            Assert.AreEqual(5, q.numEntries(null), "removed completed and aborted");
            q.setMaxCompletedEntries(0);
            q.cleanup();
            Assert.AreEqual(2, myClean.i);

            Assert.AreEqual(4, q.numEntries(null), "removed completed and aborted");
        }
Exemple #21
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));
        }
Exemple #22
0
        public virtual void testMatches()
        {
            JDFQueueEntry qe = theQueue.appendQueueEntry();

            Assert.IsTrue(filter.matches(qe), "both empty ");
            qe.setDeviceID("d1");
            qe.setQueueEntryID("qe1");

            filter.appendDevice("qe1");
            Assert.IsFalse(filter.matches(qe), "no device ");
            filter.appendDevice("d1");
            Assert.IsTrue(filter.matches(qe), " device ");

            filter.appendQueueEntryDef("qe2");
            Assert.IsFalse(filter.matches(qe), "no qentryID ");
            filter.appendQueueEntryDef("qe1");
            Assert.IsTrue(filter.matches(qe), "qentryID ");
            filter.setQueueEntryDetails(EnumQueueEntryDetails.None);
            Assert.IsFalse(filter.matches(qe), "details=none never matches ");
        }
Exemple #23
0
        public virtual VElement getQueueEntryVector(NodeIdentifier nid)
        {
            VElement v = getQueueEntryVector();

            if (nid == null || v == null)
            {
                return(v);
            }

            for (int i = v.Count - 1; i >= 0; i--)
            {
                JDFQueueEntry qe = (JDFQueueEntry)v[i];
                if (!qe.matchesNodeIdentifier(nid))
                {
                    v.RemoveAt(i);
                }
            }

            return((v.Count == 0) ? null : v);
        }
Exemple #24
0
        public virtual void testOpenClose()
        {
            q.setAutomated(true);
            q.setMaxRunningEntries(2);
            q.setMaxWaitingEntries(3);
            q.flushQueue(null);
            Assert.AreEqual(EnumQueueStatus.Waiting, q.openQueue());
            Assert.IsTrue(q.canAccept());
            Assert.IsTrue(q.canExecute());
            Assert.AreEqual(EnumQueueStatus.Closed, q.closeQueue());
            Assert.IsFalse(q.canAccept());
            Assert.IsTrue(q.canExecute());
            Assert.AreEqual(EnumQueueStatus.Waiting, q.openQueue());
            Assert.AreEqual(EnumQueueStatus.Held, q.holdQueue());
            Assert.IsTrue(q.canAccept());
            Assert.IsFalse(q.canExecute());
            Assert.AreEqual(EnumQueueStatus.Waiting, q.resumeQueue());
            Assert.AreEqual(EnumQueueStatus.Held, q.holdQueue());
            Assert.AreEqual(EnumQueueStatus.Blocked, q.closeQueue());
            Assert.IsFalse(q.canAccept());
            Assert.IsFalse(q.canExecute());
            Assert.AreEqual(EnumQueueStatus.Closed, q.resumeQueue());
            Assert.AreEqual(EnumQueueStatus.Waiting, q.openQueue());
            JDFQueueEntry qe = q.createQueueEntry(false);

            qe = q.createQueueEntry(false);
            Assert.IsTrue(q.canAccept());
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus());
            qe = q.createQueueEntry(false);
            Assert.IsFalse(q.canAccept(), "max 3 waiting - see above ");
            Assert.AreEqual(EnumQueueStatus.Closed, q.getQueueStatus());
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Running);
            Assert.IsTrue(q.canAccept(), "max 3 waiting - see above ");
            Assert.IsTrue(q.canExecute(), "max 3 waiting - see above ");
            Assert.AreEqual(EnumQueueStatus.Waiting, q.getQueueStatus());
            qe = q.createQueueEntry(false);
            qe.setQueueEntryStatus(EnumQueueEntryStatus.Running);
            Assert.AreEqual(EnumQueueStatus.Running, q.getQueueStatus());
            qe = q.createQueueEntry(false);
            Assert.AreEqual(EnumQueueStatus.Full, q.getQueueStatus());
        }
Exemple #25
0
        ///
        ///	 <summary> * Find a queueEntry by NodeIdentifier (jobid, jobpartid, part)<br>
        ///	 *
        ///	 * note that you may want to use the generic getChildByTagName with the appropriate attribute map, if you have more
        ///	 * information available
        ///	 *  </summary>
        ///	 * <param name="nodeID"> the identifier - jobID, jobPartID, parts - of the qe </param>
        ///	 * <param name="nSkip"> the number of nodes to skip, cout backwards if<0 </param>
        ///	 * <returns> the QueueEntry with matching jobID, jobPartID, parts, null if nodeID is null or empty string or the
        ///	 *         queueentry does not exist
        ///	 *  </returns>
        ///
        public virtual JDFQueueEntry getQueueEntry(NodeIdentifier nodeID, int nSkip)
        {
            if (nodeID == null)
            {
                return(null);
            }

            VElement v = getQueueEntryVector();

            if (v != null)
            {
                int siz = v.Count;
                int n   = 0;
                if (nSkip >= 0)
                {
                    for (int i = 0; i < siz; i++)
                    {
                        JDFQueueEntry  qe  = (JDFQueueEntry)v[i];
                        NodeIdentifier ni2 = qe.getIdentifier();
                        if (ni2.matches(nodeID) && n++ >= nSkip)
                        {
                            return(qe);
                        }
                    }
                }
                else
                {
                    for (int i = siz - 1; i >= 0; i--)
                    {
                        JDFQueueEntry  qe  = (JDFQueueEntry)v[i];
                        NodeIdentifier ni2 = qe.getIdentifier();
                        if (ni2.matches(nodeID) && --n <= nSkip)
                        {
                            return(qe);
                        }
                    }
                }
            }

            return(null);
        }
Exemple #26
0
        public virtual IDictionary <string, JDFQueueEntry> getQueueEntryIDMap()
        {
            Dictionary <string, JDFQueueEntry> map = null;

            VElement v = getQueueEntryVector();

            if (v != null)
            {
                int siz = v.Count;
                if (siz > 0)
                {
                    map = new Dictionary <string, JDFQueueEntry>(siz);
                    for (int i = 0; i < siz; i++)
                    {
                        JDFQueueEntry qe = (JDFQueueEntry)v[i];
                        map.Add(qe.getQueueEntryID(), qe);
                    }
                }
            }

            return(map);
        }
Exemple #27
0
        public virtual void cleanup()
        {
            VElement v = getQueueEntryVector();

            if (v != null)
            {
                int siz  = v.Count;
                int nBad = 0;
                for (int i = 0; i < siz; i++)
                {
                    JDFQueueEntry        qe     = (JDFQueueEntry)v[i];
                    EnumQueueEntryStatus status = qe.getQueueEntryStatus();
                    if (EnumQueueEntryStatus.Removed.Equals(status))
                    {
                        if (cleanupCallback != null)
                        {
                            cleanupCallback.cleanEntry(qe);
                        }

                        qe.deleteNode();
                    }
                    else if (qe.isCompleted())
                    {
                        if (nBad++ >= maxCompletedEntries)
                        {
                            if (cleanupCallback != null)
                            {
                                cleanupCallback.cleanEntry(qe);
                            }

                            qe.deleteNode();
                        }
                    }
                }
            }

            setStatusFromEntries();
        }
Exemple #28
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
        }
Exemple #29
0
        public virtual VElement flushQueue(JDFQueueFilter qf)
        {
            int siz = 0;

            VElement ve = getQueueEntryVector();

            if (ve != null)
            {
                siz = ve.Count;
                for (int i = siz - 1; i >= 0; i--)
                {
                    JDFQueueEntry qe = (JDFQueueEntry)ve[i];
                    if (qe.matchesQueueFilter(qf))
                    {
                        if (cleanupCallback != null)
                        {
                            cleanupCallback.cleanEntry(qe);
                        }

                        qe.deleteNode();
                    }
                    else
                    {
                        ve.RemoveAt(i);
                        siz--;
                    }
                }
            }

            if (automated)
            {
                setStatusFromEntries();
            }

            return(siz == 0 ? null : ve);
        }
Exemple #30
0
        public virtual JDFQueueEntry getNextExecutableQueueEntry()
        {
            JDFQueueEntry theEntry = null;

            if (!canExecute())
            {
                return(theEntry);
            }

            VElement v = getQueueEntryVector(new JDFAttributeMap(AttributeName.STATUS, EnumQueueEntryStatus.Waiting), null);

            if (v != null)
            {
                int siz = v.Count;
                for (int i = 0; i < siz; i++)
                {
                    JDFQueueEntry qe = (JDFQueueEntry)v[i];

                    if (executeCallback != null && !executeCallback.canExecute(qe))
                    {
                        continue;
                    }

                    if (theEntry == null)
                    {
                        theEntry = qe;
                    }
                    else if (qe.CompareTo(theEntry) < 0)
                    {
                        theEntry = qe;
                    }
                }
            }

            return(theEntry);
        }