private void setServerHealthError(String message, String description) { serverHealthService.update( ServerHealthState.error(message, description, HealthStateType.general(HealthStateScope.forBackupCron())) ); }
private void clearServerHealthError() { serverHealthService.update( ServerHealthState.success(HealthStateType.general(HealthStateScope.forBackupCron())) ); }
@Override public void onConfigChange(CruiseConfig newCruiseConfig) { for (ServerHealthState state : serverHealthService.logs()) { HealthStateScope currentScope = state.getType().getScope(); if (currentScope.isForJob()) { serverHealthService.removeByScope(currentScope); } } }
@Test public void shouldRemoveLogByCategoryFromServerHealth() throws Exception { HealthStateScope scope = forPipeline(PIPELINE_NAME); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.general(scope))); serverHealthService.update(ServerHealthState.error("message", "description", HealthStateType.invalidLicense(scope))); serverHealthService.update(ServerHealthState.error("message", "description", globalId)); assertThat(serverHealthService.logs().size(), is(3)); serverHealthService.removeByScope(scope); assertThat(serverHealthService.logs().size(), is(1)); assertThat(serverHealthService, ServerHealthMatcher.containsState(globalId)); }
private ServerHealthState showError(String pipelineName, String message, String desc) { if (desc == null) { desc = "Details not available, please check server logs."; } ServerHealthState serverHealthState = ServerHealthState.error(message, desc, HealthStateType.general(HealthStateScope.forPipeline(pipelineName))); serverHealthService.update(serverHealthState); return serverHealthState; }
@Override public void afterCommit() { final ServerHealthState error = ServerHealthState.error(message, description, HealthStateType.general(HealthStateScope.forJob(jobInstance.getPipelineName(), jobInstance.getStageName(), jobInstance.getName()))); error.setTimeout(Timeout.FIVE_MINUTES); serverHealthService.update(error); appendToConsoleLog(jobInstance, message); appendToConsoleLog(jobInstance, description); } });
public boolean containsError(HealthStateType type, HealthStateLevel level) { ServerHealthStates allLogs = logs(); for (ServerHealthState log : allLogs) { if (log.getType().equals(type) && log.getLogLevel() == level) { return true; } } return false; }
private void handlePluginNotifyError(String pluginId, HealthStateScope scope, String errorDescription, Exception e) { String message = "Notification update failed for plugin: " + pluginId; serverHealthService.update(ServerHealthState.error(message, errorDescription, HealthStateType.general(scope))); LOGGER.warn(message, e); }
private void removeLicenseInvalidFromLog() { serverHealthService.update(ServerHealthState.success( HealthStateType.invalidLicense(HealthStateScope.GLOBAL))); }
private synchronized void saveValidConfigToCache(GoConfigHolder configHolder) { if (configHolder != null) { LOGGER.debug("[Config Save] Saving config to the cache"); this.lastException = null; this.configHolder = configHolder; this.currentConfig = this.configHolder.config; this.currentConfigForEdit = this.configHolder.configForEdit; this.mergedCurrentConfigForEdit = configHolder.mergedConfigForEdit; serverHealthService.update(ServerHealthState.success(HealthStateType.invalidConfig())); } }
private synchronized void saveConfigError(Exception e) { this.lastException = e; ServerHealthState state = ServerHealthState.error(INVALID_CRUISE_CONFIG_XML, GoConfigValidity.invalid(e).errorMessage(), HealthStateType.invalidConfig()); serverHealthService.update(state); }
private void removeMessagesForElementsNoLongerInConfig(CruiseConfig cruiseConfig) { for (HealthStateType type : entryKeys()) { if (type.isRemovedFromConfig(cruiseConfig)) { this.removeByScope(type); } } }
private void removeByScope(HealthStateType type) { removeByScope(type.getScope()); }
public void onConfigChange(CruiseConfig newCruiseConfig) { if (registering) { registering = false; return; } serverHealthService.removeByScope(HealthStateScope.forInvalidConfig()); }
public static HealthStateType forbiddenForGroup(String groupName) { return new HealthStateType("FORBIDDEN", 403, HealthStateScope.forGroup(groupName), null); }