I agree with the idea.  I had changed the code to do the same thing and
have been testing it.
It works great for me.

I think this should be changed also.

-Chris



                                                                                       
                                                
                      "Dave Brewster"                                                  
                                                
                      <[EMAIL PROTECTED]        To:       <[EMAIL PROTECTED]>          
                                    
                      ire.com>                 cc:                                     
                                                
                                               Subject:  Scheduler problems            
                                                
                      10/22/2003 08:56                                                 
                                                
                      PM                                                               
                                                
                      Please respond to                                                
                                                
                      "JMeter Users                                                    
                                                
                      List"                                                            
                                                
                                                                                       
                                                
                                                                                       
                                                




I'm trying to develop my own listener that acts like a duration scheduled
thread group.  I.e. the thread group runs for X number of seconds.

All of this was easy to do with on exceptions.  I'm running into problems
with the startScheduler method in JMeterThread.  Threads "randomly" die
before they start due to the code in this method  the code is:

    public void startScheduler()
    {
        long delay = (startTime - System.currentTimeMillis());
        if (delay > 0)
        {
            try
            {
                running = true;
                Thread.sleep(delay);
            }
            catch (Exception e)
            {
            }
        }
        else
        {
            running = false;
        }
    }

IMHO it should be changed to:

    public void startScheduler()
    {
        running = true;
        long delay = (startTime - System.currentTimeMillis());
        if (delay > 0)
        {
            try
            {
                Thread.sleep(delay);
            }
            catch (Exception e)
            {
            }
        }
    }

In most (if not all?) cases one doesn't care if the start time is in the
past; the thread should still start.

Thoughts?  Is it possible to get this into the main line if things seem
fine?  (I've noticed other posted around this same issue as well).


The two methods I'm overriding in this class are (and it extends from
ThreadGroup):

  private long _startTime = 0;

  public long getStartTime() {
    _startTime = System.currentTimeMillis();
    return _startTime;
  }

  /**
   * Ends after specified duration
   * @return
   */
  public long getEndTime() {
    long baseValue = getProperty(TEST_DURATION).getLongValue();
    String overrideStr = System.getProperty(TEST_DURATION_PROP, null);
    if (overrideStr == null)
    {
      overrideStr = JMeterUtils.getPropDefault(TEST_DURATION_PROP, null);
    }
    try {
      if (overrideStr != null)
      {
        baseValue = Long.parseLong(overrideStr);
      }
    } catch (NumberFormatException ex)
    {
      throw new RuntimeException("Could not convert number to int " +
    overrideStr);
    }

    return _startTime + (baseValue * 1000L);
  }

Thanks,

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to