org.springframework.boot.actuate.endpoint.annotation.WriteOperation Java Examples
The following examples show how to use
org.springframework.boot.actuate.endpoint.annotation.WriteOperation.
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: LeaderElectionActuator.java From genie with Apache License 2.0 | 6 votes |
/** * Forces the node to leave the leader election, then re-join it. * * @param action the action to perform */ @WriteOperation public void doAction(final Action action) { switch (action) { case START: log.info("Starting leader election service"); this.clusterLeaderService.start(); break; case STOP: log.info("Stopping leader election service"); this.clusterLeaderService.stop(); break; case RESTART: log.info("Restarting leader election service"); this.clusterLeaderService.stop(); this.clusterLeaderService.start(); break; default: log.error("Unknown action: " + action); throw new UnsupportedOperationException("Unknown action: " + action.name()); } }
Example #2
Source File: BindingsEndpoint.java From spring-cloud-stream with Apache License 2.0 | 6 votes |
@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 |
@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: RSocketEndpoint.java From alibaba-rsocket-broker with Apache License 2.0 | 6 votes |
@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 #5
Source File: EndpointCommand.java From sshd-shell-spring-boot with Apache License 2.0 | 6 votes |
@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: CircuitBreakersEndpoint.java From failsafe-actuator with MIT License | 5 votes |
@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 #7
Source File: ServiceRegistryEndpoint.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@WriteOperation public ResponseEntity<?> setStatus(String status) { Assert.notNull(status, "status may not by null"); if (this.registration == null) { return ResponseEntity.status(HttpStatus.NOT_FOUND) .body("no registration found"); } this.serviceRegistry.setStatus(this.registration, status); return ResponseEntity.ok().build(); }
Example #8
Source File: RestartEndpoint.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@WriteOperation public Boolean resume() { if (!isRunning()) { doResume(); return true; } return false; }
Example #9
Source File: RestartEndpoint.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@WriteOperation public Boolean pause() { if (isRunning()) { doPause(); return true; } return false; }
Example #10
Source File: RestartEndpoint.java From spring-cloud-commons with Apache License 2.0 | 5 votes |
@WriteOperation public Object restart() { Thread thread = new Thread(this::safeRestart); thread.setDaemon(false); thread.start(); return Collections.singletonMap("message", "Restarting"); }
Example #11
Source File: EnvironmentBusEndpoint.java From spring-cloud-bus with Apache License 2.0 | 5 votes |
@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 #12
Source File: ChaosMonkeyJmxEndpoint.java From chaos-monkey-spring-boot with Apache License 2.0 | 5 votes |
@WriteOperation public String toggleExceptionAssault() { this.chaosMonkeySettings .getAssaultProperties() .setExceptionsActive(!this.getAssaultProperties().getExceptionsActive()); return String.valueOf(this.getAssaultProperties().getExceptionsActive()); }
Example #13
Source File: ChaosMonkeyJmxEndpoint.java From chaos-monkey-spring-boot with Apache License 2.0 | 5 votes |
@WriteOperation public String toggleLatencyAssault() { this.chaosMonkeySettings .getAssaultProperties() .setLatencyActive(!this.getAssaultProperties().getLatencyActive()); return String.valueOf(this.getAssaultProperties().getLatencyActive()); }
Example #14
Source File: ConsoleEndpoint.java From Cleanstone with MIT License | 5 votes |
@WriteOperation public void sendCommand(String commandString) { log.info("WebConsole: " + commandString + ""); CommandMessage commandMessage = CommandMessageFactory.construct(consoleSender, commandString, this.commandRegistry); Command command = commandRegistry.getCommand(commandMessage.getCommandName()); if (command != null) { try { command.execute(commandMessage); } catch (Exception e) { log.error("Error executing Command: []", e); } } }
Example #15
Source File: ChaosMonkeyJmxEndpoint.java From chaos-monkey-spring-boot with Apache License 2.0 | 5 votes |
@WriteOperation public String toggleKillApplicationAssault() { this.chaosMonkeySettings .getAssaultProperties() .setKillApplicationActive(!this.getAssaultProperties().getKillApplicationActive()); return String.valueOf(this.getAssaultProperties().getKillApplicationActive()); }
Example #16
Source File: RefreshBusEndpoint.java From spring-cloud-bus with Apache License 2.0 | 4 votes |
@WriteOperation public void busRefresh() { publish(new RefreshRemoteApplicationEvent(this, getInstanceId(), null)); }
Example #17
Source File: NotesEndpoint.java From spring-in-action-5-samples with Apache License 2.0 | 4 votes |
@WriteOperation public List<Note> addNote(String text) { notes.add(new Note(text)); return notes; }
Example #18
Source File: NotesEndpoint.java From spring-in-action-5-samples with Apache License 2.0 | 4 votes |
@WriteOperation public List<Note> addNote(String text) { notes.add(new Note(text)); return notes; }
Example #19
Source File: RefreshEndpoint.java From spring-cloud-commons with Apache License 2.0 | 4 votes |
@WriteOperation public Collection<String> refresh() { Set<String> keys = this.contextRefresher.refresh(); return keys; }
Example #20
Source File: WritableEnvironmentEndpointWebExtension.java From spring-cloud-commons with Apache License 2.0 | 4 votes |
@WriteOperation public Object write(String name, String value) { this.environment.setProperty(name, value); return Collections.singletonMap(name, value); }
Example #21
Source File: NotesEndpoint.java From spring-in-action-5-samples with Apache License 2.0 | 4 votes |
@WriteOperation public List<Note> addNote(String text) { notes.add(new Note(text)); return notes; }
Example #22
Source File: NotesEndpoint.java From spring-in-action-5-samples with Apache License 2.0 | 4 votes |
@WriteOperation public List<Note> addNote(String text) { notes.add(new Note(text)); return notes; }
Example #23
Source File: TraderAggregateDataInitializer.java From ESarch with Apache License 2.0 | 4 votes |
@WriteOperation public boolean initializeTraderAggregates() throws InterruptedException, ExecutionException { if (hasData()) { logger.warn("#### The Event Store already contains events. Aborting initialization..."); return true; } logger.info("#### The Event Store does not contain any events. " + "Starting initialization of Trader Aggregates."); CommandMessage<Object> canary = asCommandMessage(new CreatePortfolioCommand(new PortfolioId(), new UserId())); if (!commandRouter.findDestination(canary).isPresent()) { logger.error("Trading-Engine isn't running. Unable to initialize data"); return false; } logger.info("Adding some companies to the application..."); CompanyId pivotalId = new CompanyId(); CompanyId axonIQId = new CompanyId(); CompanyId solsticeId = new CompanyId(); commandGateway.sendAndWait(new CreateCompanyCommand(pivotalId, "Pivotal", 100000000, 1000000)); commandGateway.sendAndWait(new CreateCompanyCommand(axonIQId, "AxonIQ", 100000000, 1000000)); commandGateway.sendAndWait(new CreateCompanyCommand(solsticeId, "Solstice", 100000000, 1000000)); logger.info("Adding some users to the application..."); UserId allard = createUser("Allard", "allard"); UserId steven = createUser("Steven", "steven"); UserId ben = createUser("Ben", "ben"); UserId pieter = createUser("Pieter", "pieter"); UserId sampath = createUser("Sampath", "sampath"); UserId haridu = createUser("Haridu", "haridu"); UserId jakub = createUser("Jakub", "jakub"); UserId kenny = createUser("Kenny", "kenny"); UserId david = createUser("David", "david"); logger.info("Giving each user a starting position..."); addMoney(allard, 100000); addItems(allard, axonIQId, 10000L); addMoney(steven, 100000); addItems(steven, axonIQId, 10000L); addMoney(ben, 100000); addItems(ben, pivotalId, 10000L); addMoney(pieter, 100000); addItems(pieter, pivotalId, 10000L); addMoney(sampath, 100000); addItems(sampath, solsticeId, 10000L); addMoney(haridu, 100000); addItems(haridu, solsticeId, 10000L); addMoney(jakub, 100000); addItems(jakub, pivotalId, 10000L); addMoney(kenny, 100000); addItems(kenny, pivotalId, 10000L); addMoney(david, 100000); addItems(david, pivotalId, 10000L); logger.info("All done. Data initialisation is complete."); return true; }
Example #24
Source File: EnvironmentBusEndpoint.java From spring-cloud-bus with Apache License 2.0 | 4 votes |
@WriteOperation public void busEnv(String name, String value) { // TODO: document params Map<String, String> params = Collections.singletonMap(name, value); publish(new EnvironmentChangeRemoteApplicationEvent(this, getInstanceId(), null, params)); }
Example #25
Source File: CustomEndpoint.java From Spring-Boot-2.0-Projects with MIT License | 4 votes |
@WriteOperation public void set(String message) { LOGGER.info("Custom Endpoint Message {}", message); }
Example #26
Source File: RefreshBusEndpoint.java From spring-cloud-bus with Apache License 2.0 | 4 votes |
@WriteOperation public void busRefreshWithDestination(@Selector String destination) { publish(new RefreshRemoteApplicationEvent(this, getInstanceId(), destination)); }
Example #27
Source File: DubboShutdownEndpoint.java From dubbo-spring-boot-project with Apache License 2.0 | 4 votes |
@WriteOperation public Map<String, Object> shutdown() throws Exception { return dubboShutdownMetadata.shutdown(); }
Example #28
Source File: LockEndpoint.java From spring-batch-lightmin with Apache License 2.0 | 4 votes |
@WriteOperation public void releaseLock(@Selector final String id) { this.lightminServerLockManager.releaseLock(id, Boolean.TRUE); }
Example #29
Source File: ChaosMonkeyJmxEndpoint.java From chaos-monkey-spring-boot with Apache License 2.0 | 4 votes |
@WriteOperation public String disableChaosMonkey() { this.chaosMonkeySettings.getChaosMonkeyProperties().setEnabled(false); return "Chaos Monkey is disabled"; }
Example #30
Source File: ChaosMonkeyJmxEndpoint.java From chaos-monkey-spring-boot with Apache License 2.0 | 4 votes |
@WriteOperation public String enableChaosMonkey() { this.chaosMonkeySettings.getChaosMonkeyProperties().setEnabled(true); return "Chaos Monkey is enabled"; }