@WriteOperation public Map<String, Object> shutdown() throws Exception { Map<String, Object> shutdownCountData = new LinkedHashMap<>(); // registries int registriesCount = getRegistries().size(); // protocols int protocolsCount = getProtocolConfigsBeanMap().size(); ProtocolConfig.destroyAll(); shutdownCountData.put("registries", registriesCount); shutdownCountData.put("protocols", protocolsCount); // Service Beans Map<String, ServiceBean> serviceBeansMap = getServiceBeansMap(); if (!serviceBeansMap.isEmpty()) { for (ServiceBean serviceBean : serviceBeansMap.values()) { serviceBean.destroy(); } } shutdownCountData.put("services", serviceBeansMap.size()); // Reference Beans ReferenceAnnotationBeanPostProcessor beanPostProcessor = getReferenceAnnotationBeanPostProcessor(); int referencesCount = beanPostProcessor.getReferenceBeans().size(); beanPostProcessor.destroy(); shutdownCountData.put("references", referencesCount); // Set Result to complete Map<String, Object> shutdownData = new TreeMap<>(); shutdownData.put("shutdown.count", shutdownCountData); return shutdownData; }
@WriteOperation public Object restart() { Thread thread = new Thread(this::safeRestart); thread.setDaemon(false); thread.start(); return Collections.singletonMap("message", "Restarting"); }
@WriteOperation public Map<String, String> shutdown() { if (this.context == null) { return NO_CONTEXT_MESSAGE; } try { return SHUTDOWN_MESSAGE; } finally { Thread thread = new Thread(this::performShutdown); thread.setContextClassLoader(getClass().getClassLoader()); thread.start(); } }
@WriteOperation public Collection<String> refresh() { Set<String> keys = contextRefresher.refresh(); return keys; }
@WriteOperation public Object write(String name, String value) { environment.setProperty(name, value); return Collections.singletonMap(name, value); }
@WriteOperation public void rebuild() { this.graphServer.rebuild(); }
@WriteOperation public void configureLogLevel(@Selector String name, @Nullable LogLevel configuredLevel) { Assert.notNull(name, "Name must not be empty"); this.loggingSystem.setLogLevel(name, configuredLevel); }
@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(); }
@WriteOperation public Boolean resume() { if (!isRunning()) { doResume(); return true; } return false; } }
@WriteOperation public Boolean pause() { if (isRunning()) { doPause(); return true; } return false; } }
@WriteOperation public String gc() { System.gc(); return "Garbage collection initiated"; } }
@WriteOperation public Object restart() { Thread thread = new Thread(this::safeRestart); thread.setDaemon(false); thread.start(); return Collections.singletonMap("message", "Restarting"); }
@WriteOperation public Collection<String> refresh() { Set<String> keys = contextRefresher.refresh(); return keys; }
@WriteOperation public Object write(String name, String value) { environment.setProperty(name, value); return Collections.singletonMap(name, value); }
@WriteOperation public String restart() { TennisStatsApplication.restart(); return "Restart initiated"; } }
@WriteOperation public String clearCache(@Selector String name) { if (Strings.isNullOrEmpty(name)) name = ".*"; int cacheCount = dataService.clearCaches(name); return format("OK (%1$d caches cleared)", cacheCount); } }
@WriteOperation public Object reset() { this.publisher.publishEvent(new RoutesRefreshedEvent(this.routes)); return invoke(); }
@WriteOperation public void createFilteredSnapshotEvents( // this is the event type. Could have a better name, but since Spring Boot relies on the -parameters // compiler flag being set to resolve path parameter names, it would then get trickier to reliably run this // Test in the IDE. So let's stick with arg0 for now. @Selector String arg0, @Nullable String filter) { snapshotCreationService.createSnapshotEvents(arg0, filter); }
@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(); }
@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); }