static Lz4Compressor() { // HACK - Use this as a global lock in the JNI layer if (NativeCodeLoader.IsNativeCodeLoaded()) { // Initialize the native library try { InitIDs(); } catch (Exception t) { // Ignore failure to load/initialize lz4 Log.Warn(t.ToString()); } } else { Log.Error("Cannot load " + typeof(Org.Apache.Hadoop.IO.Compress.Lz4.Lz4Compressor ).FullName + " without native hadoop library!"); } }
/// <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); } }
/// <summary>Method for compressor availability check</summary> private static bool IsAvailable <T, E>(CompressDecompressTester.TesterPair <T, E> pair ) where T : Compressor where E : Decompressor { Compressor compressor = pair.compressor; if (compressor.GetType().IsAssignableFrom(typeof(Lz4Compressor)) && (NativeCodeLoader .IsNativeCodeLoaded())) { return(true); } else { if (compressor.GetType().IsAssignableFrom(typeof(BuiltInZlibDeflater)) && NativeCodeLoader .IsNativeCodeLoaded()) { return(true); } else { if (compressor.GetType().IsAssignableFrom(typeof(ZlibCompressor))) { return(ZlibFactory.IsNativeZlibLoaded(new Configuration())); } else { if (compressor.GetType().IsAssignableFrom(typeof(SnappyCompressor)) && IsNativeSnappyLoadable ()) { return(true); } } } } return(false); }
public virtual void TestNetgroups() { if (!NativeCodeLoader.IsNativeCodeLoaded()) { Log.Info("Not testing netgroups, " + "this test only runs when native code is compiled" ); return; } string groupMappingClassName = Runtime.GetProperty("TestProxyUsersGroupMapping"); if (groupMappingClassName == null) { Log.Info("Not testing netgroups, no group mapping class specified, " + "use -DTestProxyUsersGroupMapping=$className to specify " + "group mapping class (must implement GroupMappingServiceProvider " + "interface and support netgroups)" ); return; } Log.Info("Testing netgroups using: " + groupMappingClassName); Configuration conf = new Configuration(); conf.Set(CommonConfigurationKeysPublic.HadoopSecurityGroupMapping, groupMappingClassName ); conf.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserGroupConfKey (RealUserName), StringUtils.Join(",", Arrays.AsList(NetgroupNames))); conf.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserIpConfKey (RealUserName), ProxyIp); ProxyUsers.RefreshSuperUserGroupsConfiguration(conf); Groups groups = Groups.GetUserToGroupsMappingService(conf); // try proxying a group that's allowed UserGroupInformation realUserUgi = UserGroupInformation.CreateRemoteUser(RealUserName ); UserGroupInformation proxyUserUgi = UserGroupInformation.CreateProxyUserForTesting (ProxyUserName, realUserUgi, Collections.ToArray(groups.GetGroups(ProxyUserName ), new string[groups.GetGroups(ProxyUserName).Count])); AssertAuthorized(proxyUserUgi, ProxyIp); }
/// <summary>Are the native lz4 libraries loaded & initialized?</summary> /// <returns>true if loaded & initialized, otherwise false</returns> public static bool IsNativeCodeLoaded() { return(NativeCodeLoader.IsNativeCodeLoaded()); }
static Lz4Codec() { NativeCodeLoader.IsNativeCodeLoaded(); }
/// <summary>Return true if the JNI-based native IO extensions are available.</summary> public static bool IsAvailable() { return(NativeCodeLoader.IsNativeCodeLoaded() && nativeLoaded); }
public virtual void CheckLoaded() { Assume.AssumeTrue(NativeCodeLoader.IsNativeCodeLoaded()); }