You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2022/01/21 12:22:39 UTC

[GitHub] [accumulo] ctubbsii opened a new pull request #2425: Separate native map loading from native map code

ctubbsii opened a new pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425


   * Create a separate NativeMapLoader and relocate into that new class the
     code to load the native libraries that was previously in NativeMap
     alongside the actual code for handling native maps
   * Remove unnecessarily redundant `isLoaded()` checks, since the behavior
     is now to `System.exit(1)` if the native code is configured to be
     used, but cannot be loaded. There is no longer a question of whether
     they are loaded. They are always loaded if configured to be, or else
     the tserver will die on startup.
   * Simplify and organize the loader code
   * Make the loader code work better with tests by providing a method
     specifically for testing (for NativeMapIT, and InMemoryMapIT,
     specifically, because they need to load native maps inside the test
     thread, and not on a tserver)
   * Update ConfigurableMacBase so it will ensure the native maps are built
     before Mini is started, so the tests don't hang because the native
     maps aren't built (only applies to ConfigurableMacBase tests... other
     tests may need something similar)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r790009322



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/memory/NativeMapLoader.java
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.tserver.memory;
+
+import java.io.File;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.accumulo.core.conf.Property;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class NativeMapLoader {
+
+  private static final Logger log = LoggerFactory.getLogger(NativeMapLoader.class);
+  private static final Pattern dotSuffix = Pattern.compile("[.][^.]*$");
+  private static final String PROP_NAME = "accumulo.native.lib.path";
+  private static final AtomicBoolean loaded = new AtomicBoolean(false);
+
+  // don't allow instantiation
+  private NativeMapLoader() {}
+
+  public synchronized static void load() {
+    // load at most once; System.exit if loading fails
+    if (loaded.compareAndSet(false, true)) {
+      if (loadFromSearchPath(System.getProperty(PROP_NAME)) || loadFromSystemLinker()) {
+        return;
+      }
+      log.error(
+          "FATAL! Accumulo native libraries were requested but could not"
+              + " be be loaded. Either set '{}' to false in accumulo.properties or make"
+              + " sure native libraries are created in directories set by the JVM"
+              + " system property '{}' in accumulo-env.sh!",
+          Property.TSERV_NATIVEMAP_ENABLED, PROP_NAME);
+      System.exit(1);
+    }
+  }
+
+  public static void loadForTest(List<File> locations, Runnable onFail) {
+    // if the library can't be loaded at the given path, execute the failure task
+    var searchPath = locations.stream().map(File::getAbsolutePath).collect(Collectors.joining(":"));
+    if (!loadFromSearchPath(searchPath)) {
+      onFail.run();
+    }
+  }
+
+  /**
+   * The specified search path will be used to attempt to load them. Directories will be searched by
+   * using the system-specific library naming conventions. A path directly to a file can also be
+   * provided. Loading will continue until the search path is exhausted, or until the native
+   * libraries are found and successfully loaded, whichever occurs first.
+   */
+  private static boolean loadFromSearchPath(String searchPath) {
+    // Attempt to load from these directories, using standard names, or by an exact file name
+    if (searchPath != null) {
+      if (Stream.of(searchPath.split(":")).flatMap(NativeMapLoader::mapLibraryNames)
+          .anyMatch(NativeMapLoader::loadNativeLib)) {
+        return true;
+      }
+      log.error("Tried and failed to load Accumulo native library from property {} set to {}",
+          PROP_NAME, searchPath);
+    }
+    return false;
+  }
+
+  // Check LD_LIBRARY_PATH (DYLD_LIBRARY_PATH on Mac)
+  private static boolean loadFromSystemLinker() {
+    String propName = "java.library.path";

Review comment:
       I didn't feel the need, because this is only used for logging the contents. The fact that we read it as a system property is incidental (implementation detail) to how the `LD_LIBRARY_PATH` works. We're only reading this as a matter of convenience, but the actual linker doesn't use this system property. It uses the `LD_LIBRARY_PATH` environment variable in native code in Java's internals. I wanted to keep this property name contained inside this method rather than put it as a constant, because users shouldn't even have to think about this as a system property they can set or use.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r790006700



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
##########
@@ -253,8 +254,10 @@ public TabletServerResourceManager(ServerContext context) {
     final AccumuloConfiguration acuConf = context.getConfiguration();
 
     long maxMemory = acuConf.getAsBytes(Property.TSERV_MAXMEM);
-    boolean usingNativeMap =
-        acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED) && NativeMap.isLoaded();
+    boolean usingNativeMap = acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED);
+    if (usingNativeMap) {
+      NativeMapLoader.load();

Review comment:
       No, because I baked in a `load only once` mechanism with an `AtomicBoolean`. My concern with removing this here would be that it may take some time before the `NativeMap` class is referenced, and therefore it might not exit right away. We currently have fast failure, because `NativeMap` is referenced here in the code I changed. So, when the tserver is starting up and creates an instance of this resource manager object, it will fail right away if the native maps can't be loaded. Keeping this here preserves that same fast-failure behavior.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] milleruntime commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
milleruntime commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r790770655



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
##########
@@ -253,8 +254,10 @@ public TabletServerResourceManager(ServerContext context) {
     final AccumuloConfiguration acuConf = context.getConfiguration();
 
     long maxMemory = acuConf.getAsBytes(Property.TSERV_MAXMEM);
-    boolean usingNativeMap =
-        acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED) && NativeMap.isLoaded();
+    boolean usingNativeMap = acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED);
+    if (usingNativeMap) {
+      NativeMapLoader.load();

Review comment:
       I was suggesting removing the static load block from `NativeMap` and keeping this fast failure check in the tserver. Why do we still need the static code block in `NativeMap`, if we are resolving at the start up of tserver? I thought we may be using `NativeMap` outside of the tserver, perhaps in a scan thread or somewhere but couldn't find any other references. My point was we don't need the static code block with this new check. Sorry I should have commented on that part of the code.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] milleruntime commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
milleruntime commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r790780739



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
##########
@@ -253,8 +254,10 @@ public TabletServerResourceManager(ServerContext context) {
     final AccumuloConfiguration acuConf = context.getConfiguration();
 
     long maxMemory = acuConf.getAsBytes(Property.TSERV_MAXMEM);
-    boolean usingNativeMap =
-        acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED) && NativeMap.isLoaded();
+    boolean usingNativeMap = acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED);
+    if (usingNativeMap) {
+      NativeMapLoader.load();

Review comment:
       You probably didn't think any changes needed to be made but I still think it is presumptuous to merge a PR and mark comments resolved without an approval of the PR. When I open a PR and if I don't change the code that someone commented on, I usually let them decide if the conversation is resolved or not. I know we don't have explicit rules for these type of situations, I just find that it is the courteous thing to do when someone takes the time to review my code.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii merged pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
ctubbsii merged pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r791684454



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/NativeMap.java
##########
@@ -70,120 +66,9 @@
 public class NativeMap implements Iterable<Map.Entry<Key,Value>> {
 
   private static final Logger log = LoggerFactory.getLogger(NativeMap.class);
-  private static AtomicBoolean loadedNativeLibraries = new AtomicBoolean(false);
 
-  // Load native library
   static {

Review comment:
       I didn't add a new fast fail check. There was already a static reference to the `NativeMap` class in there before my changes. I preserved the existing behavior by explicitly adding the load there. However, it I remove this here, then it wouldn't guarantee that it was loaded before this class could be referenced, which some code could do in the future. Keeping this static initializer block and making the explicit load in the resources class for fast failure preserves all existing behaviors, which I don't want to risk changing.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r797154815



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
##########
@@ -253,8 +254,10 @@ public TabletServerResourceManager(ServerContext context) {
     final AccumuloConfiguration acuConf = context.getConfiguration();
 
     long maxMemory = acuConf.getAsBytes(Property.TSERV_MAXMEM);
-    boolean usingNativeMap =
-        acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED) && NativeMap.isLoaded();
+    boolean usingNativeMap = acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED);
+    if (usingNativeMap) {
+      NativeMapLoader.load();

Review comment:
       I wasn't trying to be discourteous. I was just trying to be expeditious. I apologize if I upset you by pushing it through too quickly.
   
   Regarding marking this thread as resolved. I thought I answered your questions. I had no reason to believe there will be follow-on and don't feel it necessary to hold open threads indefinitely when a reply is not expected and may never come. Open threads clutter the page and make it harder for me to find open comments that I haven't addressed. Why not just mark the thread as "Unresolved" if there's more to address? That's what I do. After all, I'm not intentionally resolving threads to be discourteous... I'm doing so to track outstanding tasks. Resolving the thread merely indicates that *I* don't think there's more to do there. I won't be offended if you simply reopen the thread because *you* believe there's more.
   
   As always, please feel free to directly email me or message me on Slack or by any other means, if you feel I've done something discourteous. I'm very busy and don't always immediately see the comments on GitHub, so contacting me directly to bring it to my attention allows me to be more expeditious in correcting any misunderstandings, or apologizing when needed.
   
   As for your observation about the static initializer. I thought I answered your question already. I understood you to mean it was redundant with the call to load() in TabletServerResourceManager, but as I answered already, I left it in because I believed it preserved existing behavior, if the NativeMap class were referenced by some other code path, either now, or in the future. As it turns out, that was a mistake, and I should have removed it, as I've done in #2453.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] milleruntime commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
milleruntime commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r790772188



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/NativeMap.java
##########
@@ -70,120 +66,9 @@
 public class NativeMap implements Iterable<Map.Entry<Key,Value>> {
 
   private static final Logger log = LoggerFactory.getLogger(NativeMap.class);
-  private static AtomicBoolean loadedNativeLibraries = new AtomicBoolean(false);
 
-  // Load native library
   static {

Review comment:
       I think you could remove this static code block with the new fast fail check you added in tserver.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r791684454



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/NativeMap.java
##########
@@ -70,120 +66,9 @@
 public class NativeMap implements Iterable<Map.Entry<Key,Value>> {
 
   private static final Logger log = LoggerFactory.getLogger(NativeMap.class);
-  private static AtomicBoolean loadedNativeLibraries = new AtomicBoolean(false);
 
-  // Load native library
   static {

Review comment:
       I didn't add a new fast fail check. There was already a static reference to the `NativeMap` class in there before my changes. I preserved the existing behavior by explicitly adding the load there. However, it I remove this here, then it wouldn't guarantee that it was loaded before this class could be referenced, which some code could do in the future. Keeping this static initializer block and making the explicit load in the resources class for fast failure preserves all existing behaviors, which I don't want to risk changing.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] ctubbsii commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r790011638



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/memory/NativeMapLoader.java
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.tserver.memory;
+
+import java.io.File;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.accumulo.core.conf.Property;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class NativeMapLoader {
+
+  private static final Logger log = LoggerFactory.getLogger(NativeMapLoader.class);
+  private static final Pattern dotSuffix = Pattern.compile("[.][^.]*$");
+  private static final String PROP_NAME = "accumulo.native.lib.path";
+  private static final AtomicBoolean loaded = new AtomicBoolean(false);
+
+  // don't allow instantiation
+  private NativeMapLoader() {}

Review comment:
       I initially tried that, but it didn't end up making any sense, because the native libraries that are loaded are static relative to the JVM (you can't "unload" them when the class is closed or garbage-collected). So, I could have had objects that have lifecycles, but still reference a single static `AtomicBoolean loaded` member, but ultimately it didn't make it easier to test, and it felt kludge-y. Static methods make it obvious that you're managing static state, which is necessarily static and can't be avoided, rather than obscuring that fact behind instantiable objects.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [accumulo] milleruntime commented on a change in pull request #2425: Separate native map loading from native map code

Posted by GitBox <gi...@apache.org>.
milleruntime commented on a change in pull request #2425:
URL: https://github.com/apache/accumulo/pull/2425#discussion_r789909142



##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/memory/NativeMapLoader.java
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.tserver.memory;
+
+import java.io.File;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.accumulo.core.conf.Property;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class NativeMapLoader {
+
+  private static final Logger log = LoggerFactory.getLogger(NativeMapLoader.class);
+  private static final Pattern dotSuffix = Pattern.compile("[.][^.]*$");
+  private static final String PROP_NAME = "accumulo.native.lib.path";
+  private static final AtomicBoolean loaded = new AtomicBoolean(false);
+
+  // don't allow instantiation
+  private NativeMapLoader() {}
+
+  public synchronized static void load() {
+    // load at most once; System.exit if loading fails
+    if (loaded.compareAndSet(false, true)) {
+      if (loadFromSearchPath(System.getProperty(PROP_NAME)) || loadFromSystemLinker()) {
+        return;
+      }
+      log.error(
+          "FATAL! Accumulo native libraries were requested but could not"
+              + " be be loaded. Either set '{}' to false in accumulo.properties or make"
+              + " sure native libraries are created in directories set by the JVM"
+              + " system property '{}' in accumulo-env.sh!",
+          Property.TSERV_NATIVEMAP_ENABLED, PROP_NAME);
+      System.exit(1);
+    }
+  }
+
+  public static void loadForTest(List<File> locations, Runnable onFail) {
+    // if the library can't be loaded at the given path, execute the failure task
+    var searchPath = locations.stream().map(File::getAbsolutePath).collect(Collectors.joining(":"));
+    if (!loadFromSearchPath(searchPath)) {
+      onFail.run();
+    }
+  }
+
+  /**
+   * The specified search path will be used to attempt to load them. Directories will be searched by
+   * using the system-specific library naming conventions. A path directly to a file can also be
+   * provided. Loading will continue until the search path is exhausted, or until the native
+   * libraries are found and successfully loaded, whichever occurs first.
+   */
+  private static boolean loadFromSearchPath(String searchPath) {
+    // Attempt to load from these directories, using standard names, or by an exact file name
+    if (searchPath != null) {
+      if (Stream.of(searchPath.split(":")).flatMap(NativeMapLoader::mapLibraryNames)
+          .anyMatch(NativeMapLoader::loadNativeLib)) {
+        return true;
+      }
+      log.error("Tried and failed to load Accumulo native library from property {} set to {}",
+          PROP_NAME, searchPath);
+    }
+    return false;
+  }
+
+  // Check LD_LIBRARY_PATH (DYLD_LIBRARY_PATH on Mac)
+  private static boolean loadFromSystemLinker() {
+    String propName = "java.library.path";

Review comment:
       Could make this final and put at top with the other static final variables. Then you'd have to rename the system properties to be more descriptive.

##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServerResourceManager.java
##########
@@ -253,8 +254,10 @@ public TabletServerResourceManager(ServerContext context) {
     final AccumuloConfiguration acuConf = context.getConfiguration();
 
     long maxMemory = acuConf.getAsBytes(Property.TSERV_MAXMEM);
-    boolean usingNativeMap =
-        acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED) && NativeMap.isLoaded();
+    boolean usingNativeMap = acuConf.getBoolean(Property.TSERV_NATIVEMAP_ENABLED);
+    if (usingNativeMap) {
+      NativeMapLoader.load();

Review comment:
       Won't this cause the native map to get loaded twice because of the static code block being executed when `NativeMap` class is loaded? If we have this do we still need the static code block?

##########
File path: server/tserver/src/main/java/org/apache/accumulo/tserver/memory/NativeMapLoader.java
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.accumulo.tserver.memory;
+
+import java.io.File;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import org.apache.accumulo.core.conf.Property;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+public class NativeMapLoader {
+
+  private static final Logger log = LoggerFactory.getLogger(NativeMapLoader.class);
+  private static final Pattern dotSuffix = Pattern.compile("[.][^.]*$");
+  private static final String PROP_NAME = "accumulo.native.lib.path";
+  private static final AtomicBoolean loaded = new AtomicBoolean(false);
+
+  // don't allow instantiation
+  private NativeMapLoader() {}

Review comment:
       It seems like this class could be a regular java object and have its static methods converted to non static methods. It might make it easier to test.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org