コード例 #1
0
 private void extendSize() {
   long minSize = TimeUtils.daysToMillis(SKConstants.TEST_QUEUE_NORMAL_SIZE_IN_DAYS);
   long currentSize = endTime - System.currentTimeMillis();
   if (currentSize < minSize) {
     SKLogger.d(this, "extending queue");
     long maxSize = TimeUtils.daysToMillis(SKConstants.TEST_QUEUE_MAX_SIZE_IN_DAYS);
     long newEndSize = System.currentTimeMillis() + maxSize;
     populate(newEndSize);
   } else {
     SKLogger.d(this, "no need to extend queue, endTime: " + TimeUtils.logString(endTime));
   }
 }
コード例 #2
0
 private synchronized void populate(long newEndTime) {
   long timeNow = System.currentTimeMillis();
   startTime = endTime >= timeNow ? endTime : timeNow;
   endTime = newEndTime;
   SKLogger.d(
       this,
       "populating test queue from: "
           + TimeUtils.logString(startTime)
           + " to "
           + TimeUtils.logString(endTime));
   for (TestGroup tg : tc.config.backgroundTestGroups) {
     for (Long t : tg.getTimesInInterval(startTime, endTime)) {
       SKLogger.d(this, "Add test group id " + tg.id + " at time: " + TimeUtils.logString(t));
       addEntry(t, tg);
     }
   }
   SKLogger.d(this, "queue populated with: " + entries.size());
 }
コード例 #3
0
  public ScheduledTestExecutionQueue(TestContext tc) {
    this.tc = tc;
    accumulatedTestBytes = 0L;
    startTime = endTime = System.currentTimeMillis();

    long daysDiff = TimeUtils.daysToMillis(SKConstants.TEST_QUEUE_MAX_SIZE_IN_DAYS);
    long newEndTime = startTime + daysDiff;
    populate(newEndTime);
  }
コード例 #4
0
 private long getSleepTimeDurationMilliseconds() {
   if (entries.isEmpty()) {
     return TimeUtils.daysToMillis(SKConstants.TEST_QUEUE_NORMAL_SIZE_IN_DAYS);
   } else {
     QueueEntry entry = entries.peek();
     long value = entry.getSystemTimeMilliseconds() - System.currentTimeMillis();
     return value;
   }
 }
コード例 #5
0
 public List<Long> getTimesInInterval(long startInterval, long endInterval) {
   List<Long> ret = new ArrayList<Long>();
   long time = startInterval;
   while (time <= endInterval) {
     for (TestTime tt : times) {
       if (tt.getNextStart(time) > startInterval && tt.getNextEnd(time) < endInterval) {
         ret.add(tt.getNextTime(time));
       }
     }
     time = TimeUtils.getStartNextDayTime(time);
   }
   return ret;
 }
コード例 #6
0
  public long getNextTime(long time) {
    long ret = TestTime.NO_START_TIME;
    for (TestTime tt : times) {
      if (tt.getNextStart(time) > time) {
        ret = tt.getNextTime(time);
        break;
      }
    }

    if (ret <= time && !times.isEmpty()) {
      ret = times.get(0).getNextTime(TimeUtils.getStartNextDayTime(time));
    }
    return ret;
  }
コード例 #7
0
 public void addEntry(long time, TestGroup tg) {
   entries.add(new QueueEntry(time, tg.id, tc.config.backgroundTestGroups.indexOf(tg)));
   SKLogger.d(this, "scheduling test group at: " + TimeUtils.logString(time));
 }