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));
}
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());
}
}
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);
}
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);
}
Aggregations