Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(igor): Rename master to controller #960

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -43,10 +43,10 @@ public BuildCache(
this.igorConfigurationProperties = igorConfigurationProperties;
}

public List<String> getJobNames(String master) {
public List<String> getJobNames(String controller) {
List<String> jobs = new ArrayList<>();
redisClientDelegate.withKeyScan(
baseKey() + ":completed:" + master + ":*",
baseKey() + ":completed:" + controller + ":*",
1000,
page ->
jobs.addAll(
Expand All @@ -71,8 +71,8 @@ public List<String> getTypeaheadResults(String search) {
return results;
}

public int getLastBuild(String master, String job, boolean running) {
String key = makeKey(master, job, running);
public int getLastBuild(String controller, String job, boolean running) {
String key = makeKey(controller, job, running);
return redisClientDelegate.withCommandsClient(
c -> {
if (!c.exists(key)) {
Expand All @@ -82,8 +82,8 @@ public int getLastBuild(String master, String job, boolean running) {
});
}

public Long getTTL(String master, String job) {
final String key = makeKey(master, job);
public Long getTTL(String controller, String job) {
final String key = makeKey(controller, job);
return getTTL(key);
}

Expand All @@ -101,17 +101,18 @@ public void setTTL(String key, int ttl) {
});
}

public void setLastBuild(String master, String job, int lastBuild, boolean building, int ttl) {
public void setLastBuild(
String controller, String job, int lastBuild, boolean building, int ttl) {
if (!building) {
setBuild(makeKey(master, job), lastBuild, false, master, job, ttl);
setBuild(makeKey(controller, job), lastBuild, false, controller, job, ttl);
}
storeLastBuild(makeKey(master, job, building), lastBuild, ttl);
storeLastBuild(makeKey(controller, job, building), lastBuild, ttl);
}

public List<String> getDeprecatedJobNames(String master) {
public List<String> getDeprecatedJobNames(String controller) {
List<String> jobs = new ArrayList<>();
redisClientDelegate.withKeyScan(
baseKey() + ":" + master + ":*",
baseKey() + ":" + controller + ":*",
1000,
page ->
jobs.addAll(
Expand All @@ -122,8 +123,8 @@ public List<String> getDeprecatedJobNames(String master) {
return jobs;
}

public Map<String, Object> getDeprecatedLastBuild(String master, String job) {
String key = makeKey(master, job);
public Map<String, Object> getDeprecatedLastBuild(String controller, String job) {
String key = makeKey(controller, job);
Map<String, String> result =
redisClientDelegate.withCommandsClient(
c -> {
Expand All @@ -144,10 +145,10 @@ public Map<String, Object> getDeprecatedLastBuild(String master, String job) {
return converted;
}

public List<Map<String, String>> getTrackedBuilds(String master) {
public List<Map<String, String>> getTrackedBuilds(String controller) {
List<Map<String, String>> builds = new ArrayList<>();
redisClientDelegate.withKeyScan(
baseKey() + ":track:" + master + ":*",
baseKey() + ":track:" + controller + ":*",
1000,
page ->
builds.addAll(
Expand All @@ -157,17 +158,17 @@ public List<Map<String, String>> getTrackedBuilds(String master) {
return builds;
}

public void setTracking(String master, String job, int buildId, int ttl) {
String key = makeTrackKey(master, job, buildId);
public void setTracking(String controller, String job, int buildId, int ttl) {
String key = makeTrackKey(controller, job, buildId);
redisClientDelegate.withCommandsClient(
c -> {
c.set(key, "marked as running");
});
setTTL(key, ttl);
}

public void deleteTracking(String master, String job, int buildId) {
String key = makeTrackKey(master, job, buildId);
public void deleteTracking(String controller, String job, int buildId) {
String key = makeTrackKey(controller, job, buildId);
redisClientDelegate.withCommandsClient(
c -> {
c.del(key);
Expand All @@ -182,7 +183,7 @@ 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, int lastBuild, boolean building, String controller, String job, int ttl) {
redisClientDelegate.withCommandsClient(
c -> {
c.hset(key, "lastBuildLabel", Integer.toString(lastBuild));
Expand All @@ -199,17 +200,17 @@ private void storeLastBuild(String key, int lastBuild, int ttl) {
setTTL(key, ttl);
}

protected String makeKey(String master, String job) {
return baseKey() + ":" + master + ":" + job.toUpperCase() + ":" + job;
protected String makeKey(String controller, String job) {
return baseKey() + ":" + controller + ":" + job.toUpperCase() + ":" + job;
}

protected String makeKey(String master, String job, boolean running) {
protected String makeKey(String controller, String job, boolean running) {
String buildState = running ? "running" : "completed";
return baseKey() + ":" + buildState + ":" + master + ":" + job.toUpperCase() + ":" + job;
return baseKey() + ":" + buildState + ":" + controller + ":" + job.toUpperCase() + ":" + job;
}

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

private static String extractJobName(String key) {
Expand Down
Expand Up @@ -26,7 +26,7 @@
*
* <pre>{@code
* someProvider:
* masters:
* controllers:
* - name: someProvider-host1
* address: https://foo.com/api
* permissions:
Expand All @@ -46,10 +46,19 @@ public interface BuildServerProperties<T extends BuildServerProperties.Host> {
/**
* Returns a list of the build service hosts configured with this provider
*
* @deprecated
* @return The build service hosts
*/
@Deprecated(forRemoval = true)
List<T> getMasters();

/**
* Returns a list of the build service hosts configured with this provider
*
* @return The build service hosts
*/
List<T> getControllers();

/** Interface for representing the properties of a specific build service host */
interface Host {
/**
Expand All @@ -75,7 +84,7 @@ interface Host {
*
* <pre>{@code
* someProvider:
* masters:
* controllers:
* - name: someProvider-host1
* address: https://foo.com/api
* permissions:
Expand Down
Expand Up @@ -22,6 +22,20 @@
@Data
public class GenericBuildContent {
private GenericProject project;

@Deprecated(forRemoval = true)
private String master;

@Deprecated(forRemoval = true)
public String getMaster() {
return controller;
}

@Deprecated(forRemoval = true)
public void setMaster(String controller) {
this.controller = controller;
}

private String controller;
private String type;
}
Expand Up @@ -77,8 +77,8 @@ default void updateBuild(String jobName, Integer buildNumber, UpdatedBuild updat

JobConfiguration getJobConfig(String jobName);

default Object queuedBuild(String master, int item) {
default Object queuedBuild(String controller, int item) {
throw new UnsupportedOperationException(
String.format("Queued builds are not supported for build service %s", master));
String.format("Queued builds are not supported for build service %s", controller));
}
}