Beispiel #1
0
  @Override
  public void dropOffOperation(OperationExecution result) {
    // Scoreboard closed?
    if (!running) return;

    // Assign label to the operation execution
    if (timing.inRampUp(result.timeStarted)) result.setTraceLabel(TraceLabels.RAMP_UP_LABEL);
    else if (timing.inSteadyState(result.timeFinished))
      result.setTraceLabel(TraceLabels.STEADY_STATE_TRACE_LABEL);
    else if (timing.inSteadyState(result.timeStarted)) result.setTraceLabel(TraceLabels.LATE_LABEL);
    else if (timing.inRampDown(result.timeStarted))
      result.setTraceLabel(TraceLabels.RAMP_DOWN_LABEL);

    // Put all results into the dropoff queue
    long lockStart = System.currentTimeMillis();
    synchronized (swapDropoffQueueLock) {
      // Calculate time required to acquire this lock
      long dropOffWaitTime = (System.currentTimeMillis() - lockStart);

      // Update internal dropoff statistics
      totalDropOffWaitTime += dropOffWaitTime;
      totalDropoffs++;
      maxDropOffWaitTime = Math.max(maxDropOffWaitTime, dropOffWaitTime);

      // Dropoff this operation execution
      dropOffQ.add(result);
    }
  }
Beispiel #2
0
  @Override
  public void run() {
    logger.info(this + " starting scoreboard worker thread...");

    // Run as long as the scoreboard is not done or the dropoff queue still contains entries
    while (running || !dropOffQ.isEmpty()) {
      if (!dropOffQ.isEmpty()) {

        // Queue swap (dropOffQ with processingQ)
        synchronized (swapDropoffQueueLock) {
          List<OperationExecution> temp = processingQ;
          processingQ = dropOffQ;
          dropOffQ = temp;
        }

        // Process all entries in the working queue
        while (!processingQ.isEmpty()) {
          OperationExecution result = processingQ.remove(0);
          TraceLabels traceLabel = result.getTraceLabel();

          // Process this operation by its label
          switch (traceLabel) {
            case STEADY_STATE_TRACE_LABEL:
              processSteadyStateResult(result);
              break;
            case LATE_LABEL:
              processLateStateResult(result);
              break;
            default:
              // Not processed
              break;
          }
        }
      } else {
        // Wait some time, until the dropOffQ fills up
        try {
          Thread.sleep(1000);
        } catch (InterruptedException tie) {
          logger.info(this + " worker thread interrupted.");
        }
      }
    }

    // Debugging
    logger.debug(this + " drop off queue size (should be 0): " + dropOffQ.size());
    logger.debug(this + " processing queue size (should be 0): " + processingQ.size());
    logger.debug(this + " worker thread finished!");
  }
Beispiel #3
0
  private void issueMetricSnapshot(OperationExecution result) {
    // If snapshot thread doesn't exist
    if (metricWriter == null) return;

    long responseTime = result.getExecutionTime();

    // Transferable stat object
    ResponseTimeStat responseTimeStat =
        new ResponseTimeStat(
            result.timeFinished,
            responseTime,
            scorecard.getTotalOpResponseTime(),
            scorecard.getTotalOpsSuccessful(),
            result.operationName,
            result.operationRequest,
            targetId);

    // Accept stat object
    metricWriter.accept(responseTimeStat);
  }