Skip to content

Add more logs specifically for the scheduler and close #40

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

Merged
merged 4 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public String id() {

@Override
public void close() {
LOGGER.debug("Close called for session {}.", id);
try {
dockerService.killContainerByName(containerName());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class JShellSessionService {
private void initScheduler() {
scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(() -> {
LOGGER.info("Scheduler heartbeat: started.");
jshellSessions.keySet()
.stream()
.filter(id -> jshellSessions.get(id).isClosed())
Expand All @@ -36,6 +37,7 @@ private void initScheduler() {
.stream()
.filter(id -> jshellSessions.get(id).shouldDie())
.toList();
LOGGER.info("Scheduler heartbeat: sessions ready to die: {}", toDie);
for (String id : toDie) {
try {
deleteSession(id);
Expand All @@ -49,8 +51,10 @@ private void initScheduler() {

void notifyDeath(String id) {
JShellService shellService = jshellSessions.remove(id);
if (shellService == null)
if (shellService == null) {
LOGGER.debug("Notify death on already removed session {}.", id);
return;
}
if (!shellService.isClosed()) {
LOGGER.error("JShell Service isn't dead when it should for id {}.", id);
}
Expand Down Expand Up @@ -81,6 +85,7 @@ public JShellService oneTimeSession(@Nullable StartupScriptId startupScriptId)
}

public void deleteSession(String id) throws DockerException {
LOGGER.debug("Soft delete called for session {}.", id);
JShellService service = jshellSessions.remove(id);
service.stop();
scheduler.schedule(service::close, 500, TimeUnit.MILLISECONDS);
Expand Down
Loading