Skip to content

Commit

Permalink
fix(jenkins): Changed Int to Long to accomodate cloudbees HA changes
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelepperson committed Jan 28, 2025
1 parent 4cb094c commit 65b5da1
Show file tree
Hide file tree
Showing 26 changed files with 121 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ public List<String> getTypeaheadResults(String search) {
return results;
}

public int getLastBuild(String master, String job, boolean running) {
public long getLastBuild(String master, String job, boolean running) {
String key = makeKey(master, job, running);
return redisClientDelegate.withCommandsClient(
c -> {
if (!c.exists(key)) {
return -1;
return -1l;
}
return Integer.parseInt(c.get(key));
return Long.parseLong(c.get(key));
});
}

Expand All @@ -101,7 +101,7 @@ public void setTTL(String key, int ttlSeconds) {
});
}

public void setLastBuild(String master, String job, int lastBuild, boolean building, int ttl) {
public void setLastBuild(String master, String job, long lastBuild, boolean building, int ttl) {
if (!building) {
setBuild(makeKey(master, job), lastBuild, false, master, job, ttl);
}
Expand Down Expand Up @@ -138,7 +138,7 @@ public Map<String, Object> getDeprecatedLastBuild(String master, String job) {
}

Map<String, Object> converted = new HashMap<>();
converted.put("lastBuildLabel", Integer.parseInt(result.get("lastBuildLabel")));
converted.put("lastBuildLabel", Long.parseLong(result.get("lastBuildLabel")));
converted.put("lastBuildBuilding", Boolean.valueOf(result.get("lastBuildBuilding")));

return converted;
Expand All @@ -157,7 +157,7 @@ public List<Map<String, String>> getTrackedBuilds(String master) {
return builds;
}

public void setTracking(String master, String job, int buildId, int ttlSeconds) {
public void setTracking(String master, String job, long buildId, int ttlSeconds) {
String key = makeTrackKey(master, job, buildId);
redisClientDelegate.withCommandsClient(
c -> {
Expand All @@ -166,7 +166,7 @@ public void setTracking(String master, String job, int buildId, int ttlSeconds)
setTTL(key, ttlSeconds);
}

public void deleteTracking(String master, String job, int buildId) {
public void deleteTracking(String master, String job, long buildId) {
String key = makeTrackKey(master, job, buildId);
redisClientDelegate.withCommandsClient(
c -> {
Expand All @@ -182,19 +182,19 @@ private static Map<String, String> getTrackedBuild(String key) {
}

private void setBuild(
String key, int lastBuild, boolean building, String master, String job, int ttl) {
String key, long lastBuild, boolean building, String master, String job, int ttl) {
redisClientDelegate.withCommandsClient(
c -> {
c.hset(key, "lastBuildLabel", Integer.toString(lastBuild));
c.hset(key, "lastBuildLabel", Long.toString(lastBuild));
c.hset(key, "lastBuildBuilding", Boolean.toString(building));
});
setTTL(key, ttl);
}

private void storeLastBuild(String key, int lastBuild, int ttl) {
private void storeLastBuild(String key, long lastBuild, int ttl) {
redisClientDelegate.withCommandsClient(
c -> {
c.set(key, Integer.toString(lastBuild));
c.set(key, Long.toString(lastBuild));
});
setTTL(key, ttl);
}
Expand All @@ -208,7 +208,7 @@ protected String makeKey(String master, String job, boolean running) {
return baseKey() + ":" + buildState + ":" + master + ":" + job.toUpperCase() + ":" + job;
}

protected String makeTrackKey(String master, String job, int buildId) {
protected String makeTrackKey(String master, String job, long buildId) {
return baseKey() + ":track:" + master + ":" + job.toUpperCase() + ":" + job + ":" + buildId;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class GenericBuild {
private boolean building;
private String fullDisplayName;
private String name;
private int number;
private long number;
private Integer duration;
/** String representation of time in nanoseconds since Unix epoch */
private String timestamp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface BuildOperations extends BuildService {
* @param buildNumber The build number
* @return A Spinnaker representation of a build
*/
GenericBuild getGenericBuild(String job, int buildNumber);
GenericBuild getGenericBuild(String job, long buildNumber);

/**
* Trigger a build of a given job on the build service host
Expand All @@ -54,7 +54,7 @@ public interface BuildOperations extends BuildService {
* @param queryParameters A key-value map of parameters to be injected into the build
* @return An id identifying the build; preferably the build number of the build
*/
int triggerBuildWithParameters(String job, Map<String, String> queryParameters);
long triggerBuildWithParameters(String job, Map<String, String> queryParameters);

/**
* Returns all/relevant builds for the given job.
Expand All @@ -71,13 +71,13 @@ public interface BuildOperations extends BuildService {
* @param buildNumber The build number
* @param updatedBuild The updated details for the build
*/
default void updateBuild(String jobName, Integer buildNumber, UpdatedBuild updatedBuild) {
default void updateBuild(String jobName, Long buildNumber, UpdatedBuild updatedBuild) {
// not supported by default
}

JobConfiguration getJobConfig(String jobName);

default Object queuedBuild(String master, int item) {
default Object queuedBuild(String master, long item) {
throw new UnsupportedOperationException(
String.format("Queued builds are not supported for build service %s", master));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) {
delta.getItems().forEach(item -> processBuild(sendEvents, master, travisService, item));

// Find id of processed builds
Set<Integer> processedBuilds =
Set<Long> processedBuilds =
delta.getItems().stream()
.map(BuildDelta::getBuild)
.map(V3Build::getId)
Expand All @@ -140,7 +140,7 @@ protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) {
// Check for tracked builds that have fallen out of the tracking window (can happen for long
// running Travis jobs)
buildCache.getTrackedBuilds(master).stream()
.mapToInt(build -> Integer.parseInt(build.get("buildId")))
.mapToLong(build -> Long.parseLong(build.get("buildId")))
.filter(id -> !processedBuilds.contains(id))
.mapToObj(travisService::getV3Build)
.filter(
Expand Down Expand Up @@ -178,7 +178,7 @@ protected void commitDelta(BuildPollingDelta delta, boolean sendEvents) {

private Stream<? extends BuildDelta> createBuildDelta(
String master, TravisService travisService, V3Build v3Build) {
int lastBuild =
long lastBuild =
buildCache.getLastBuild(master, v3Build.branchedRepoSlug(), v3Build.getState().isRunning());
return Stream.of(v3Build)
.filter(build -> !build.spinnakerTriggered())
Expand Down Expand Up @@ -311,7 +311,7 @@ public static class BuildDelta implements DeltaItem {
private final V3Build build;
private final GenericBuild genericBuild;
private final String travisBaseUrl;
private final int currentBuildNum;
private final int previousBuildNum;
private final long currentBuildNum;
private final long previousBuildNum;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public TravisCache(
this.igorConfigurationProperties = igorConfigurationProperties;
}

public Map<String, Integer> getQueuedJob(String master, int queueNumber) {
public Map<String, Long> getQueuedJob(String master, long queueNumber) {
Map<String, String> result =
redisClientDelegate.withCommandsClient(
c -> {
Expand All @@ -59,48 +59,48 @@ public Map<String, Integer> getQueuedJob(String master, int queueNumber) {
return Collections.emptyMap();
}

Map<String, Integer> converted = new HashMap<>();
converted.put("requestId", Integer.parseInt(result.get("requestId")));
converted.put("repositoryId", Integer.parseInt(result.get("repositoryId")));
Map<String, Long> converted = new HashMap<>();
converted.put("requestId", Long.parseLong(result.get("requestId")));
converted.put("repositoryId", Long.parseLong(result.get("repositoryId")));

return converted;
}

public int setQueuedJob(String master, int repositoryId, int requestId) {
public long setQueuedJob(String master, long repositoryId, long requestId) {
String key = makeKey(QUEUE_TYPE, master, requestId);
redisClientDelegate.withCommandsClient(
c -> {
c.hset(key, "requestId", Integer.toString(requestId));
c.hset(key, "repositoryId", Integer.toString(repositoryId));
c.hset(key, "requestId", Long.toString(requestId));
c.hset(key, "repositoryId", Long.toString(repositoryId));
c.expire(key, QUEUE_EXPIRE_SECONDS);
});
return requestId;
}

public void removeQuededJob(String master, int queueId) {
public void removeQuededJob(String master, long queueId) {
redisClientDelegate.withCommandsClient(
c -> {
c.del(makeKey(QUEUE_TYPE, master, queueId));
});
}

public void setJobLog(String master, int jobId, String log) {
public void setJobLog(String master, long jobId, String log) {
String key = makeKey(LOG_TYPE, master, jobId);
redisClientDelegate.withCommandsClient(
c -> {
c.setex(key, LOG_EXPIRE_SECONDS, log);
});
}

public String getJobLog(String master, int jobId) {
public String getJobLog(String master, long jobId) {
String key = makeKey(LOG_TYPE, master, jobId);
return redisClientDelegate.withCommandsClient(
c -> {
return c.get(key);
});
}

private String makeKey(String type, String master, int id) {
private String makeKey(String type, String master, long id) {
return baseKey() + ":" + type + ":" + master + ":" + id;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public interface TravisClient {
public abstract Builds builds(
@Header("Authorization") String accessToken,
@Query("slug") String repoSlug,
@Query("number") int buildNumber);
@Query("number") long buildNumber);

@POST("/repo/{repoSlug}/requests")
@Headers("Travis-API-Version: 3")
Expand All @@ -79,14 +79,14 @@ public abstract V3Log jobLog(
@Headers("Travis-API-Version: 3")
public abstract V3Build v3build(
@Header("Authorization") String accessToken,
@Path("build_id") int buildId,
@Path("build_id") long buildId,
@Query("include") String include);

@GET("/repo/{repository_id}/builds")
@Headers("Travis-API-Version: 3")
public abstract V3Builds builds(
@Header("Authorization") String accessToken,
@Path("repository_id") int repositoryId,
@Path("repository_id") long repositoryId,
@Query("limit") int limit,
@Query("include") String include);

Expand Down Expand Up @@ -130,8 +130,8 @@ public abstract V3Builds v3buildsByEventType(
@Headers("Travis-API-Version: 3")
public abstract Request request(
@Header("Authorization") String accessToken,
@Path("repository_id") int repositoryId,
@Path("request_id") int requestId);
@Path("repository_id") long repositoryId,
@Path("request_id") long requestId);

@GET("/jobs")
@Headers("Travis-API-Version: 3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ public class Request {

private List<V3Build> builds;

private int id;
private long id;
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class V3Build {
private V3Branch branch;

@JsonProperty("commit_id")
private int commitId;
private long commitId;

private V3Commit commit;

Expand All @@ -50,14 +50,14 @@ public class V3Build {
@JsonProperty("event_type")
private String eventType;

@EqualsAndHashCode.Include private int id;
@EqualsAndHashCode.Include private long id;

private V3Repository repository;

@JsonProperty("repository_id")
private int repositoryId;
private long repositoryId;

private int number;
private long number;

@EqualsAndHashCode.Include private TravisBuildState state;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public boolean isReady() {
@JsonIgnoreProperties(ignoreUnknown = true)
public static class V3LogPart {
private String content;
private Integer number;
private Long number;
private boolean isFinal;

public String getContent() {
Expand All @@ -87,11 +87,11 @@ public void setContent(String content) {
this.content = content;
}

public Integer getNumber() {
public Long getNumber() {
return number;
}

public void setNumber(Integer number) {
public void setNumber(Long number) {
this.number = number;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@XmlRootElement(name = "repository")
public class V3Repository {

private int id;
private long id;

private String name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static GenericBuild genericBuild(V3Build build, String baseUrl) {
return genericBuild;
}

public static String url(String repoSlug, String baseUrl, int id) {
public static String url(String repoSlug, String baseUrl, long id) {
return baseUrl + "/" + repoSlug + "/builds/" + id;
}
}
Loading

0 comments on commit 65b5da1

Please sign in to comment.