use of co.cask.common.internal.io.UnsupportedTypeException in project cdap by caskdata.
the class SparkRuntimeService method getShutdownHookRunnable.
@Nullable
private Runnable getShutdownHookRunnable(Object hookEntry) {
try {
// Post Hadoop-2.8, the entry is the ShutdownHookManager.HookEntry class
if (!(hookEntry instanceof Runnable)) {
Field hookField = hookEntry.getClass().getDeclaredField("hook");
hookField.setAccessible(true);
hookEntry = hookField.get(hookEntry);
}
if (hookEntry instanceof Runnable) {
return (Runnable) hookEntry;
}
throw new UnsupportedTypeException("Hook entry is not a Runnable: " + hookEntry.getClass().getName());
} catch (Exception e) {
LOG.warn("Failed to get Spark shutdown hook Runnable from Hadoop ShutdownHookManager hook entry {} due to {}", hookEntry, e.toString());
}
return null;
}
Aggregations