Search in sources :

Example 1 with OperationResult

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);
    }
}
Also used : DiskSpaceOperationResult(com.thoughtworks.go.server.service.result.DiskSpaceOperationResult) OperationResult(com.thoughtworks.go.server.service.result.OperationResult) DiskSpaceOperationResult(com.thoughtworks.go.server.service.result.DiskSpaceOperationResult) DiskSpaceChecker(com.thoughtworks.go.server.service.DiskSpaceChecker) SystemDiskSpaceChecker(com.thoughtworks.go.server.service.SystemDiskSpaceChecker)

Example 2 with OperationResult

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;
    }
}
Also used : DefaultLocalizedOperationResult(com.thoughtworks.go.server.service.result.DefaultLocalizedOperationResult) OperationResult(com.thoughtworks.go.server.service.result.OperationResult) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) LocalizedOperationResult(com.thoughtworks.go.server.service.result.LocalizedOperationResult) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)

Example 3 with OperationResult

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)));
}
Also used : DiskSpaceOperationResult(com.thoughtworks.go.server.service.result.DiskSpaceOperationResult) ServerHealthService(com.thoughtworks.go.serverhealth.ServerHealthService) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) OperationResult(com.thoughtworks.go.server.service.result.OperationResult) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) DiskSpaceOperationResult(com.thoughtworks.go.server.service.result.DiskSpaceOperationResult) Test(org.junit.Test)

Example 4 with OperationResult

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();
}
Also used : OperationResult(com.thoughtworks.go.server.service.result.OperationResult) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 5 with OperationResult

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);
    }
}
Also used : ServerHealthServiceUpdatingOperationResult(com.thoughtworks.go.server.service.result.ServerHealthServiceUpdatingOperationResult) OperationResult(com.thoughtworks.go.server.service.result.OperationResult) ServerHealthServiceUpdatingOperationResult(com.thoughtworks.go.server.service.result.ServerHealthServiceUpdatingOperationResult)

Aggregations

OperationResult (com.thoughtworks.go.server.service.result.OperationResult)10 Test (org.junit.Test)6 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)5 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)4 HashMap (java.util.HashMap)3 DiskSpaceOperationResult (com.thoughtworks.go.server.service.result.DiskSpaceOperationResult)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 Username (com.thoughtworks.go.server.domain.Username)1 ScheduleOptions (com.thoughtworks.go.server.scheduling.ScheduleOptions)1 DiskSpaceChecker (com.thoughtworks.go.server.service.DiskSpaceChecker)1 SystemDiskSpaceChecker (com.thoughtworks.go.server.service.SystemDiskSpaceChecker)1 DefaultLocalizedOperationResult (com.thoughtworks.go.server.service.result.DefaultLocalizedOperationResult)1 LocalizedOperationResult (com.thoughtworks.go.server.service.result.LocalizedOperationResult)1 ServerHealthServiceUpdatingOperationResult (com.thoughtworks.go.server.service.result.ServerHealthServiceUpdatingOperationResult)1 TestTransactionSynchronizationManager (com.thoughtworks.go.server.transaction.TestTransactionSynchronizationManager)1 TestTransactionTemplate (com.thoughtworks.go.server.transaction.TestTransactionTemplate)1 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)1 Semaphore (java.util.concurrent.Semaphore)1 NoMoreInteractions (org.mockito.internal.verification.NoMoreInteractions)1