use of com.thoughtworks.go.server.service.result.OperationResult in project gocd by gocd.
the class GoDiskSpaceMonitor method onTimer.
//Note: This method is called from a Spring timer task
public void onTimer() {
OperationResult result = new DiskSpaceOperationResult(serverHealthService);
try {
boolean outOfDisk = false;
for (DiskSpaceChecker checker : checkers) {
OperationResult callResult = checker.resultFor(result);
checker.check(callResult);
outOfDisk = outOfDisk || !result.canContinue();
}
lowOnDisk = outOfDisk;
} catch (Exception e) {
LOG.error("Error occured during checking filesystems low disk space", e);
}
}
use of com.thoughtworks.go.server.service.result.OperationResult in project gocd by gocd.
the class ScheduleService method lockAndRerunStage.
private Stage lockAndRerunStage(String pipelineName, String counterOrLabel, String stageName, StageInstanceCreator creator, final ErrorConditionHandler errorHandler) {
synchronized (mutexForPipeline(pipelineName)) {
OperationResult result = new ServerHealthStateOperationResult();
if (!schedulingChecker.canSchedule(result)) {
errorHandler.cantSchedule(result.getServerHealthState().getDescription(), pipelineName, stageName);
}
String username = CaseInsensitiveString.str(UserHelper.getUserName().getUsername());
if (!securityService.hasOperatePermissionForStage(pipelineName, stageName, username)) {
errorHandler.noOperatePermission(pipelineName, stageName);
}
Pipeline pipeline = pipelineService.fullPipelineByCounterOrLabel(pipelineName, counterOrLabel);
if (pipeline == null) {
errorHandler.nullPipeline(pipelineName, counterOrLabel, stageName);
}
if (!pipeline.hasStageBeenRun(stageName)) {
if (goConfigService.hasPreviousStage(pipelineName, stageName)) {
CaseInsensitiveString previousStageName = goConfigService.previousStage(pipelineName, stageName).name();
if (!pipeline.hasStageBeenRun(CaseInsensitiveString.str(previousStageName))) {
errorHandler.previousStageNotRun(pipeline.getName(), stageName);
}
}
}
Stage stage = internalRerun(pipeline, stageName, username, creator, errorHandler);
if (stage == null) {
errorHandler.nullStage();
}
return stage;
}
}
use of com.thoughtworks.go.server.service.result.OperationResult in project gocd by gocd.
the class ArtifactsDiskCleanerTest method shouldUseA_NonServerHealthAware_result.
@Test
public void shouldUseA_NonServerHealthAware_result() {
serverHealthService = mock(ServerHealthService.class);
OperationResult operationResult = artifactsDiskCleaner.resultFor(new DiskSpaceOperationResult(serverHealthService));
assertThat(operationResult, is(instanceOf(ServerHealthStateOperationResult.class)));
}
use of com.thoughtworks.go.server.service.result.OperationResult in project gocd by gocd.
the class SchedulingCheckerService method canAutoTriggerConsumer.
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, activityService)));
checker.check(result);
return result.getServerHealthState().isSuccess();
}
use of com.thoughtworks.go.server.service.result.OperationResult in project gocd by gocd.
the class PipelineScheduler method autoProduceBuildCauseAndSave.
private void autoProduceBuildCauseAndSave() {
try {
OperationResult result = new ServerHealthServiceUpdatingOperationResult(serverHealthService);
if (!schedulingChecker.canSchedule(result)) {
return;
}
removeLicenseInvalidFromLog();
checkPipelines();
} catch (Exception e) {
LOGGER.error("Error autoScheduling pipelines", e);
}
}
Aggregations