Skip to content

Commit

Permalink
Implement ComputerListener#onIdle
Browse files Browse the repository at this point in the history
Introduces a new computer listener fired whenever a Computer becomes idle.
  • Loading branch information
Vlatombe committed Aug 28, 2024
1 parent ffdd5be commit 64667af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
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 @@ -1102,6 +1102,8 @@ protected void removeExecutor(final Executor e) {
if (ciBase != null) { // TODO confirm safe to assume non-null and use getInstance()
ciBase.removeComputer(Computer.this);
}
} else if (isIdle()) {
Listeners.notify(ComputerListener.class, false, l -> l.onIdle(this));
}
}
};
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

0 comments on commit 64667af

Please sign in to comment.