Search in sources :

Example 26 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class DiskSpaceWarningCheckerTest method shouldUseWarningLimit.

@Test
public void shouldUseWarningLimit() {
    new SystemEnvironment().setProperty(SystemEnvironment.ARTIFACT_WARNING_SIZE_LIMIT, "1M");
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig(".", new SecurityConfig()));
    ArtifactsDiskSpaceWarningChecker fullChecker = new ArtifactsDiskSpaceWarningChecker(new SystemEnvironment(), sender, goConfigService, new SystemDiskSpaceChecker(), serverHealthService);
    assertThat(fullChecker.limitInMb(), is(1L));
}
Also used : SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) ServerConfig(com.thoughtworks.go.config.ServerConfig) SecurityConfig(com.thoughtworks.go.config.SecurityConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 27 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class ArtifactsDiskCleaner method deleteOldArtifacts.

void deleteOldArtifacts() {
    ServerConfig serverConfig = goConfigService.serverConfig();
    Double requiredSpaceInGb = serverConfig.getPurgeUpto();
    if (serverConfig.isArtifactPurgingAllowed()) {
        double requiredSpace = requiredSpaceInGb * GoConstants.GIGA_BYTE;
        LOGGER.info("Clearing old artifacts as the disk space is low. Current space: '{}'. Need to clear till we hit: '{}'.", availableSpace(), requiredSpace);
        List<Stage> stages;
        int numberOfStagesPurged = 0;
        do {
            configDbStateRepository.flushConfigState();
            stages = stageService.oldestStagesWithDeletableArtifacts();
            for (Stage stage : stages) {
                if (availableSpace() > requiredSpace) {
                    break;
                }
                numberOfStagesPurged++;
                artifactService.purgeArtifactsForStage(stage);
            }
        } while ((availableSpace() < requiredSpace) && !stages.isEmpty());
        if (availableSpace() < requiredSpace) {
            LOGGER.warn("Ran out of stages to clear artifacts from but the disk space is still low");
        }
        LOGGER.info("Finished clearing old artifacts. Deleted artifacts for '{}' stages. Current space: '{}'", numberOfStagesPurged, availableSpace());
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) Stage(com.thoughtworks.go.domain.Stage)

Example 28 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class BaseUrlChangeListener method onConfigChange.

public void onConfigChange(CruiseConfig newCruiseConfig) {
    ServerConfig newServerConfig = newCruiseConfig.server();
    ServerSiteUrlConfig newSecureSiteUrl = newServerConfig.getSecureSiteUrl();
    ServerSiteUrlConfig newSiteUrl = newServerConfig.getSiteUrl();
    if (!(secureSiteUrl.equals(newSecureSiteUrl) && siteUrl.equals(newSiteUrl))) {
        goCache.remove(URLS_CACHE_KEY);
        LOGGER.info("[Configuration Changed] Site URL was changed from [{}] to [{}] and Secure Site URL was changed from [{}] to [{}]", siteUrl, newSiteUrl, secureSiteUrl, newSecureSiteUrl);
    }
    setUrls(newSiteUrl, newSecureSiteUrl);
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) ServerSiteUrlConfig(com.thoughtworks.go.domain.ServerSiteUrlConfig)

Example 29 with ServerConfig

use of com.thoughtworks.go.config.ServerConfig in project gocd by gocd.

the class CachedCommandSnippetsTest method setupAFakeCommandRepoLocation.

private void setupAFakeCommandRepoLocation(final String location, final String... otherLocations) {
    CruiseConfig cruiseConfig = mock(BasicCruiseConfig.class);
    ServerConfig serverConfig = mock(ServerConfig.class);
    when(systemEnvironment.get(COMMAND_REPOSITORY_DIRECTORY)).thenReturn("some-directory");
    when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
    when(cruiseConfig.server()).thenReturn(serverConfig);
    when(serverConfig.getCommandRepositoryLocation()).thenReturn(location, otherLocations);
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig)

Aggregations

ServerConfig (com.thoughtworks.go.config.ServerConfig)29 Test (org.junit.Test)16 BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)12 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)11 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)6 Username (com.thoughtworks.go.server.domain.Username)5 AgentConfig (com.thoughtworks.go.config.AgentConfig)4 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)4 File (java.io.File)4 ResponseEntity (org.springframework.http.ResponseEntity)4 UpdateConfigCommand (com.thoughtworks.go.config.UpdateConfigCommand)3 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)3 Before (org.junit.Before)3 HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)2 Stage (com.thoughtworks.go.domain.Stage)1 GoPluginExtension (com.thoughtworks.go.plugin.access.common.settings.GoPluginExtension)1 PluginRequestProcessorRegistry (com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry)1 SendEmailMessage (com.thoughtworks.go.server.messaging.SendEmailMessage)1 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)1