NativeLibraryLoader.getInstance().loadLibrary(rocksLibFolder.getAbsolutePath());
/** * Attempts to extract the native RocksDB library * from the classpath and load it * * @param tmpDir A temporary directory to use * to copy the native library to. If null, * or the empty string, we rely on Java's * {@link java.io.File#createTempFile(String, String)} * function to provide a temporary location. * The temporary file will be registered for deletion * on exit. * * @throws java.io.IOException if a filesystem operation fails. */ void loadLibraryFromJar(final String tmpDir) throws IOException { if (!initialized) { System.load(loadLibraryFromJarToTemp(tmpDir).getAbsolutePath()); initialized = true; } }
/** * Firstly attempts to load the library from <i>java.library.path</i>, * if that fails then it falls back to extracting * the library from the classpath * {@link org.rocksdb.NativeLibraryLoader#loadLibraryFromJar(java.lang.String)} * * @param tmpDir A temporary directory to use * to copy the native library to when loading from the classpath. * If null, or the empty string, we rely on Java's * {@link java.io.File#createTempFile(String, String)} * function to provide a temporary location. * The temporary file will be registered for deletion * on exit. * * @throws java.io.IOException if a filesystem operation fails. */ public synchronized void loadLibrary(final String tmpDir) throws IOException { try { System.loadLibrary(sharedLibraryName); } catch(final UnsatisfiedLinkError ule1) { try { System.loadLibrary(jniLibraryName); } catch(final UnsatisfiedLinkError ule2) { loadLibraryFromJar(tmpDir); } } }
public static void load(String tmpDir) { String envTmpDir = System.getenv(ENV_VAR); if (!Strings.isNullOrEmpty(envTmpDir) && !envTmpDir.equals(tmpDir)) { throw new IllegalArgumentException("The temp dir for " + "native rocksdb libraries has been set to " + tmpDir + " by your kvs prefs, and to " + envTmpDir + " by the " + ENV_VAR + " environment variable."); } if (staticTmpDir.compareAndSet(null, tmpDir)) { try { NativeLibraryLoader.getInstance().loadLibrary(tmpDir); } catch (IOException e) { throw Throwables.propagate(e); } } else if (!staticTmpDir.get().equals(tmpDir)) { log.error("Cannot load native rocksdb libraries to {}, " + "native libraries were already loaded to {}", tmpDir, staticTmpDir.get()); } } }
NativeLibraryLoader.getInstance().loadLibrary(tmpDir); } catch (IOException e) { libraryLoaded.set(LibraryState.NOT_LOADED);
NativeLibraryLoader.getInstance().loadLibrary(rocksLibFolder.getAbsolutePath());
NativeLibraryLoader.getInstance().loadLibrary(rocksLibFolder.getAbsolutePath());
NativeLibraryLoader.getInstance().loadLibrary(rocksLibFolder.getAbsolutePath());