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

The following examples show how to use org.springframework.boot.actuate.endpoint.annotation.Selector. 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: RSocketEndpoint.java    From alibaba-rsocket-broker with Apache License 2.0 6 votes vote down vote up
@WriteOperation
public Mono<String> operate(@Selector String action) {
    if ("online".equalsIgnoreCase(action)) {
        this.rsocketServiceStatus = AppStatusEvent.STATUS_SERVING;
        return sendAppStatus(this.rsocketServiceStatus).thenReturn("Succeed to register RSocket services on brokers!");
    } else if ("offline".equalsIgnoreCase(action)) {
        this.rsocketServiceStatus = AppStatusEvent.STATUS_OUT_OF_SERVICE;
        return sendAppStatus(this.rsocketServiceStatus).thenReturn("Succeed to unregister RSocket services on brokers!");
    } else if ("shutdown".equalsIgnoreCase(action)) {
        this.rsocketServiceStatus = AppStatusEvent.STATUS_STOPPED;
        return sendAppStatus(this.rsocketServiceStatus)
                .thenReturn("Succeed to unregister RSocket services on brokers! Please wait almost 60 seconds to shutdown the Spring Boot App!");
    } else if ("refreshUpstreams".equalsIgnoreCase(action)) {
        Collection<UpstreamCluster> allClusters = this.upstreamManager.findAllClusters();
        for (UpstreamCluster upstreamCluster : allClusters) {
            upstreamCluster.getLoadBalancedRSocket().refreshUnHealthyUris();
        }
        return Mono.just("Begin to refresh unHealthy upstream clusters now!");
    } else {
        return Mono.just("Unknown action, please use online, offline and shutdown");
    }
}
 
Example #2
Source File: BindingsEndpoint.java    From spring-cloud-stream with Apache License 2.0 6 votes vote down vote up
@WriteOperation
public void changeState(@Selector String name, State state) {
	Binding<?> binding = BindingsEndpoint.this.locateBinding(name);
	if (binding != null) {
		switch (state) {
		case STARTED:
			binding.start();
			break;
		case STOPPED:
			binding.stop();
			break;
		case PAUSED:
			binding.pause();
			break;
		case RESUMED:
			binding.resume();
			break;
		default:
			break;
		}
	}
}
 
Example #3
Source File: CircuitBreakerEndpoint.java    From resilience4j with Apache License 2.0 6 votes vote down vote up
@WriteOperation
public CircuitBreakerUpdateStateResponse updateCircuitBreakerState(@Selector String name, UpdateState updateState) {
    final CircuitBreaker circuitBreaker = circuitBreakerRegistry.circuitBreaker(name);
    final String message = "%s state has been changed successfully";
    switch (updateState) {
        case CLOSE:
            circuitBreaker.transitionToClosedState();
            return createCircuitBreakerUpdateStateResponse(name, circuitBreaker.getState().toString(), String.format(message, name));
        case FORCE_OPEN:
            circuitBreaker.transitionToForcedOpenState();
            return createCircuitBreakerUpdateStateResponse(name, circuitBreaker.getState().toString(), String.format(message, name));
        case DISABLE:
            circuitBreaker.transitionToDisabledState();
            return createCircuitBreakerUpdateStateResponse(name, circuitBreaker.getState().toString(), String.format(message, name));
        default:
            return createCircuitBreakerUpdateStateResponse(name, circuitBreaker.getState().toString(), "State change value is not supported please use only " + Arrays.toString(UpdateState.values()));
    }

}
 
Example #4
Source File: EnvironmentBusEndpoint.java    From spring-cloud-bus with Apache License 2.0 5 votes vote down vote up
@WriteOperation
public void busEnvWithDestination(String name, String value,
		@Selector String destination) { // TODO: document params
	Map<String, String> params = Collections.singletonMap(name, value);
	publish(new EnvironmentChangeRemoteApplicationEvent(this, getInstanceId(),
			destination, params));
}
 
Example #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: CircuitBreakersEndpoint.java    From failsafe-actuator with MIT License 5 votes vote down vote up
@WriteOperation
@Nullable
public CircuitBreakerView transitionTo(@Selector final String name, final CircuitBreaker.State state) {
    final CircuitBreaker breaker = breakers.get(name);

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

    transitioner(state).accept(breaker);

    return toView(breaker);
}
 
Example #12
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 #13
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 #14
Source File: CircuitBreakerEventsEndpoint.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
@ReadOperation
public CircuitBreakerEventsEndpointResponse getEventsFilteredByCircuitBreakerName(
    @Selector String name) {
    return new CircuitBreakerEventsEndpointResponse(getCircuitBreakerEvents(name)
        .map(CircuitBreakerEventDTOFactory::createCircuitBreakerEventDTO).toJavaList());
}
 
Example #15
Source File: TimeLimiterEventsEndpoint.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
@ReadOperation
public TimeLimiterEventsEndpointResponse getEventsFilteredByTimeLimiterName(@Selector String name) {
    return new TimeLimiterEventsEndpointResponse(getTimeLimiterEvents(name)
            .map(TimeLimiterEventDTO::createTimeLimiterEventDTO).toJavaList());
}
 
Example #16
Source File: LockEndpoint.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
@WriteOperation
public void releaseLock(@Selector final String id) {
    this.lightminServerLockManager.releaseLock(id, Boolean.TRUE);
}
 
Example #17
Source File: RetryEventsEndpoint.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
/**
 * @param name backend name
 * @return the retry events generated for this backend
 */
@ReadOperation
public RetryEventsEndpointResponse getEventsFilteredByRetryName(@Selector String name) {
    return new RetryEventsEndpointResponse(getRetryEvents(name)
        .map(RetryEventDTOFactory::createRetryEventDTO).toJavaList());
}
 
Example #18
Source File: RateLimiterEventsEndpoint.java    From resilience4j with Apache License 2.0 4 votes vote down vote up
@ReadOperation
public RateLimiterEventsEndpointResponse getEventsFilteredByRateLimiterName(
    @Selector String name) {
    return new RateLimiterEventsEndpointResponse(getRateLimiterEvents(name)
        .map(RateLimiterEventDTO::createRateLimiterEventDTO).toJavaList());
}
 
Example #19
Source File: BindingsEndpoint.java    From spring-cloud-stream with Apache License 2.0 4 votes vote down vote up
@ReadOperation
public Binding<?> queryState(@Selector String name) {
	Assert.notNull(name, "'name' must not be null");
	return this.locateBinding(name);
}
 
Example #20
Source File: RefreshBusEndpoint.java    From spring-cloud-bus with Apache License 2.0 4 votes vote down vote up
@WriteOperation
public void busRefreshWithDestination(@Selector String destination) {
	publish(new RefreshRemoteApplicationEvent(this, getInstanceId(), destination));
}
 
Example #21
Source File: LogFileEndPoint.java    From Moss with Apache License 2.0 4 votes vote down vote up
@ReadOperation
@ResponseBody
public Resource retriveLogfile(@Selector String requiredLogFileName) throws FileNotFoundException {

    return this.registry.getFile(requiredLogFileName);
}