Skip to content
Closed
Changes from all 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 @@ -519,6 +519,9 @@ public void setPropertyAndRestart(String id, InterpreterOption option,
synchronized (interpreterSettings) {
InterpreterSetting intpsetting = interpreterSettings.get(id);
if (intpsetting != null) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to refactor setPropertyAndRestart() and restart() to remove duplication and prevent diverged issue like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HeartSaVioR Okay, I will attempt to code refactoring.

stopJobAllInterpreter(intpsetting);

intpsetting.getInterpreterGroup().close();
intpsetting.getInterpreterGroup().destroy();

Expand All @@ -541,20 +544,7 @@ public void restart(String id) {
InterpreterSetting intpsetting = interpreterSettings.get(id);
if (intpsetting != null) {

for (Interpreter intp : intpsetting.getInterpreterGroup()) {
for (Job job : intp.getScheduler().getJobsRunning()) {
job.abort();
job.setStatus(Status.ABORT);
logger.info("Job " + job.getJobName() + " aborted ");
}

for (Job job : intp.getScheduler().getJobsWaiting()) {
job.abort();
job.setStatus(Status.ABORT);
logger.info("Job " + job.getJobName() + " aborted ");
}
}

stopJobAllInterpreter(intpsetting);

intpsetting.getInterpreterGroup().close();
intpsetting.getInterpreterGroup().destroy();
Expand All @@ -570,6 +560,22 @@ public void restart(String id) {
}
}

private void stopJobAllInterpreter(InterpreterSetting intpsetting) {
if (intpsetting != null) {
for (Interpreter intp : intpsetting.getInterpreterGroup()) {
for (Job job : intp.getScheduler().getJobsRunning()) {
job.abort();
job.setStatus(Status.ABORT);
logger.info("Job " + job.getJobName() + " aborted ");
}
for (Job job : intp.getScheduler().getJobsWaiting()) {
job.abort();
job.setStatus(Status.ABORT);
logger.info("Job " + job.getJobName() + " aborted ");
}
}
}
}

public void close() {
List<Thread> closeThreads = new LinkedList<Thread>();
Expand Down