use of com.disney.groovity.util.InterruptFactory in project groovity by disney.
the class Groovity method start.
protected void start() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException {
log.info("Initializing Groovity");
if (httpClient == null) {
httpClient = HttpClients.createDefault();
}
if (argsLookup == null) {
argsLookup = new ArgsLookup();
}
asyncExecutor = Executors.newFixedThreadPool(asyncThreads, new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("Groovity Async " + t.getName());
return t;
}
});
cacheRefreshExecutor = Executors.newScheduledThreadPool(Runtime.getRuntime().availableProcessors() * 4, new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("Groovity Cache " + t.getName());
return t;
}
});
cacheRefreshExecutor.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
GroovityStatistics.warnStuckThreads();
}
}, 1, 1, TimeUnit.MINUTES);
cacheTimeExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("Groovity Cache Time " + t.getName());
return t;
}
});
cacheTimeExecutor.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
Caches.currentCacheTime = (System.currentTimeMillis() / 1000);
}
}, 1, 1, TimeUnit.SECONDS);
interruptFactory = new InterruptFactory();
// intialize configurator first so class inits can pick up system properties
if (configurator != null) {
configurator.init();
}
init(true);
if (configurator != null) {
// initialize configurator again to pick up any changes to system properties that happened during class init
configurator.init();
// schedule 10-second configuration refresh
configExecutor = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
public Thread newThread(Runnable r) {
Thread t = new Thread(r);
t.setName("Groovity Config Applier " + t.getName());
return t;
}
});
configExecutor.scheduleWithFixedDelay(new Runnable() {
public void run() {
try {
configureAll();
} catch (Exception e) {
log.log(Level.SEVERE, "Error updating configuration ", e);
}
}
}, 10, 10, TimeUnit.SECONDS);
configureAll();
}
// now start all scripts
for (Class<?> c : getGroovityScriptClasses()) {
startClass(c);
}
// init locators AFTER compile, to avoid scheduled compilation starting before startup is complete
if (sourceLocators != null && sourceLocators.length > 0) {
for (GroovitySourceLocator locator : sourceLocators) {
locator.addSourceListener(this.groovitySourceListener);
locator.init();
}
}
started.set(true);
}
Aggregations