mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
Close and destroy interpreters in parallel
This commit is contained in:
parent
4558417518
commit
d2b1fa626b
2 changed files with 61 additions and 10 deletions
|
|
@ -18,9 +18,11 @@
|
|||
package org.apache.zeppelin.interpreter;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.zeppelin.display.AngularObjectRegistry;
|
||||
|
||||
/**
|
||||
|
|
@ -71,14 +73,50 @@ public class InterpreterGroup extends LinkedList<Interpreter>{
|
|||
}
|
||||
|
||||
public void close() {
|
||||
for (Interpreter intp : this) {
|
||||
intp.close();
|
||||
List<Thread> closeThreads = new LinkedList<Thread>();
|
||||
|
||||
for (final Interpreter intp : this) {
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
intp.close();
|
||||
}
|
||||
};
|
||||
|
||||
t.start();
|
||||
closeThreads.add(t);
|
||||
}
|
||||
|
||||
for (Thread t : closeThreads) {
|
||||
try {
|
||||
t.join();
|
||||
} catch (InterruptedException e) {
|
||||
Logger logger = Logger.getLogger(InterpreterGroup.class);
|
||||
logger.error("Can't close interpreter", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
for (Interpreter intp : this) {
|
||||
intp.destroy();
|
||||
List<Thread> destroyThreads = new LinkedList<Thread>();
|
||||
|
||||
for (final Interpreter intp : this) {
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
intp.destroy();
|
||||
}
|
||||
};
|
||||
|
||||
t.start();
|
||||
destroyThreads.add(t);
|
||||
}
|
||||
|
||||
for (Thread t : destroyThreads) {
|
||||
try {
|
||||
t.join();
|
||||
} catch (InterruptedException e) {
|
||||
Logger logger = Logger.getLogger(InterpreterGroup.class);
|
||||
logger.error("Can't close interpreter", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -546,13 +546,26 @@ public class InterpreterFactory {
|
|||
|
||||
|
||||
public void close() {
|
||||
List<Thread> closeThreads = new LinkedList<Thread>();
|
||||
synchronized (interpreterSettings) {
|
||||
synchronized (interpreterSettings) {
|
||||
Collection<InterpreterSetting> intpsettings = interpreterSettings.values();
|
||||
for (InterpreterSetting intpsetting : intpsettings) {
|
||||
intpsetting.getInterpreterGroup().close();
|
||||
intpsetting.getInterpreterGroup().destroy();
|
||||
}
|
||||
Collection<InterpreterSetting> intpsettings = interpreterSettings.values();
|
||||
for (final InterpreterSetting intpsetting : intpsettings) {
|
||||
Thread t = new Thread() {
|
||||
public void run() {
|
||||
intpsetting.getInterpreterGroup().close();
|
||||
intpsetting.getInterpreterGroup().destroy();
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
closeThreads.add(t);
|
||||
}
|
||||
}
|
||||
|
||||
for (Thread t : closeThreads) {
|
||||
try {
|
||||
t.join();
|
||||
} catch (InterruptedException e) {
|
||||
logger.error("Can't close interpreterGroup", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue