public static synchronized void requireHadoopNative() { if (loaded) { return; } if (error != null) { throw new RuntimeException("failed to load Hadoop native library", error); } try { loadLibrary("hadoop"); loadLibrary("snappy"); setStatic(NativeCodeLoader.class.getDeclaredField("nativeCodeLoaded"), true); setStatic(LoadSnappy.class.getDeclaredField("AVAILABLE"), true); setStatic(LoadSnappy.class.getDeclaredField("LOADED"), true); // verify that all configured codec classes can be loaded loadAllCodecs(); loaded = true; } catch (Throwable t) { error = t; throw new RuntimeException("failed to load Hadoop native library", error); } }
public void testSnappyCodec() throws IOException { if (LoadSnappy.isAvailable()) { if (LoadSnappy.isLoaded()) { codecTest(conf, seed, 0, "org.apache.hadoop.io.compress.SnappyCodec"); codecTest(conf, seed, count, "org.apache.hadoop.io.compress.SnappyCodec"); } else { fail("Snappy native available but Hadoop native not"); } } }
/** * Are the native snappy libraries loaded & initialized? * * @param conf * configuration * @return true if loaded & initialized, otherwise false */ public static boolean isNativeSnappyLoaded(Configuration conf) { return LoadSnappy.isLoaded(); }
/** * Are the native snappy libraries loaded & initialized? * * @param conf configuration * @return true if loaded & initialized, otherwise false */ public static boolean isNativeSnappyLoaded(Configuration conf) { return LoadSnappy.isLoaded() && conf.getBoolean( CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_KEY, CommonConfigurationKeys.IO_NATIVE_LIB_AVAILABLE_DEFAULT); }