001    /*
002     * CDDL HEADER START
003     *
004     * The contents of this file are subject to the terms of the
005     * Common Development and Distribution License, Version 1.0 only
006     * (the "License").  You may not use this file except in compliance
007     * with the License.
008     *
009     * You can obtain a copy of the license at
010     * docs/licenses/cddl.txt
011     * or http://www.opensource.org/licenses/cddl1.php.
012     * See the License for the specific language governing permissions
013     * and limitations under the License.
014     *
015     * When distributing Covered Code, include this CDDL HEADER in each
016     * file and include the License file at
017     * docs/licenses/cddl.txt.  If applicable,
018     * add the following below this CDDL HEADER, with the fields enclosed
019     * by brackets "[]" replaced with your own identifying information:
020     *      Portions Copyright [yyyy] [name of copyright owner]
021     *
022     * CDDL HEADER END
023     *
024     *
025     *      Copyright 2010-2012 UnboundID Corp.
026     */
027    package com.unboundid.directory.sdk.proxy.types;
028    
029    
030    
031    import java.util.List;
032    
033    import com.unboundid.directory.sdk.common.types.ServerContext;
034    import com.unboundid.util.NotExtensible;
035    import com.unboundid.util.ThreadSafety;
036    import com.unboundid.util.ThreadSafetyLevel;
037    
038    
039    
040    /**
041     * This interface may be used to obtain information about the Directory Proxy
042     * Server in which an extension is running.
043     */
044    @NotExtensible()
045    @ThreadSafety(level=ThreadSafetyLevel.INTERFACE_THREADSAFE)
046    public interface ProxyServerContext
047           extends ServerContext
048    {
049      /**
050       * Retrieves the location that has been assigned to the server, if any.
051       *
052       * @return  The location that has been assigned to the server, or {@code null}
053       *          if no location has been assigned.
054       */
055      Location getLocation();
056    
057    
058    
059      /**
060       * Creates a health check result with the provided information.
061       *
062       * @param  state     The health check state for the result.  It must not be
063       *                   {@code null}.
064       * @param  score     The score for the result.  It must be an integer value
065       *                   between 1 and 10 for a state of AVAILABLE or DEGRADED, or
066       *                   zero for a state of UNAVAILABLE.
067       * @param  messages  A set of messages with additional information about the
068       *                   reason for the provided state and score.  It may be
069       *                   {@code null} or empty if no messages are needed.
070       *
071       * @return  The created health check result.
072       */
073      HealthCheckResult createHealthCheckResult(final HealthCheckState state,
074                                                final int score,
075                                                final String... messages);
076    
077    
078    
079      /**
080       * Creates a health check result with the provided information.
081       *
082       * @param  state     The health check state for the result.  It must not be
083       *                   {@code null}.
084       * @param  score     The score for the result.  It must be an integer value
085       *                   between 1 and 10 for a state of AVAILABLE or DEGRADED, or
086       *                   zero for a state of UNAVAILABLE.
087       * @param  messages  A set of messages with additional information about the
088       *                   reason for the provided state and score.  It may be
089       *                   {@code null} or empty if no messages are needed.
090       *
091       * @return  The created health check result.
092       */
093      HealthCheckResult createHealthCheckResult(final HealthCheckState state,
094                                                final int score,
095                                                final List<String> messages);
096    
097    
098    
099      /**
100       * Aggregates the information contained in the provided list of health check
101       * results into a single result.  The aggregate result will be the worst
102       * result of all of the provided results, and will contain all the messages
103       * from all of the given results.
104       *
105       * @param  results  The list of health check results to be aggregated.  It
106       *                  must not be {@code null} or empty.
107       *
108       * @return  The health check result which is an aggregation of the provided
109       *          list of results.
110       */
111      HealthCheckResult aggregate(final List<HealthCheckResult> results);
112    }