org.springframework.boot.actuate.endpoint.annotation.ReadOperation Java Examples

The following examples show how to use org.springframework.boot.actuate.endpoint.annotation.ReadOperation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsulEndpoint.java    From spring-cloud-consul with Apache License 2.0 6 votes vote down vote up
@ReadOperation
public ConsulData invoke() {
	ConsulData data = new ConsulData();
	// data.setKeyValues(kvClient.getKeyValueRecurse());
	Response<Map<String, Service>> agentServices = this.consul.getAgentServices();
	data.setAgentServices(agentServices.getValue());

	Response<Map<String, List<String>>> catalogServices = this.consul
			.getCatalogServices(CatalogServicesRequest.newBuilder()
					.setQueryParams(QueryParams.DEFAULT).build());

	for (String serviceId : catalogServices.getValue().keySet()) {
		Response<List<CatalogService>> response = this.consul
				.getCatalogService(serviceId, CatalogServiceRequest.newBuilder()
						.setQueryParams(QueryParams.DEFAULT).build());
		data.getCatalogServices().put(serviceId, response.getValue());
	}

	Response<List<Node>> catalogNodes = this.consul
			.getCatalogNodes(CatalogNodesRequest.newBuilder()
					.setQueryParams(QueryParams.DEFAULT).build());
	data.setCatalogNodes(catalogNodes.getValue());

	return data;
}
 
Example #2
Source File: JHipsterMetricsEndpoint.java    From jhipster with Apache License 2.0 6 votes vote down vote up
/**
 * GET /management/jhi-metrics
 * <p>
 * Give metrics displayed on Metrics page
 *
 * @return a Map with a String defining a category of metrics as Key and
 * another Map containing metrics related to this category as Value
 */
@ReadOperation
public Map<String, Map> allMetrics() {

    Map<String, Map> results = new HashMap<>();
    // JVM stats
    results.put("jvm", this.jvmMemoryMetrics());
    // HTTP requests stats
    results.put("http.server.requests", this.httpRequestsMetrics());
    // Cache stats
    results.put("cache", this.cacheMetrics());
    // Service stats
    results.put("services", this.serviceMetrics());
    // Database stats
    results.put("databases", this.databaseMetrics());
    // Garbage collector
    results.put("garbageCollector", this.garbageCollectorMetrics());
    // Process stats
    results.put("processMetrics", this.processMetrics());

    return results;
}
 
Example #3
Source File: WebSocketActuatorEndpoint.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@ReadOperation
public List<Map<String, String>> getAll() {
    List<Map<String, String>> result = new ArrayList<>();

    for (Entry<String, WebSocketRoutedSession> entry : webSocketProxyServerHandler.getRoutedSessions().entrySet()) {
        WebSocketRoutedSession currentSession = entry.getValue();

        Map<String, String> map = new LinkedHashMap<>();

        map.put("sessionId", entry.getKey());
        map.put("clientAddress", currentSession.getServerRemoteAddress());
        map.put("gatewayPath", currentSession.getServerUri());

        map.put("serviceUrl", currentSession.getClientUri());
        map.put("serviceSessionId", currentSession.getClientId());

        result.add(map);
    }

    return result;
}
 
Example #4
Source File: NacosConfigEndpoint.java    From nacos-spring-boot-project with Apache License 2.0 6 votes vote down vote up
@ReadOperation
public Map<String, Object> invoke() {
	Map<String, Object> result = new HashMap<>(8);

	if (!(ClassUtils.isAssignable(applicationContext.getEnvironment().getClass(),
			ConfigurableEnvironment.class))) {
		result.put("error", "environment type not match ConfigurableEnvironment: "
				+ applicationContext.getEnvironment().getClass().getName());
	}
	else {

		result.put("nacosConfigMetadata", nacosConfigMetadataMap.values());

		result.put("nacosConfigGlobalProperties",
				PropertiesUtils.extractSafeProperties(applicationContext.getBean(
						CONFIG_GLOBAL_NACOS_PROPERTIES_BEAN_NAME, Properties.class)));
	}

	return result;
}
 
Example #5
Source File: EndpointCommand.java    From sshd-shell-spring-boot with Apache License 2.0 6 votes vote down vote up
@Autowired
EndpointCommand(ApplicationContext appCtx) {
    appCtx.getBeansWithAnnotation(Endpoint.class).entrySet().stream()
            .sorted(Comparator.comparing(e -> e.getKey()))
            .forEachOrdered(entry -> {
                log.debug("{} : {}", entry.getKey(), entry.getValue().getClass().getName());
                for (Method m : entry.getValue().getClass().getDeclaredMethods()) {
                    if (m.isAnnotationPresent(ReadOperation.class) || m.isAnnotationPresent(WriteOperation.class)) {
                        log.debug("\tOp: {}", m.getName());
                        for (Parameter p : m.getParameters()) {
                            log.debug("\t\tParameter {}, {}", p.getName(), p.getType().getName());
                        }
                    }
                }
            });
}
 
Example #6
Source File: AbstractQuickFixJEndpoint.java    From quickfixj-spring-boot-starter with Apache License 2.0 6 votes vote down vote up
@ReadOperation
public Map<String, Properties> readProperties() {
	Map<String, Properties> reports = new HashMap<>();
	connector.getSessions().forEach(sessionId -> {
		try {
			Properties p = new Properties();
			p.putAll(sessionSettings.getDefaultProperties());
			p.putAll(sessionSettings.getSessionProperties(sessionId));
			p.putAll(addSessionIdProperties(sessionId));

			reports.put(sessionId.toString(), p);
		} catch (ConfigError e) {
			throw new IllegalStateException(e);
		}
	});
	return reports;
}
 
Example #7
Source File: NacosConfigEndpoint.java    From spring-cloud-alibaba with Apache License 2.0 6 votes vote down vote up
@ReadOperation
public Map<String, Object> invoke() {
	Map<String, Object> result = new HashMap<>(16);
	result.put("NacosConfigProperties", properties);

	List<NacosPropertySource> all = NacosPropertySourceRepository.getAll();

	List<Map<String, Object>> sources = new ArrayList<>();
	for (NacosPropertySource ps : all) {
		Map<String, Object> source = new HashMap<>(16);
		source.put("dataId", ps.getDataId());
		source.put("lastSynced", dateFormat.get().format(ps.getTimestamp()));
		sources.add(source);
	}
	result.put("Sources", sources);
	result.put("RefreshHistory", refreshHistory.getRecords());

	return result;
}
 
Example #8
Source File: NacosDiscoveryEndpoint.java    From spring-cloud-alibaba with Apache License 2.0 6 votes vote down vote up
/**
 * @return nacos discovery endpoint
 */
@ReadOperation
public Map<String, Object> nacosDiscovery() {
	Map<String, Object> result = new HashMap<>();
	result.put("NacosDiscoveryProperties", nacosDiscoveryProperties);

	NamingService namingService = nacosDiscoveryProperties.namingServiceInstance();
	List<ServiceInfo> subscribe = Collections.emptyList();

	try {
		subscribe = namingService.getSubscribeServices();
	}
	catch (Exception e) {
		log.error("get subscribe services from nacos fail,", e);
	}
	result.put("subscribe", subscribe);
	return result;
}
 
Example #9
Source File: ServiceRegistryEndpoint.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public ResponseEntity getStatus() {
	if (this.registration == null) {
		return ResponseEntity.status(HttpStatus.NOT_FOUND)
				.body("no registration found");
	}

	return ResponseEntity.ok()
			.body(this.serviceRegistry.getStatus(this.registration));
}
 
Example #10
Source File: BulkheadEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public BulkheadEventsEndpointResponse getEventsFilteredByBulkheadNameAndEventType(
    @Selector String bulkheadName, @Selector String eventType) {
    java.util.List<BulkheadEventDTO> response = getBulkheadEvent(bulkheadName)
        .filter(event -> event.getEventType() == BulkheadEvent.Type
            .valueOf(eventType.toUpperCase()))
        .map(BulkheadEventDTOFactory::createBulkheadEventDTO)
        .toJavaList();

    return new BulkheadEventsEndpointResponse(response);
}
 
Example #11
Source File: CircuitBreakerEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public CircuitBreakerEventsEndpointResponse getAllCircuitBreakerEvents() {
    return new CircuitBreakerEventsEndpointResponse(eventConsumerRegistry.getAllEventConsumer()
        .flatMap(CircularEventConsumer::getBufferedEvents)
        .sorted(Comparator.comparing(CircuitBreakerEvent::getCreationTime))
        .map(CircuitBreakerEventDTOFactory::createCircuitBreakerEventDTO).toJavaList());
}
 
Example #12
Source File: BulkheadEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public BulkheadEventsEndpointResponse getAllBulkheadEvents() {
    java.util.List<BulkheadEventDTO> response = eventConsumerRegistry.getAllEventConsumer()
        .flatMap(CircularEventConsumer::getBufferedEvents)
        .sorted(Comparator.comparing(BulkheadEvent::getCreationTime))
        .map(BulkheadEventDTOFactory::createBulkheadEventDTO)
        .toJavaList();

    return new BulkheadEventsEndpointResponse(response);
}
 
Example #13
Source File: BulkheadEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public BulkheadEndpointResponse getAllBulkheads() {
    List<String> bulkheads = bulkheadRegistry.getAllBulkheads()
        .map(Bulkhead::getName)
        .appendAll(threadPoolBulkheadRegistry
            .getAllBulkheads()
            .map(ThreadPoolBulkhead::getName)).sorted().toJavaList();
    return new BulkheadEndpointResponse(bulkheads);
}
 
Example #14
Source File: CircuitBreakerEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public CircuitBreakerEventsEndpointResponse getEventsFilteredByCircuitBreakerNameAndEventType(
    @Selector String name, @Selector String eventType) {
    return new CircuitBreakerEventsEndpointResponse(getCircuitBreakerEvents(name)
        .filter(event -> event.getEventType() == CircuitBreakerEvent.Type
            .valueOf(eventType.toUpperCase()))
        .map(CircuitBreakerEventDTOFactory::createCircuitBreakerEventDTO).toJavaList());
}
 
Example #15
Source File: BulkheadEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public BulkheadEventsEndpointResponse getEventsFilteredByBulkheadName(
    @Selector String bulkheadName) {
    java.util.List<BulkheadEventDTO> response = getBulkheadEvent(bulkheadName)
        .map(BulkheadEventDTOFactory::createBulkheadEventDTO)
        .toJavaList();

    return new BulkheadEventsEndpointResponse(response);
}
 
Example #16
Source File: RetryEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
/**
 * @return all retry generated events
 */
@ReadOperation
public RetryEventsEndpointResponse getAllRetryEvents() {
    return new RetryEventsEndpointResponse(eventConsumerRegistry.getAllEventConsumer()
        .flatMap(CircularEventConsumer::getBufferedEvents)
        .sorted(Comparator.comparing(RetryEvent::getCreationTime))
        .map(RetryEventDTOFactory::createRetryEventDTO).toJavaList());
}
 
Example #17
Source File: RetryEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
/**
 * @param name      backend name
 * @param eventType retry event type
 * @return the matching generated retry events
 */
@ReadOperation
public RetryEventsEndpointResponse getEventsFilteredByRetryNameAndEventType(
    @Selector String name, @Selector String eventType) {
    return new RetryEventsEndpointResponse(getRetryEvents(name)
        .filter(
            event -> event.getEventType() == RetryEvent.Type.valueOf(eventType.toUpperCase()))
        .map(RetryEventDTOFactory::createRetryEventDTO).toJavaList());
}
 
Example #18
Source File: RateLimiterEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public RateLimiterEventsEndpointResponse getAllRateLimiterEvents() {
    return new RateLimiterEventsEndpointResponse(eventsConsumerRegistry.getAllEventConsumer()
        .flatMap(CircularEventConsumer::getBufferedEvents)
        .sorted(Comparator.comparing(RateLimiterEvent::getCreationTime))
        .map(RateLimiterEventDTO::createRateLimiterEventDTO).toJavaList());
}
 
Example #19
Source File: RateLimiterEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public RateLimiterEventsEndpointResponse getEventsFilteredByRateLimiterNameAndEventType(
    @Selector String name,
    @Selector String eventType) {
    RateLimiterEvent.Type targetType = RateLimiterEvent.Type.valueOf(eventType.toUpperCase());
    return new RateLimiterEventsEndpointResponse(getRateLimiterEvents(name)
        .filter(event -> event.getEventType() == targetType)
        .map(RateLimiterEventDTO::createRateLimiterEventDTO).toJavaList());
}
 
Example #20
Source File: MonitoringEndpoint.java    From javamelody with Apache License 2.0 5 votes vote down vote up
/**
 * Display a report page.
 * @throws ServletException e
 * @throws IOException e
 */
@ReadOperation
public void report() throws ServletException, IOException {
	final ServletRequestAttributes currentRequestAttributes = (ServletRequestAttributes) RequestContextHolder
			.currentRequestAttributes();
	final HttpServletRequest httpServletRequest = currentRequestAttributes.getRequest();
	final HttpServletResponse httpResponse = currentRequestAttributes.getResponse();

	reportServlet.service(httpServletRequest, httpResponse);
}
 
Example #21
Source File: ResolvedEnvironmentEndpoint.java    From kork with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public Map<String, Object> resolvedEnv() {
  return getPropertyKeys().stream()
      .collect(
          Collectors.toMap(
              property -> property,
              property -> {
                try {
                  return sanitizer.sanitize(property, environment.getProperty(property));
                } catch (Exception e) {
                  return format("Exception occurred: %s", e.getMessage());
                }
              }));
}
 
Example #22
Source File: TimeLimiterEventsEndpoint.java    From resilience4j with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public TimeLimiterEventsEndpointResponse getEventsFilteredByTimeLimiterNameAndEventType(@Selector String name,
                                                                                        @Selector String eventType) {
    TimeLimiterEvent.Type targetType = TimeLimiterEvent.Type.valueOf(eventType.toUpperCase());
    return new TimeLimiterEventsEndpointResponse(getTimeLimiterEvents(name)
            .filter(event -> event.getEventType() == targetType)
            .map(TimeLimiterEventDTO::createTimeLimiterEventDTO).toJavaList());
}
 
Example #23
Source File: ServiceStatusEndpoint.java    From zhcet-web with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public Status getStatus() {
    Status status = new Status();

    status.email.enabled = !emailProperties.isDisabled();
    status.email.working = EmailConfiguration.isEmailSet();

    status.firebase.enabled = firebaseService.isEnabled();
    status.firebase.initialized = firebaseService.isInitialized();
    status.firebase.proceedable = firebaseService.canProceed();

    status.pepperSet = SecurePropertyConfig.isPepperSet();

    return status;
}
 
Example #24
Source File: CircuitBreakersEndpoint.java    From failsafe-actuator with MIT License 5 votes vote down vote up
@ReadOperation
@Nullable
public CircuitBreakerView circuitBreaker(@Selector final String name) {
    final CircuitBreaker breaker = breakers.get(name);

    if (breaker == null) {
        return null;
    }

    return toView(breaker);
}
 
Example #25
Source File: LeaderElectionActuator.java    From genie with Apache License 2.0 5 votes vote down vote up
/**
 * Provides the current leader service status: whether the leader service is running and whether the node is leader.
 *
 * @return a map of attributes
 */
@ReadOperation
public Map<String, Object> getStatus() {
    return ImmutableMap.<String, Object>builder()
        .put(RUNNING, this.clusterLeaderService.isRunning())
        .put(LEADER, this.clusterLeaderService.isLeader())
        .build();
}
 
Example #26
Source File: KafkaStreamsTopologyEndpoint.java    From spring-cloud-stream-binder-kafka with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public String kafkaStreamsTopology(@Selector String applicationId) {
	if (!StringUtils.isEmpty(applicationId)) {
		final StreamsBuilderFactoryBean streamsBuilderFactoryBean = this.kafkaStreamsRegistry.streamsBuilderFactoryBean(applicationId);
		if (streamsBuilderFactoryBean != null) {
			return streamsBuilderFactoryBean.getTopology().describe().toString();
		}
		else {
			return NO_TOPOLOGY_FOUND_MSG;
		}
	}
	return NO_TOPOLOGY_FOUND_MSG;
}
 
Example #27
Source File: KafkaStreamsTopologyEndpoint.java    From spring-cloud-stream-binder-kafka with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public String kafkaStreamsTopology() {
	final List<StreamsBuilderFactoryBean> streamsBuilderFactoryBeans = this.kafkaStreamsRegistry.streamsBuilderFactoryBeans();
	final StringBuilder topologyDescription = new StringBuilder();
	streamsBuilderFactoryBeans.stream()
			.forEach(streamsBuilderFactoryBean ->
					topologyDescription.append(streamsBuilderFactoryBean.getTopology().describe().toString()));
	return topologyDescription.toString();
}
 
Example #28
Source File: MarathonEndpoint.java    From spring-cloud-marathon with MIT License 5 votes vote down vote up
@ReadOperation
public MarathonData info() {
    try {
        return MarathonData.builder()
                .serverInfo(marathon.getServerInfo())
                .apps(marathon.getApps().getApps())
                .build();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }

    return MarathonData.builder().build();
}
 
Example #29
Source File: LoggedInEndoint.java    From zhcet-web with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public List<LoggedUser> getLoggedInUsers() {
    return authService.getUsersFromSessionRegistry()
            .stream()
            .map(customUser -> modelMapper.map(customUser, LoggedUser.class))
            .collect(Collectors.toList());
}
 
Example #30
Source File: Bucket4jEndpoint.java    From bucket4j-spring-boot-starter with Apache License 2.0 5 votes vote down vote up
@ReadOperation
public Map<String, Object> bucket4jConfig() {
	Map<String, Object> result = new HashMap<>();
	if(servletConfigs != null) {
		result.put("servlet", servletConfigs.getFilterConfiguration());
	}
	if(zuulConfigs != null) {
		result.put("zuul", zuulConfigs.getFilterConfiguration());
	}
	if(webfluxConfigs != null) {
		result.put("webflux", webfluxConfigs.getFilterConfiguration());
	}
	
	return result;
}