uschindler commented on code in PR #1360:
URL: https://github.com/apache/solr/pull/1360#discussion_r1125444982


##########
solr/core/src/java/org/apache/solr/core/MMapDirectoryFactory.java:
##########
@@ -63,7 +63,7 @@ protected Directory create(String path, LockFactory 
lockFactory, DirContext dirC
       throws IOException {
     MMapDirectory mapDirectory = new MMapDirectory(Path.of(path), lockFactory, 
maxChunk);
     try {
-      mapDirectory.setUseUnmap(unmapHack);
+      System.setProperty(MMapDirectory.ENABLE_UNMAP_HACK_SYSPROP, 
String.valueOf(unmapHack));

Review Comment:
   Do it like that:
   
   ```java
   public class MMapDirectoryFactory extends StandardDirectoryFactory {
     private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
     boolean preload;
     private long maxChunk;
   
     @Override
     public void init(NamedList<?> args) {
       super.init(args);
       SolrParams params = args.toSolrParams();
       maxChunk = params.getLong("maxChunkSize", 
MMapDirectory.DEFAULT_MAX_CHUNK_SIZE);
       if (maxChunk <= 0) {
         throw new IllegalArgumentException("maxChunk must be greater than 0");
       }
       if (params.get("unmap") != null) {
         log.warn("It is no longer possible to configure unmapping of index 
files on DirectoryFactory level in solrconfig.xml.");
         log.warn("To disable unmapping, pass 
-Dorg.apache.lucene.store.MMapDirectory.enableUnmapHack=false on Solr's command 
line.");
       }
       preload = params.getBool("preload", false); // default turn-off
     }
   
     @Override
     protected Directory create(String path, LockFactory lockFactory, 
DirContext dirContext)
         throws IOException {
       MMapDirectory mapDirectory = new MMapDirectory(Path.of(path), 
lockFactory, maxChunk);
       mapDirectory.setPreload(preload);
       return mapDirectory;
     }
   }
   ```



-- 
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: issues-unsubscr...@solr.apache.org

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


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

Reply via email to