uschindler commented on a change in pull request #1364: SOLR-14335: Lock Solr's 
memory to prevent swapping
URL: https://github.com/apache/lucene-solr/pull/1364#discussion_r396320238
 
 

 ##########
 File path: solr/bootstrap/src/java/org/apache/solr/bootstrap/NativeLibrary.java
 ##########
 @@ -0,0 +1,139 @@
+/*
+ * 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.solr.bootstrap;
+
+import com.sun.jna.LastErrorException;
+import org.eclipse.jetty.start.StartLog;
+
+import static org.apache.solr.bootstrap.NativeLibrary.OSType.*;
+
+public final class NativeLibrary {
+  public enum OSType {
+    LINUX,
+    MAC,
+    WINDOWS,
+    AIX,
+    OTHER;
+  }
+
+  public static final OSType osType;
+
+  private static final int MCL_CURRENT;
+
+  private static final int ENOMEM = 12;
+
+  private static final NativeLibraryWrapper wrappedLibrary;
+  private static boolean jnaLockable = false;
+
+  static {
+    // detect the OS type the JVM is running on and then set the 
CLibraryWrapper
+    // instance to a compatable implementation of CLibraryWrapper for that OS 
type
+    osType = getOsType();
+    switch (osType) {
+      case MAC:
+        wrappedLibrary = new NativeLibraryDarwin();
+        break;
+      case WINDOWS:
+        wrappedLibrary = new NativeLibraryWindows();
+        break;
+      case LINUX:
+      case AIX:
+      case OTHER:
+      default:
+        wrappedLibrary = new NativeLibraryLinux();
+    }
+
+    if (System.getProperty("os.arch").toLowerCase().contains("ppc")) {
+      if (osType == LINUX) {
+        MCL_CURRENT = 0x2000;
+      } else if (osType == AIX) {
+        MCL_CURRENT = 0x100;
+      } else {
+        MCL_CURRENT = 1;
+      }
+    } else {
+      MCL_CURRENT = 1;
+    }
+  }
+
+  private NativeLibrary() {
+  }
+
+  /**
+   * @return the detected OSType of the Operating System running the JVM using 
crude string matching
+   */
+  private static OSType getOsType() {
 
 Review comment:
   we already detect the OS type using `oal.util.Constants`. We should not 
duplicate code here.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to