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_r396321964
########## File path: solr/bootstrap/src/java/org/apache/solr/bootstrap/SolrBootstrap.java ########## @@ -0,0 +1,51 @@ +/* + * 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 org.eclipse.jetty.start.StartLog; + +/** + * Main class that will delegate to Jetty's Main class after doing some bootstrap actions. + * Everything that needs to be done before the Jetty application starts can go here. + */ +public class SolrBootstrap { + static { + System.setProperty("jna.tmpdir", System.getProperty("solr.solr.home")); + } + + public SolrBootstrap() { + StartLog.info("Starting Solr..."); + } + + public static void main(String[] args) { + SolrBootstrap solrBootstrap = new SolrBootstrap(); + solrBootstrap.memLockMaybe(); + org.eclipse.jetty.start.Main.main(args); + } + + private void memLockMaybe() { + if (Boolean.getBoolean("solr.memory.lock")) { + if (NativeLibrary.isAvailable()) { + StartLog.info("Attempting to lock Solr's memory to prevent swapping..."); + NativeLibrary.tryMlockall(); + } else { + StartLog.debug("JNA not available, cannot lock memory"); Review comment: This should also be "warn" has it is a bad idea to not tell the user that it does not work at all. If user wants to get rid of warning, he should disable the solr.memory.lock sysprop (resp. env var) from startfile. ---------------------------------------------------------------- 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