Ejemplo n.º 1
0
  public void start() {
    // Thread is running
    running = true;

    // Start snapshot thread
    metricWriter = new MetricWriterThread();
    metricWriter.setName("Scoreboard-Snapshot-Writer");
    metricWriter.start();

    // Start worker thread
    setName("Scoreboard-Worker");
    super.start();
  }
Ejemplo n.º 2
0
  public void dispose() {
    // Disable running flag
    running = false;

    // Worker thread
    try {
      // Join worker thread
      logger.debug(this + " waiting for worker thread to exit!");
      join(60 * 1000);

      // If its still alive try to interrupt it
      if (isAlive()) {
        logger.debug(this + " interrupting worker thread.");
        interrupt();
      }
    } catch (InterruptedException ie) {
      logger.info(this + " Interrupted waiting on worker thread exit!");
    }

    // Snapshot thread
    try {
      // Stop snapshot thread
      if (metricWriter != null) {
        // Set stop flag
        metricWriter.interrupt();

        // Wait to join
        logger.debug(this + " waiting metric snapshot writer thread to join");
        metricWriter.join(60 * 1000);

        // If its still alive try to interrupt again
        if (metricWriter.isAlive()) {
          logger.debug(this + " interrupting snapshot thread.");
          metricWriter.interrupt();
        }
      }
    } catch (InterruptedException ie) {
      logger.info(this + " Interrupted waiting on snapshot thread exit!");
    }
  }
Ejemplo n.º 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);
  }