Package org.apache.sling.hc.api

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


        if ( refs != null ) {
            final List<ServiceReference> sortedRefs = Arrays.asList(refs);
            Collections.sort(sortedRefs);

            for(final ServiceReference ref : sortedRefs) {
                final HealthCheck hc = (HealthCheck)bundleContext.getService(ref);
                log.debug("Selected HealthCheck service {}", hc);
                if ( hc != null ) {
                    this.usedReferences.add(ref);
                    result.add(hc);
                }
View Full Code Here


                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) {
View Full Code Here

            if(OSGiFilter.contains(key)) {
                final HcLogSetter hls = LOG_SETTERS.get(key);
                final ServiceReference ref = Mockito.mock(ServiceReference.class);
                Mockito.when(ref.getProperty(Constants.SERVICE_ID)).thenReturn(random.nextLong());
                Mockito.when(ref.getProperty(HealthCheck.NAME)).thenReturn("someTest");
                final HealthCheck hc = new HealthCheck() {
                    @Override
                    public Result execute() {
                        final FormattingResultLog log = new FormattingResultLog();
                        return new Result(hls.setLog(log));
                    }
View Full Code Here

    @Test
    public void testAsyncHealthCheck() throws InterruptedException {
        final String id = UUID.randomUUID().toString();
        final AtomicInteger counter = new AtomicInteger(Integer.MIN_VALUE);
        final HealthCheck hc = new HealthCheck() {
            @Override
            public Result execute() {
                final int v = counter.incrementAndGet();
                return new Result(Result.Status.OK, "counter is now " + v);
            }
View Full Code Here

TOP

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

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.