本文整理汇总了Java中org.apache.hadoop.hbase.util.ShutdownHookManager.deleteShutdownHook方法的典型用法代码示例。如果您正苦于以下问题:Java ShutdownHookManager.deleteShutdownHook方法的具体用法?Java ShutdownHookManager.deleteShutdownHook怎么用?Java ShutdownHookManager.deleteShutdownHook使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.hadoop.hbase.util.ShutdownHookManager
的用法示例。
在下文中一共展示了ShutdownHookManager.deleteShutdownHook方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: suppressHdfsShutdownHook
import org.apache.hadoop.hbase.util.ShutdownHookManager; //导入方法依赖的package包/类
private static Runnable suppressHdfsShutdownHook(final FileSystem fs) {
try {
// This introspection has been updated to work for hadoop 0.20, 0.21 and for
// cloudera 0.20. 0.21 and cloudera 0.20 both have hadoop-4829. With the
// latter in place, things are a little messy in that there are now two
// instances of the data member clientFinalizer; an uninstalled one in
// FileSystem and one in the innner class named Cache that actually gets
// registered as a shutdown hook. If the latter is present, then we are
// on 0.21 or cloudera patched 0.20.
Runnable hdfsClientFinalizer = null;
// Look into the FileSystem#Cache class for clientFinalizer
Class<?> [] classes = FileSystem.class.getDeclaredClasses();
Class<?> cache = null;
for (Class<?> c: classes) {
if (c.getSimpleName().equals("Cache")) {
cache = c;
break;
}
}
if (cache == null) {
throw new RuntimeException(
"This should not happen. Could not find the cache class in FileSystem.");
}
Field field = null;
try {
field = cache.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);
} catch (NoSuchFieldException e) {
// We can get here if the Cache class does not have a clientFinalizer
// instance: i.e. we're running on straight 0.20 w/o hadoop-4829.
}
if (field != null) {
field.setAccessible(true);
Field cacheField = FileSystem.class.getDeclaredField("CACHE");
cacheField.setAccessible(true);
Object cacheInstance = cacheField.get(fs);
hdfsClientFinalizer = (Runnable)field.get(cacheInstance);
} else {
// Then we didnt' find clientFinalizer in Cache. Presume clean 0.20 hadoop.
field = FileSystem.class.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);
field.setAccessible(true);
hdfsClientFinalizer = (Runnable)field.get(null);
}
if (hdfsClientFinalizer == null) {
throw new RuntimeException("Client finalizer is null, can't suppress!");
}
synchronized (fsShutdownHooks) {
if (!fsShutdownHooks.containsKey(hdfsClientFinalizer) &&
!ShutdownHookManager.deleteShutdownHook(hdfsClientFinalizer)) {
throw new RuntimeException("Failed suppression of fs shutdown hook: " +
hdfsClientFinalizer);
}
Integer refs = fsShutdownHooks.get(hdfsClientFinalizer);
fsShutdownHooks.put(hdfsClientFinalizer, refs == null ? 1 : refs + 1);
}
return hdfsClientFinalizer;
} catch (NoSuchFieldException nsfe) {
LOG.fatal("Couldn't find field 'clientFinalizer' in FileSystem!", nsfe);
throw new RuntimeException("Failed to suppress HDFS shutdown hook");
} catch (IllegalAccessException iae) {
LOG.fatal("Couldn't access field 'clientFinalizer' in FileSystem!", iae);
throw new RuntimeException("Failed to suppress HDFS shutdown hook");
}
}
示例2: suppressHdfsShutdownHook
import org.apache.hadoop.hbase.util.ShutdownHookManager; //导入方法依赖的package包/类
private static Runnable suppressHdfsShutdownHook(final FileSystem fs) {
try {
// This introspection has been updated to work for hadoop 0.20, 0.21 and for
// cloudera 0.20. 0.21 and cloudera 0.20 both have hadoop-4829. With the
// latter in place, things are a little messy in that there are now two
// instances of the data member clientFinalizer; an uninstalled one in
// FileSystem and one in the innner class named Cache that actually gets
// registered as a shutdown hook. If the latter is present, then we are
// on 0.21 or cloudera patched 0.20.
Runnable hdfsClientFinalizer = null;
// Look into the FileSystem#Cache class for clientFinalizer
Class<?> [] classes = FileSystem.class.getDeclaredClasses();
Class<?> cache = null;
for (Class<?> c: classes) {
if (c.getSimpleName().equals("Cache")) {
cache = c;
break;
}
}
Field field = null;
try {
field = cache.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);
} catch (NoSuchFieldException e) {
// We can get here if the Cache class does not have a clientFinalizer
// instance: i.e. we're running on straight 0.20 w/o hadoop-4829.
}
if (field != null) {
field.setAccessible(true);
Field cacheField = FileSystem.class.getDeclaredField("CACHE");
cacheField.setAccessible(true);
Object cacheInstance = cacheField.get(fs);
hdfsClientFinalizer = (Runnable)field.get(cacheInstance);
} else {
// Then we didnt' find clientFinalizer in Cache. Presume clean 0.20 hadoop.
field = FileSystem.class.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);
field.setAccessible(true);
hdfsClientFinalizer = (Runnable)field.get(null);
}
if (hdfsClientFinalizer == null) {
throw new RuntimeException("Client finalizer is null, can't suppress!");
}
if (!fsShutdownHooks.containsKey(hdfsClientFinalizer) &&
!ShutdownHookManager.deleteShutdownHook(hdfsClientFinalizer)) {
throw new RuntimeException("Failed suppression of fs shutdown hook: " +
hdfsClientFinalizer);
}
synchronized (fsShutdownHooks) {
Integer refs = fsShutdownHooks.get(hdfsClientFinalizer);
fsShutdownHooks.put(hdfsClientFinalizer, refs == null ? 1 : refs + 1);
}
return hdfsClientFinalizer;
} catch (NoSuchFieldException nsfe) {
LOG.fatal("Couldn't find field 'clientFinalizer' in FileSystem!", nsfe);
throw new RuntimeException("Failed to suppress HDFS shutdown hook");
} catch (IllegalAccessException iae) {
LOG.fatal("Couldn't access field 'clientFinalizer' in FileSystem!", iae);
throw new RuntimeException("Failed to suppress HDFS shutdown hook");
}
}
示例3: suppressHdfsShutdownHook
import org.apache.hadoop.hbase.util.ShutdownHookManager; //导入方法依赖的package包/类
private static Runnable suppressHdfsShutdownHook(final FileSystem fs) {
try {
// This introspection has been updated to work for hadoop 0.20, 0.21 and for
// cloudera 0.20. 0.21 and cloudera 0.20 both have hadoop-4829. With the
// latter in place, things are a little messy in that there are now two
// instances of the data member clientFinalizer; an uninstalled one in
// FileSystem and one in the innner class named Cache that actually gets
// registered as a shutdown hook. If the latter is present, then we are
// on 0.21 or cloudera patched 0.20.
Runnable hdfsClientFinalizer = null;
// Look into the FileSystem#Cache class for clientFinalizer
Class<?> [] classes = FileSystem.class.getDeclaredClasses();
Class<?> cache = null;
for (Class<?> c: classes) {
if (c.getSimpleName().equals("Cache")) {
cache = c;
break;
}
}
if (cache == null) {
throw new RuntimeException(
"This should not happen. Could not find the cache class in FileSystem.");
}
Field field = null;
try {
field = cache.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);
} catch (NoSuchFieldException e) {
// We can get here if the Cache class does not have a clientFinalizer
// instance: i.e. we're running on straight 0.20 w/o hadoop-4829.
}
if (field != null) {
field.setAccessible(true);
Field cacheField = FileSystem.class.getDeclaredField("CACHE");
cacheField.setAccessible(true);
Object cacheInstance = cacheField.get(fs);
hdfsClientFinalizer = (Runnable)field.get(cacheInstance);
} else {
// Then we didnt' find clientFinalizer in Cache. Presume clean 0.20 hadoop.
field = FileSystem.class.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);
field.setAccessible(true);
hdfsClientFinalizer = (Runnable)field.get(null);
}
if (hdfsClientFinalizer == null) {
throw new RuntimeException("Client finalizer is null, can't suppress!");
}
synchronized (fsShutdownHooks) {
boolean isFSCacheDisabled = fs.getConf().getBoolean("fs.hdfs.impl.disable.cache", false);
if (!isFSCacheDisabled && !fsShutdownHooks.containsKey(hdfsClientFinalizer)
&& !ShutdownHookManager.deleteShutdownHook(hdfsClientFinalizer)) {
throw new RuntimeException(
"Failed suppression of fs shutdown hook: " + hdfsClientFinalizer);
}
Integer refs = fsShutdownHooks.get(hdfsClientFinalizer);
fsShutdownHooks.put(hdfsClientFinalizer, refs == null ? 1 : refs + 1);
}
return hdfsClientFinalizer;
} catch (NoSuchFieldException nsfe) {
LOG.error(HBaseMarkers.FATAL, "Couldn't find field 'clientFinalizer' in FileSystem!",
nsfe);
throw new RuntimeException("Failed to suppress HDFS shutdown hook");
} catch (IllegalAccessException iae) {
LOG.error(HBaseMarkers.FATAL, "Couldn't access field 'clientFinalizer' in FileSystem!",
iae);
throw new RuntimeException("Failed to suppress HDFS shutdown hook");
}
}
示例4: suppressHdfsShutdownHook
import org.apache.hadoop.hbase.util.ShutdownHookManager; //导入方法依赖的package包/类
private static Runnable suppressHdfsShutdownHook(final FileSystem fs) {
try {
// This introspection has been updated to work for hadoop 0.20, 0.21 and for
// cloudera 0.20. 0.21 and cloudera 0.20 both have hadoop-4829. With the
// latter in place, things are a little messy in that there are now two
// instances of the data member clientFinalizer; an uninstalled one in
// FileSystem and one in the innner class named Cache that actually gets
// registered as a shutdown hook. If the latter is present, then we are
// on 0.21 or cloudera patched 0.20.
Runnable hdfsClientFinalizer = null;
// Look into the FileSystem#Cache class for clientFinalizer
Class<?> [] classes = FileSystem.class.getDeclaredClasses();
Class<?> cache = null;
for (Class<?> c: classes) {
if (c.getSimpleName().equals("Cache")) {
cache = c;
break;
}
}
if (cache == null) {
throw new RuntimeException(
"This should not happen. Could not find the cache class in FileSystem.");
}
Field field = null;
try {
field = cache.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);
} catch (NoSuchFieldException e) {
// We can get here if the Cache class does not have a clientFinalizer
// instance: i.e. we're running on straight 0.20 w/o hadoop-4829.
}
if (field != null) {
field.setAccessible(true);
Field cacheField = FileSystem.class.getDeclaredField("CACHE");
cacheField.setAccessible(true);
Object cacheInstance = cacheField.get(fs);
hdfsClientFinalizer = (Runnable)field.get(cacheInstance);
} else {
// Then we didnt' find clientFinalizer in Cache. Presume clean 0.20 hadoop.
field = FileSystem.class.getDeclaredField(CLIENT_FINALIZER_DATA_METHOD);
field.setAccessible(true);
hdfsClientFinalizer = (Runnable)field.get(null);
}
if (hdfsClientFinalizer == null) {
throw new RuntimeException("Client finalizer is null, can't suppress!");
}
if (!fsShutdownHooks.containsKey(hdfsClientFinalizer) &&
!ShutdownHookManager.deleteShutdownHook(hdfsClientFinalizer)) {
throw new RuntimeException("Failed suppression of fs shutdown hook: " +
hdfsClientFinalizer);
}
synchronized (fsShutdownHooks) {
Integer refs = fsShutdownHooks.get(hdfsClientFinalizer);
fsShutdownHooks.put(hdfsClientFinalizer, refs == null ? 1 : refs + 1);
}
return hdfsClientFinalizer;
} catch (NoSuchFieldException nsfe) {
LOG.fatal("Couldn't find field 'clientFinalizer' in FileSystem!", nsfe);
throw new RuntimeException("Failed to suppress HDFS shutdown hook");
} catch (IllegalAccessException iae) {
LOG.fatal("Couldn't access field 'clientFinalizer' in FileSystem!", iae);
throw new RuntimeException("Failed to suppress HDFS shutdown hook");
}
}