Package org.apache.sling.hc.api

Examples of org.apache.sling.hc.api.Result


        List<HealthCheckFuture> futures = new LinkedList<HealthCheckFuture>();
        futures.add(future);
        Collection<HealthCheckExecutionResult> results = new TreeSet<HealthCheckExecutionResult>();

        when(future.isDone()).thenReturn(true);
        ExecutionResult testResult = new ExecutionResult(HealthCheckMetadata, new Result(Result.Status.OK, "test"), 10L);
        when(future.get()).thenReturn(testResult);

        healthCheckExecutorImpl.collectResultsFromFutures(futures, results);

        verify(future, times(1)).get();
View Full Code Here


        } else if(failures != 0){
            resultLog.warn("Checked {} logins, {} failures", checked, failures);
        } else {
            resultLog.debug("Checked {} logins, all successful", checked, failures);
        }
        return new Result(resultLog);
    }
View Full Code Here

            resultLog.warn("No paths checked, empty paths list?");
        } else {
            resultLog.debug("{} paths checked, {} failures", checked, failed);
        }

        return new Result(resultLog);
    }
View Full Code Here

            pw.println("<table class='content healthcheck' cellpadding='0' cellspacing='0' width='100%'>");
            int total = 0;
            int failed = 0;
            for (final HealthCheckExecutionResult exR : results) {

                final Result r = exR.getHealthCheckResult();
                total++;
                if (!r.isOk()) {
                    failed++;
                }
                if (!quiet || !r.isOk()) {
                    renderResult(pw, exR, debug);
                }

            }
            final WebConsoleHelper c = new WebConsoleHelper(resp.getWriter());
View Full Code Here

    private void renderResult(final PrintWriter pw,
            final HealthCheckExecutionResult exResult,
            final boolean debug)
   throws IOException {
        final Result result = exResult.getHealthCheckResult();
        final WebConsoleHelper c = new WebConsoleHelper(pw);

        final StringBuilder status = new StringBuilder();

        status.append("Tags: ").append(exResult.getHealthCheckMetadata().getTags());
        c.titleHtml(exResult.getHealthCheckMetadata().getTitle(), null);

        c.tr();
        c.tdContent();
        c.writer().print(ResponseUtil.escapeXml(status.toString()));
        c.writer().print("<br/>Result: <span class='resultOk");
        c.writer().print(result.isOk());
        c.writer().print("'>");
        c.writer().print(result.getStatus().toString());
        c.writer().print("</span>");
        c.closeTd();
        c.closeTr();

        c.tr();
View Full Code Here

     */
    public ExecutionResult(final HealthCheckMetadata metadata,
            final Result.Status status,
            final String errorMessage,
            final long elapsedTime, boolean timedOut) {
        this(metadata, new Result(status, errorMessage), elapsedTime, timedOut);
    }
View Full Code Here

                Thread.currentThread().setName("HealthCheck " + metadata.getTitle());
                LOG.debug("Starting check {}", metadata);

                final StopWatch stopWatch = new StopWatch();
                stopWatch.start();
                Result resultFromHealthCheck = null;
                ExecutionResult executionResult = null;

                final HealthCheck healthCheck = (HealthCheck) bundleContext.getService(metadata.getServiceReference());

                try {
                    if (healthCheck != null) {
                        resultFromHealthCheck = healthCheck.execute();
                    } else {
                        throw new IllegalStateException("Service for " + metadata + " is gone");
                    }

                } catch (final Exception e) {
                    resultFromHealthCheck = new Result(Result.Status.CRITICAL, "Exception during execution of " + this + ": " + e, e);
                } finally {
                    // unget service ref
                    bundleContext.ungetService(metadata.getServiceReference());

                    // update result with information about this run
View Full Code Here

            HealthCheckMetadata healthCheckMetadata = checksIt.next();
            if (isAsync(healthCheckMetadata)) {
                ExecutionResult result = asyncResultsByDescriptor.get(healthCheckMetadata);
                if (result == null) {

                    result = new ExecutionResult(healthCheckMetadata, new Result(Result.Status.INFO, "Async Health Check with cron expression '"
                            + healthCheckMetadata.getAsyncCronExpression() + "' has not yet been executed."), 0L);

                    asyncResults.add(result);
                }
                asyncResults.add(result);
View Full Code Here

            } catch(Exception e) {
                resultLog.warn("Exception while executing tests (" + testSelector + ")" + e);
            }
        }
       
        return new Result(resultLog);
    }
View Full Code Here

    /** Execute our health check and dump its log
     *  messages > INFO if it fails */
    public void testHealthCheck() {
        try {
            final Result r = hc.execute();
            final StringBuilder failMsg = new StringBuilder();
            if(!r.isOk()) {
                failMsg.append(metadata.getName());
                failMsg.append("\n");
                for(ResultLog.Entry log : r) {
                    if(log.getStatus().compareTo(Result.Status.INFO) > 0) {
                        if(failMsg.length() > 0) {
View Full Code Here

TOP

Related Classes of org.apache.sling.hc.api.Result

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.