001/**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.camel.spi;
018
019import java.util.List;
020
021import org.apache.camel.StaticService;
022
023/**
024 * A registry which listen for runtime usage of {@link org.apache.camel.Endpoint} during routing in Camel.
025 */
026public interface RuntimeEndpointRegistry extends StaticService {
027
028    /**
029     * Statistics gathered about the endpoint.
030     */
031    public interface Statistic {
032
033        /**
034         * The endpoint uri
035         */
036        String getUri();
037
038        /**
039         * The route id (if the endpoint is associated with a route)
040         */
041        String getRouteId();
042
043        /**
044         * Whether the endpoint is used as input our output
045         * <p/>
046         * The returned value can either be <tt>in</tt> or <tt>out</tt>
047         */
048        String getDirection();
049
050        /**
051         * Usage of the endpoint, such as how many messages it has received / sent to
052         * <p/>
053         * This information is only available if {@link org.apache.camel.ManagementStatisticsLevel} is configured as
054         * {@link org.apache.camel.ManagementStatisticsLevel#Extended}.
055         */
056        long getHits();
057    }
058
059    /**
060     * Whether gathering runtime usage is enabled or not.
061     */
062    boolean isEnabled();
063
064    /**
065     * Sets whether gathering runtime usage is enabled or not.
066     */
067    void setEnabled(boolean enabled);
068
069    /**
070     * Maximum number of endpoints to keep in the cache per route.
071     * <p/>
072     * The default value is <tt>1000</tt>
073     */
074    int getLimit();
075
076    /**
077     * Sets the maximum number of endpoints to keep in the cache per route.
078     */
079    void setLimit(int limit);
080
081    /**
082     * Clears the registry
083     */
084    void clear();
085
086    /**
087     * Reset the statistic counters
088     */
089    void reset();
090
091    /**
092     * Number of endpoints currently in the cache.
093     */
094    int size();
095
096    /**
097     * Gets all the endpoint uris captured during runtime routing that are in-use of the routes.
098     *
099     * @param includeInputs whether to include route inputs
100     */
101    List<String> getAllEndpoints(boolean includeInputs);
102
103    /**
104     * Gets all the endpoint uris captured from the given route during runtime routing that are in-use of the routes.
105     *
106     * @param routeId       the route id
107     * @param includeInputs whether to include route inputs
108     */
109    List<String> getEndpointsPerRoute(String routeId, boolean includeInputs);
110
111    /**
112     * Gets details about all the endpoint captured from the given route during runtime routing that are in-use of the routes.
113     */
114    List<Statistic> getEndpointStatistics();
115
116}