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

Introduce ComputerListener#onIdle #9673

Merged
merged 5 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/model/Computer.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
* @author Kohsuke Kawaguchi
*/
@ExportedBean
public /*transient*/ abstract class Computer extends Actionable implements AccessControlled, ExecutorListener, DescriptorByNameOwner, StaplerProxy, HasWidgets {

Check warning on line 167 in core/src/main/java/hudson/model/Computer.java

View check run for this annotation

ci.jenkins.io / Java Compiler

access-modifier-checker:enforce

NORMAL: Note: Generating hudson/model/Computer.javadoc

private final CopyOnWriteArrayList<Executor> executors = new CopyOnWriteArrayList<>();
// TODO:
Expand Down Expand Up @@ -1102,6 +1102,8 @@
if (ciBase != null) { // TODO confirm safe to assume non-null and use getInstance()
ciBase.removeComputer(Computer.this);
}
} else if (isIdle()) {
jglick marked this conversation as resolved.
Show resolved Hide resolved
Listeners.notify(ComputerListener.class, false, l -> l.onIdle(this));
}
}
};
Expand Down Expand Up @@ -1423,7 +1425,7 @@
}

@RequirePOST
public HttpResponse doToggleOffline(@QueryParameter String offlineMessage) throws IOException, ServletException {

Check warning on line 1428 in core/src/main/java/hudson/model/Computer.java

View check run for this annotation

ci.jenkins.io / Java Compiler

access-modifier-checker:enforce

NORMAL: Note: Generating hudson/model/Computer/doToggleOffline.stapler
if (!temporarilyOffline) {
checkPermission(DISCONNECT);
offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
Expand All @@ -1437,7 +1439,7 @@
}

@RequirePOST
public HttpResponse doChangeOfflineCause(@QueryParameter String offlineMessage) throws IOException, ServletException {

Check warning on line 1442 in core/src/main/java/hudson/model/Computer.java

View check run for this annotation

ci.jenkins.io / Java Compiler

access-modifier-checker:enforce

NORMAL: Note: Generating hudson/model/Computer/doChangeOfflineCause.stapler
checkPermission(DISCONNECT);
offlineMessage = Util.fixEmptyAndTrim(offlineMessage);
setTemporarilyOffline(true,
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/java/hudson/slaves/ComputerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ public void onTemporarilyOffline(Computer c, OfflineCause cause) {}
*/
public void onConfigurationChange() {}

/**
* Indicates that the computer has become idle.
*
* @since TODO
*/
public void onIdle(Computer c) {}

/**
* Registers this {@link ComputerListener} so that it will start receiving events.
*
Expand Down
Loading