示例#1
0
 public static string GetLibraryName(Configuration conf)
 {
     if (IsNativeBzip2Loaded(conf))
     {
         return(Bzip2Compressor.GetLibraryName());
     }
     else
     {
         return(bzip2LibraryName);
     }
 }
示例#2
0
 /// <summary>
 /// Check if native-bzip2 code is loaded & initialized correctly and
 /// can be loaded for this job.
 /// </summary>
 /// <param name="conf">configuration</param>
 /// <returns>
 /// <code>true</code> if native-bzip2 is loaded & initialized
 /// and can be loaded for this job, else <code>false</code>
 /// </returns>
 public static bool IsNativeBzip2Loaded(Configuration conf)
 {
     lock (typeof(Bzip2Factory))
     {
         string libname = conf.Get("io.compression.codec.bzip2.library", "system-native");
         if (!bzip2LibraryName.Equals(libname))
         {
             nativeBzip2Loaded = false;
             bzip2LibraryName  = libname;
             if (libname.Equals("java-builtin"))
             {
                 Log.Info("Using pure-Java version of bzip2 library");
             }
             else
             {
                 if (conf.GetBoolean(CommonConfigurationKeys.IoNativeLibAvailableKey, CommonConfigurationKeys
                                     .IoNativeLibAvailableDefault) && NativeCodeLoader.IsNativeCodeLoaded())
                 {
                     try
                     {
                         // Initialize the native library.
                         Bzip2Compressor.InitSymbols(libname);
                         Bzip2Decompressor.InitSymbols(libname);
                         nativeBzip2Loaded = true;
                         Log.Info("Successfully loaded & initialized native-bzip2 library " + libname);
                     }
                     catch
                     {
                         Log.Warn("Failed to load/initialize native-bzip2 library " + libname + ", will use pure-Java version"
                                  );
                     }
                 }
             }
         }
         return(nativeBzip2Loaded);
     }
 }