@ReadOperation public RateLimiterEventsEndpointResponse getEventsFilteredByRateLimiterNameAndEventType(@Selector String name, @Selector String eventType) { RateLimiterEvent.Type targetType = RateLimiterEvent.Type.valueOf(eventType.toUpperCase()); List<RateLimiterEventDTO> eventsList = eventsConsumerRegistry.getEventConsumer(name).getBufferedEvents() .filter(event -> event.getRateLimiterName().equals(name)) .filter(event -> event.getEventType() == targetType) .map(RateLimiterEventDTO::createRateLimiterEventDTO).toJavaList(); return new RateLimiterEventsEndpointResponse(eventsList); } }
@ReadOperation public CircuitBreakerEventsEndpointResponse getEventsFilteredByCircuitBreakerNameAndEventType(@Selector String name, @Selector String eventType) { return new CircuitBreakerEventsEndpointResponse(eventConsumerRegistry.getEventConsumer(name).getBufferedEvents() .filter(event -> event.getCircuitBreakerName().equals(name)) .filter(event -> event.getEventType() == CircuitBreakerEvent.Type.valueOf(eventType.toUpperCase())) .map(CircuitBreakerEventDTOFactory::createCircuitBreakerEventDTO).toJavaList()); } }
@ReadOperation public CircuitBreakerEventsEndpointResponse getEventsFilteredByCircuitBreakerName(@Selector String name) { return new CircuitBreakerEventsEndpointResponse(eventConsumerRegistry.getEventConsumer(name).getBufferedEvents() .filter(event -> event.getCircuitBreakerName().equals(name)) .map(CircuitBreakerEventDTOFactory::createCircuitBreakerEventDTO).toJavaList()); }
@ReadOperation public RateLimiterEventsEndpointResponse getEventsFilteredByRateLimiterName(@Selector String name) { List<RateLimiterEventDTO> eventsList = eventsConsumerRegistry.getEventConsumer(name).getBufferedEvents() .filter(event -> event.getRateLimiterName().equals(name)) .map(RateLimiterEventDTO::createRateLimiterEventDTO).toJavaList(); return new RateLimiterEventsEndpointResponse(eventsList); }
@WriteOperation public void configureLogLevel(@Selector String name, @Nullable LogLevel configuredLevel) { Assert.notNull(name, "Name must not be empty"); this.loggingSystem.setLogLevel(name, configuredLevel); }
@ReadOperation public WebEndpointResponse<Health> healthForComponentInstance( SecurityContext securityContext, @Selector String component, @Selector String instance) { Supplier<Health> health = () -> this.delegate .healthForComponentInstance(component, instance); return this.responseMapper.mapDetails(health, securityContext); }
@DeleteOperation public void deleteSession(@Selector String sessionId) { this.sessionRepository.deleteById(sessionId); }
@ReadOperation public EnvironmentEntryDescriptor environmentEntry(@Selector String toMatch) { return getEnvironmentEntryDescriptor(toMatch); }
@ReadOperation public LoggerLevels loggerLevels(@Selector String name) { Assert.notNull(name, "Name must not be null"); LoggerConfiguration configuration = this.loggingSystem .getLoggerConfiguration(name); return (configuration != null) ? new LoggerLevels(configuration) : null; }
/** * Return the {@link Health} of a particular {@code instance} managed by the specified * {@code component} or {@code null} if that particular component is not a * {@link CompositeHealthIndicator} or if such instance does not exist. * @param component the name of a particular {@link CompositeHealthIndicator} * @param instance the name of an instance managed by that component * @return the {@link Health} for the component instance of {@code null} */ @ReadOperation public Health healthForComponentInstance(@Selector String component, @Selector String instance) { HealthIndicator indicator = getNestedHealthIndicator(this.healthIndicator, component); HealthIndicator nestedIndicator = getNestedHealthIndicator(indicator, instance); return (nestedIndicator != null) ? nestedIndicator.health() : null; }
/** * Return a {@link CacheDescriptor} for the specified cache. * @param cache the name of the cache * @param cacheManager the name of the cacheManager (can be {@code null} * @return the descriptor of the cache or {@code null} if no such cache exists * @throws NonUniqueCacheException if more than one cache with that name exists and no * {@code cacheManager} was provided to identify a unique candidate */ @ReadOperation public CacheEntry cache(@Selector String cache, @Nullable String cacheManager) { return extractUniqueCacheEntry(cache, getCacheEntries((name) -> name.equals(cache), isNameMatch(cacheManager))); }
@ReadOperation public WebEndpointResponse<Health> healthForComponent(SecurityContext securityContext, @Selector String component) { Supplier<Health> health = () -> this.delegate.healthForComponent(component); return this.responseMapper.mapDetails(health, securityContext); }
/** * Return the {@link Health} of a particular component or {@code null} if such * component does not exist. * @param component the name of a particular {@link HealthIndicator} * @return the {@link Health} for the component or {@code null} */ @ReadOperation public Health healthForComponent(@Selector String component) { HealthIndicator indicator = getNestedHealthIndicator(this.healthIndicator, component); return (indicator != null) ? indicator.health() : null; }
@ReadOperation public SessionDescriptor getSession(@Selector String sessionId) { Session session = this.sessionRepository.findById(sessionId); if (session == null) { return null; } return new SessionDescriptor(session); }
@ReadOperation public WebEndpointResponse<CacheEntry> cache(@Selector String cache, @Nullable String cacheManager) { try { CacheEntry entry = this.delegate.cache(cache, cacheManager); int status = (entry != null) ? WebEndpointResponse.STATUS_OK : WebEndpointResponse.STATUS_NOT_FOUND; return new WebEndpointResponse<>(entry, status); } catch (NonUniqueCacheException ex) { return new WebEndpointResponse<>(WebEndpointResponse.STATUS_BAD_REQUEST); } }
@DeleteOperation public WebEndpointResponse<Void> clearCache(@Selector String cache, @Nullable String cacheManager) { try { boolean cleared = this.delegate.clearCache(cache, cacheManager); int status = (cleared ? WebEndpointResponse.STATUS_NO_CONTENT : WebEndpointResponse.STATUS_NOT_FOUND); return new WebEndpointResponse<>(status); } catch (NonUniqueCacheException ex) { return new WebEndpointResponse<>(WebEndpointResponse.STATUS_BAD_REQUEST); } }
/** * Clear the specific {@link Cache}. * @param cache the name of the cache * @param cacheManager the name of the cacheManager (can be {@code null} to match all) * @return {@code true} if the cache was cleared or {@code false} if no such cache * exists * @throws NonUniqueCacheException if more than one cache with that name exists and no * {@code cacheManager} was provided to identify a unique candidate */ @DeleteOperation public boolean clearCache(@Selector String cache, @Nullable String cacheManager) { CacheEntry entry = extractUniqueCacheEntry(cache, getCacheEntries((name) -> name.equals(cache), isNameMatch(cacheManager))); return (entry != null && clearCache(entry)); }
@ReadOperation public WebEndpointResponse<EnvironmentEntryDescriptor> environmentEntry( @Selector String toMatch) { EnvironmentEntryDescriptor descriptor = this.delegate.environmentEntry(toMatch); return new WebEndpointResponse<>(descriptor, getStatus(descriptor)); }
@ReadOperation public MetricResponse metric(@Selector String requiredMetricName, @Nullable List<String> tag) { List<Tag> tags = parseTags(tag); Collection<Meter> meters = findFirstMatchingMeters(this.registry, requiredMetricName, tags); if (meters.isEmpty()) { return null; } Map<Statistic, Double> samples = getSamples(meters); Map<String, Set<String>> availableTags = getAvailableTags(meters); tags.forEach((t) -> availableTags.remove(t.getKey())); Meter.Id meterId = meters.iterator().next().getId(); return new MetricResponse(requiredMetricName, meterId.getDescription(), meterId.getBaseUnit(), asList(samples, Sample::new), asList(availableTags, AvailableTag::new)); }
@ReadOperation public Binding<?> queryState(@Selector String name) { Assert.notNull(name, "'name' must not be null"); return this.locateBinding(name); }