Checks the report URL every 5 seconds until the report has a finished time available, then we know it is done being generated. Throws BlackDuckIntegrationException after 30 minutes if the report has not been generated yet.
762453
public ReportView isReportFinishedGenerating(String reportUri) throws InterruptedException, IntegrationException {
        long startTime = System.currentTimeMillis();
        long elapsedTime = 0;
        Date timeFinished = null;
        ReportView reportInfo = null;

        while (timeFinished == null) {
            reportInfo = blackDuckService.getResponse(reportUri, ReportView.class);
            timeFinished = reportInfo.getFinishedAt();
            if (timeFinished != null) {
                break;
            }
            if (elapsedTime >= timeoutInMilliseconds) {
                String formattedTime = String.format("%d minutes", TimeUnit.MILLISECONDS.toMinutes(timeoutInMilliseconds));
                throw new BlackDuckIntegrationException("The Report has not finished generating in : " + formattedTime);
            }
            // Retry every 5 seconds
            Thread.sleep(5000);
            elapsedTime = System.currentTimeMillis() - startTime;
        }
        return reportInfo;
    }
92620
protected String generateReport (String type, long now, boolean reset)
    {
        long sinceLast = now - _lastReportStamp;
        long uptime = now - _serverStartTime;
        StringBuilder report = new StringBuilder();

        // add standard bits to the default report
        if (DEFAULT_TYPE.equals(type)) {
            report.append("- Uptime: ");
            report.append(StringUtil.intervalToString(uptime)).append("\n");
            report.append("- Report period: ");
            report.append(StringUtil.intervalToString(sinceLast)).append("\n");

            // report on the state of memory
            Runtime rt = Runtime.getRuntime();
            long total = rt.totalMemory(), max = rt.maxMemory();
            long used = (total - rt.freeMemory());
            report.append("- Memory: ").append(used/1024).append("k used, ");
            report.append(total/1024).append("k total, ");
            report.append(max/1024).append("k max\n");
        }

        for (Reporter rptr : _reporters.get(type)) {
            try {
                rptr.appendReport(report, now, sinceLast, reset);
            } catch (Throwable t) {
                log.warning("Reporter choked", "rptr", rptr, t);
            }
        }

        /* The following Interval debug methods are no longer supported,
         * but they could be added back easily if needed.
        report.append("* samskivert.Interval:\n");
        report.append("- Registered intervals: ");
        report.append(Interval.registeredIntervalCount());
        report.append("\n- Fired since last report: ");
        report.append(Interval.getAndClearFiredIntervals());
        report.append("\n");
        */

        // strip off the final newline
        int blen = report.length();
        if (report.length() > 0 && report.charAt(blen-1) == '\n') {
            report.delete(blen-1, blen);
        }

        // only reset the last report time if this is a periodic report
        if (reset) {
            _lastReportStamp = now;
        }

        return report.toString();
    }
847965
private boolean waitForWebElementsToBeCreated(){
		final long endTime = SystemClock.uptimeMillis() + 5000;

		while(SystemClock.uptimeMillis() < endTime){

			if(isFinished){
				return true;
			}

			sleeper.sleepMini();
		}
		return false;
	}
569175
@Override
    public void onNewReport(final AcraReport pReport) throws SynchronizationException {

        final Issue issue = new Issue();

        final Project project = new Project();
        project.setId(ConfigurationManager.getInstance().CHILIPROJECT_PROJECT_ID);
        issue.setProject(project);

        final Tracker tracker = new Tracker();
        tracker.setId(ConfigurationManager.getInstance().CHILIPROJECT_TRACKER_ID);
        issue.setTracker(tracker);

        final CustomField md5CustomField = new CustomField();
        md5CustomField.setId(ConfigurationManager.getInstance().CHILIPROJECT_STACKTRACE_MD5_CF_ID);
        md5CustomField.setValue(pReport.getStacktraceMD5());
        issue.getCustomFields().add(md5CustomField);

        final String stack = pReport.getValue(AcraReportHeader.STACK_TRACE);
        final IssueDescriptionBuilder description = new IssueDescriptionBuilder(stack);
        description.addOccurrence(IssueDescriptionUtils.toErrorOccurrence(pReport));

        final Matcher m = Pattern.compile("(.*)$", Pattern.MULTILINE).matcher(stack);
        m.find();
        issue.setSubject(m.group());
        issue.setDescription(description.build());

        try {
            redmineClient.createIssue(
                    String.valueOf(ConfigurationManager.getInstance().CHILIPROJECT_PROJECT_ID),
                    issue);
        } catch (final Exception e) {
            pReport.setStatus(SyncStatus.FAILURE);
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Failure while creating issue: \n{}",
                        ToStringBuilder.reflectionToString(issue, ToStringStyle.MULTI_LINE_STYLE));
            }
            throw new SynchronizationException("Unable to create issue for ACRA report: "
                    + pReport.getId(), e);
        }
        pReport.setStatus(SyncStatus.SUCCESS);
    }
634361
@Override
    public void checkTimeout() {
	if (!engine.allowRequestTimeout()) return;

	// print.e(MonitorState.checkForBlockedThreads(runningPcs.values()));
	// print.e(MonitorState.checkForBlockedThreads(runningChildPcs.values()));

	// synchronized (runningPcs) {
	// int len=runningPcs.size();
	// we only terminate child threads

	Map<Integer, PageContextImpl> map = engine.exeRequestAsync() ? runningChildPcs : runningPcs;

	{
	    Iterator<Entry<Integer, PageContextImpl>> it = map.entrySet().iterator();
	    PageContextImpl pc;
	    Entry<Integer, PageContextImpl> e;
	    while (it.hasNext()) {
		e = it.next();
		pc = e.getValue();

		long timeout = pc.getRequestTimeout();
		if (pc.getStartTime() + timeout < System.currentTimeMillis() && Long.MAX_VALUE != timeout) {
		    Log log = ((ConfigImpl) pc.getConfig()).getLog("requesttimeout");
		    if (log != null) {
			log.log(Log.LEVEL_ERROR, "controller",
				"stop " + (pc.getParentPageContext() == null ? "request" : "thread") + " (" + pc.getId() + ") because run into a timeout " + getPath(pc) + "."
					+ MonitorState.getBlockedThreads(pc) + RequestTimeoutException.locks(pc) + "\n" + MonitorState.toString(pc.getThread().getStackTrace()));
		    }
		    terminate(pc, true);
		    runningPcs.remove(Integer.valueOf(pc.getId()));
		    it.remove();
		}
		// after 10 seconds downgrade priority of the thread
		else if (pc.getStartTime() + 10000 < System.currentTimeMillis() && pc.getThread().getPriority() != Thread.MIN_PRIORITY) {
		    Log log = ((ConfigImpl) pc.getConfig()).getLog("requesttimeout");
		    if (log != null) {
			log.log(Log.LEVEL_WARN, "controller", "downgrade priority of the a " + (pc.getParentPageContext() == null ? "request" : "thread") + " at " + getPath(pc)
				+ ". " + MonitorState.getBlockedThreads(pc) + RequestTimeoutException.locks(pc) + "\n" + MonitorState.toString(pc.getThread().getStackTrace()));
		    }
		    try {
			pc.getThread().setPriority(Thread.MIN_PRIORITY);
		    }
		    catch (Throwable t) {
			ExceptionUtil.rethrowIfNecessary(t);
		    }
		}
	    }
	}
    }
217413
protected void submitReport() {
    try {
      utilizationGauger.gauge();
      rpcCollector.reportTaskTrackerUtilization(
              utilizationGauger.getTaskTrackerUtilization(),
              utilizationGauger.getLocalJobUtilization());
    } catch (IOException e) {
      LOG.error(StringUtils.stringifyException(e));
    }
  }
84682
private void checkDone() {
    if (doneHandler != null) {
      if (cause != null) {
        doneHandler.handle(new DefaultFutureResult<T>(cause));
      } else {
        if (count == required) {
          doneHandler.handle(new DefaultFutureResult<T>((T) null));
        }
      }
    }
  }
1021775
@Override
    public void verifyOrCreateReport(String reportId) {
        checkNotNull(reportId, "reportId");

        String tableName = getTableName(reportId);
        if (_dataStore.getTableExists(tableName)) {
            return;  // Nothing to do.
        }

        try {
            // TODO: when run in the EU this should be routed to the US data center.
            _dataStore.createTable(tableName,
                    new TableOptionsBuilder().setPlacement(_systemTablePlacement).build(),
                    ImmutableMap.<String, String>of(),
                    new AuditBuilder().setComment("create table").build()
            );
        } catch (TableExistsException e) {
            // This is expected if we're continuing an existing report.
        }
    }
679321
def afterSummaryReport(self, event):
        
        logger.info('Generating HTML report...')

        sorted_test_results = self._sort_test_results()

        context = {
            'test_report_title': 'Test Report',
            'test_summary': self.summary_stats,
            'test_results': sorted_test_results,
            'autocomplete_terms': json.dumps(self._generate_search_terms()),
            'timestamp': datetime.utcnow().strftime('%Y/%m/%d %H:%M:%S UTC')
        }
        template = load_template(self._config['template'])
        rendered_template = render_template(template, context)
        with open(self._config['report_path'], 'w') as template_file:
            template_file.write(rendered_template)
1222058
private void verifyTimestamp(X509Certificate cert)
        throws CertPathValidatorException
    {
        String msg = "timestamp";
        if (debug != null)
            debug.println("---checking " + msg + ":" + date.toString() + "...");

        try {
            cert.checkValidity(date);
        } catch (CertificateExpiredException e) {
            throw new CertPathValidatorException
                (msg + " check failed", e, null, -1, BasicReason.EXPIRED);
        } catch (CertificateNotYetValidException e) {
            throw new CertPathValidatorException
                (msg + " check failed", e, null, -1, BasicReason.NOT_YET_VALID);
        }

        if (debug != null)
            debug.println(msg + " verified.");
    }
1312651
public void notifyCheckpointComplete(long checkpointId, long timestamp) {
		final LogicalSlot slot = assignedResource;

		if (slot != null) {
			final TaskManagerGateway taskManagerGateway = slot.getTaskManagerGateway();

			taskManagerGateway.notifyCheckpointComplete(attemptId, getVertex().getJobId(), checkpointId, timestamp);
		} else {
			LOG.debug("The execution has no slot assigned. This indicates that the execution is " +
				"no longer running.");
		}
	}
1119793
def on_finish(self):
        
        super(StatsdMixin, self).on_finish()
        key = '%s.%s.%s.%s' % (self.__module__,
                               self.__class__.__name__,
                               self.request.method, self._status_code)
        LOGGER.info('Processing %s', key)
        self.statsd_incr(key)
        self.statsd_add_timing(key, self.request.request_time() * 1000)
995691
@Override
    protected void loadReport(ReportsConfig result, File report, String reportId) throws IOException {
        // Need to refresh? -- CahcedReport should be made abstract and the type should define which class to use
        // and what refresh checking method is used.
        if (!cache.containsKey(reportId) || cache.get(reportId).getLastModified() != report.lastModified())
        {
            super.loadReport(result, report, reportId);
            cache.put(reportId,new CachedReport(result.getReports().get(reportId),report.lastModified()));
        }
        result.getReports().put(reportId, cache.get(reportId).getReportConfig());
    }
612681
public String executePostRequestAndRetrieveURL(BlackDuckPath path, Request.Builder requestBuilder) throws IntegrationException {
        String uri = pieceTogetherUri(blackDuckHttpClient.getBaseUrl(), path.getPath());
        requestBuilder.uri(uri);
        return executePostRequestAndRetrieveURL(requestBuilder.build());
    }
584122
public void onRetry(Throwable t) {
        try {
            this.retries++;
            debugRelativeTime("onRetry: " + this.retries);
            metricRecorder.incrementRetriesCount();
            if (timeout != null) {
                timeout.restart();
                attemptStartTime = System.nanoTime();
            }
            onAttemptComplete(t);
        } catch (RuntimeException e) {
            // Unchecked exceptions thrown here can be swallowed by Failsafe
            // This catch ensures we at least get an FFDC
            throw e;
        }
    }
531116
@Override
    public void visit(JunitXmlReport report) {

        int testsPassed = report.getTests() - report.getFailures() - report.getErrors();

        Map<String, Pair<Integer, CodeQualityMetricStatus>> metricsMap = new HashMap<>();
        metricsMap.put(TOTAL_NO_OF_TESTS, Pair.of(report.getTests(), CodeQualityMetricStatus.Ok));
        metricsMap.put(TEST_FAILURES, Pair.of(report.getFailures(), report.getFailures() > 0 ? CodeQualityMetricStatus.Warning : CodeQualityMetricStatus.Ok));
        metricsMap.put(TEST_ERRORS, Pair.of(report.getErrors(), report.getErrors() > 0 ? CodeQualityMetricStatus.Alert : CodeQualityMetricStatus.Ok));
        metricsMap.put(TEST_SUCCESS_DENSITY, Pair.of(testsPassed, CodeQualityMetricStatus.Ok));

        if (null != report.getTimestamp()) {
            long timestamp = Math.max(quality.getTimestamp(), report.getTimestamp().toGregorianCalendar().getTimeInMillis());
            quality.setTimestamp(timestamp);
        }
        quality.setType(CodeQualityType.StaticAnalysis);

        // finally produce the result
        this.sumMetrics(metricsMap);

    }
606518
@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		long millis = System.currentTimeMillis();
		
		super.onCreate(savedInstanceState);

		millis = System.currentTimeMillis() - millis;
		
		Log.i("INSTRUMENTATION:IckleFragmentActivity", getClass().getSimpleName() + ": " + millis + "ms");
	}