public int errorCount() { int errors = 0; for (ServerHealthState serverHealthState : this) { if (!serverHealthState.isSuccess()) { errors++; } } return errors; }
public boolean canContinue() { return lastHealthState == null || lastHealthState.isSuccess(); }
public static JsonAction from(ServerHealthState serverHealthState) { if (serverHealthState.isSuccess()) { return jsonCreated(new LinkedHashMap()); } Map<String, Object> jsonLog = new LinkedHashMap<>(); jsonLog.put(ERROR_FOR_JSON, serverHealthState.getDescription()); return new JsonAction(serverHealthState.getType().getHttpCode(), jsonLog); }
public boolean canManuallyTrigger(PipelineConfig pipelineConfig, String username, OperationResult result) { SchedulingChecker checker = buildScheduleCheckers(asList(manualTriggerCheckers(pipelineConfig, username))); checker.check(result); return result.getServerHealthState().isSuccess(); }
public boolean canRun(PipelineIdentifier pipelineIdentifier, String stageName, String username, boolean hasPreviousStageBeenScheduled) { if (!goConfigService.hasStageConfigNamed(pipelineIdentifier.getName(), stageName)) { return false; } ServerHealthStateOperationResult result = new ServerHealthStateOperationResult(); schedulingChecker.canScheduleStage(pipelineIdentifier, stageName, username, result); return result.getServerHealthState().isSuccess() && hasPreviousStageBeenScheduled; }
public boolean canRerunStage(PipelineIdentifier pipelineIdentifier, String stageName, String username, OperationResult result) { String pipelineName = pipelineIdentifier.getName(); SchedulingChecker canRerunChecker = buildScheduleCheckers(asList( new StageAuthorizationChecker(pipelineName, stageName, username, securityService), new PipelinePauseChecker(pipelineName, pipelinePauseService), new PipelineActiveChecker(stageService, pipelineIdentifier), new StageActiveChecker(pipelineName, stageName, stageService), diskCheckers())); canRerunChecker.check(result); return result.getServerHealthState().isSuccess(); }
public boolean canAutoTriggerConsumer(PipelineConfig pipelineConfig) { OperationResult result = new ServerHealthStateOperationResult(); String pipelineName = CaseInsensitiveString.str(pipelineConfig.name()); String stageName = CaseInsensitiveString.str(pipelineConfig.getFirstStageConfig().name()); SchedulingChecker checker = buildScheduleCheckers(asList(new PipelinePauseChecker(pipelineName, pipelinePauseService), new PipelineLockChecker(pipelineName, pipelineLockService), new StageActiveChecker(pipelineName, stageName, stageService))); checker.check(result); return result.getServerHealthState().isSuccess(); }