Skip to content

Commit

Permalink
chore(travis): Remove old build cache migrator (#514)
Browse files Browse the repository at this point in the history
This migrator has been in place since October 2017, and is no longer needed. Also it was a bit misleading. The `initialize` name suggests it is run on bean creation, but it actually ran every polling cycle, which seems a bit excess for a migrator. Since it was only used by the Travis integration, I just removed the whole thing.
  • Loading branch information
jervi authored and cfieber committed Sep 27, 2019
1 parent 263baea commit cd75c26
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ class DockerMonitor extends CommonPollingMonitor<ImageDelta, DockerPollingDelta>
this.dockerRegistryProperties = dockerRegistryProperties
}

@Override
void initialize() {
}

@Override
void poll(boolean sendEvents) {
if (keysMigration.isPresent() && keysMigration.get().running) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ public GitlabCiBuildMonitor(
this.echoService = echoService;
}

@Override
protected void initialize() {}

@Override
public void poll(boolean sendEvents) {
buildServices.getServiceNames(BuildServiceProvider.GITLAB_CI).stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,6 @@ class JenkinsBuildMonitor extends CommonPollingMonitor<JobDelta, JobPollingDelta
pollingEnabled && super.isInService()
}

@Override
void initialize() {
}

@Override
void poll(boolean sendEvents) {
buildServices.getServiceNames(BuildServiceProvider.JENKINS).stream().forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ void stop() {
}
}

protected abstract void initialize();
protected void initialize() {}

/**
* Returns a delta of stored state versus newly polled data. A polling monitor must not perform
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ class WerckerBuildMonitor extends CommonPollingMonitor<PipelineDelta, PipelinePo
pollingEnabled && super.isInService()
}

@Override
void initialize() {
}

@Override
void poll(boolean sendEvents) {
long startTime = System.currentTimeMillis()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ public String getName() {
return "artifactoryPublishingMonitor";
}

@Override
protected void initialize() {}

@Override
public void poll(boolean sendEvents) {
for (ArtifactorySearch search : artifactoryProperties.getSearches()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public ConcourseBuildMonitor(
this.echoService = echoService;
}

@Override
protected void initialize() {}

@Override
protected JobPollingDelta generateDelta(PollContext ctx) {
ConcourseProperties.Host host =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -86,11 +85,6 @@ public TravisBuildMonitor(
this.echoService = echoService;
}

@Override
public void initialize() {
migrateToNewBuildCache();
}

@Override
public void poll(boolean sendEvents) {
buildServices
Expand Down Expand Up @@ -280,40 +274,6 @@ private void sendEventForBuild(
}
}

private void migrateToNewBuildCache() {
buildServices
.getServiceNames(BuildServiceProvider.TRAVIS)
.forEach(
master ->
buildCache
.getDeprecatedJobNames(master)
.forEach(
job -> {
Map<String, Object> oldBuild =
buildCache.getDeprecatedLastBuild(master, job);
if (!oldBuild.isEmpty()) {
int oldBuildNumber = (int) oldBuild.get("lastBuildLabel");
boolean oldBuildBuilding = (boolean) oldBuild.get("lastBuildBuilding");
int currentBuild =
buildCache.getLastBuild(master, job, oldBuildBuilding);
if (currentBuild < oldBuildNumber) {
log.info(
"BuildCache migration {}:{}:{}:{}",
kv("master", master),
kv("job", job),
kv("building", oldBuildBuilding),
kv("buildNumber", oldBuildNumber));
buildCache.setLastBuild(
master,
job,
oldBuildNumber,
oldBuildBuilding,
buildCacheJobTTLSeconds());
}
}
}));
}

private int buildCacheJobTTLSeconds() {
return (int) TimeUnit.DAYS.toSeconds(travisProperties.getCachedJobTTLDays());
}
Expand Down

0 comments on commit cd75c26

Please sign in to comment.