lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cpoersc...@apache.org
Subject svn commit: r1723602 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/core/ solr/core/src/java/org/apache/solr/core/ solr/core/src/java/org/apache/solr/update/ solr/core/src/test/org/apache/solr/core/ solr/core/src/test/org/apache/solr/update/
Date Thu, 07 Jan 2016 17:39:44 GMT
Author: cpoerschke
Date: Thu Jan  7 17:39:43 2016
New Revision: 1723602

URL: http://svn.apache.org/viewvc?rev=1723602&view=rev
Log:
SOLR-8484: refactor update/SolrIndexConfig.LOCK_TYPE_* into core/DirectoryFactory.LOCK_TYPE_*
(merge in revision 1723564 from trunk)

Added:
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/DirectoryFactoryTest.java
      - copied unchanged from r1723564, lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/DirectoryFactoryTest.java
Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/solr/   (props changed)
    lucene/dev/branches/branch_5x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/   (props changed)
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/StandardDirectoryFactory.java
    lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestConfig.java
  (contents, props changed)
    lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java

Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Thu Jan  7 17:39:43 2016
@@ -249,6 +249,9 @@ Other Changes
 
 * SOLR-8498: Improve error message when a large value is stored in an indexed string field.
(shalin)
 
+* SOLR-8484: refactor update/SolrIndexConfig.LOCK_TYPE_* into core/DirectoryFactory.LOCK_TYPE_*
+  (Christine Poerschke)
+
 ==================  5.4.0 ==================
 
 Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/DirectoryFactory.java
Thu Jan  7 17:39:43 2016
@@ -54,6 +54,12 @@ public abstract class DirectoryFactory i
   public enum DirContext {DEFAULT, META_DATA}
 
   private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  // Available lock types
+  public final static String LOCK_TYPE_SIMPLE = "simple";
+  public final static String LOCK_TYPE_NATIVE = "native";
+  public final static String LOCK_TYPE_SINGLE = "single";
+  public final static String LOCK_TYPE_NONE   = "none";
   
   /**
    * Indicates a Directory will no longer be used, and when its ref count

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/HdfsDirectoryFactory.java
Thu Jan  7 17:39:43 2016
@@ -163,9 +163,9 @@ public class HdfsDirectoryFactory extend
     switch (lockType) {
       case "hdfs":
         return HdfsLockFactory.INSTANCE;
-      case "single":
+      case DirectoryFactory.LOCK_TYPE_SINGLE:
         return new SingleInstanceLockFactory();
-      case "none":
+      case DirectoryFactory.LOCK_TYPE_NONE:
         return NoLockFactory.INSTANCE;
       default:
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/RAMDirectoryFactory.java
Thu Jan  7 17:39:43 2016
@@ -33,9 +33,9 @@ public class RAMDirectoryFactory extends
 
   @Override
   protected LockFactory createLockFactory(String rawLockType) throws IOException {
-    if (!(rawLockType == null || "single".equalsIgnoreCase(rawLockType.trim()))) {
+    if (!(rawLockType == null || DirectoryFactory.LOCK_TYPE_SINGLE.equalsIgnoreCase(rawLockType.trim())))
{
       throw new SolrException(ErrorCode.FORBIDDEN,
-          "RAMDirectory can only be used with the 'single' lock factory type.");
+          "RAMDirectory can only be used with the '"+DirectoryFactory.LOCK_TYPE_SINGLE+"'
lock factory type.");
     }
     return new SingleInstanceLockFactory();
   }

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/StandardDirectoryFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/StandardDirectoryFactory.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/StandardDirectoryFactory.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/core/StandardDirectoryFactory.java
Thu Jan  7 17:39:43 2016
@@ -56,19 +56,18 @@ public class StandardDirectoryFactory ex
   @Override
   protected LockFactory createLockFactory(String rawLockType) throws IOException {
     if (null == rawLockType) {
-      // we default to "native"
-      log.warn("No lockType configured, assuming 'native'.");
-      rawLockType = "native";
+      rawLockType = DirectoryFactory.LOCK_TYPE_NATIVE;
+      log.warn("No lockType configured, assuming '"+rawLockType+"'.");
     }
     final String lockType = rawLockType.toLowerCase(Locale.ROOT).trim();
     switch (lockType) {
-      case "simple":
+      case DirectoryFactory.LOCK_TYPE_SIMPLE:
         return SimpleFSLockFactory.INSTANCE;
-      case "native":
+      case DirectoryFactory.LOCK_TYPE_NATIVE:
         return NativeFSLockFactory.INSTANCE;
-      case "single":
+      case DirectoryFactory.LOCK_TYPE_SINGLE:
         return new SingleInstanceLockFactory();
-      case "none":
+      case DirectoryFactory.LOCK_TYPE_NONE:
         return NoLockFactory.INSTANCE;
       default:
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,

Modified: lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/java/org/apache/solr/update/SolrIndexConfig.java
Thu Jan  7 17:39:43 2016
@@ -29,6 +29,7 @@ import org.apache.lucene.util.InfoStream
 import org.apache.lucene.util.Version;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.Utils;
+import org.apache.solr.core.DirectoryFactory;
 import org.apache.solr.core.MapSerializable;
 import org.apache.solr.core.PluginInfo;
 import org.apache.solr.core.SolrConfig;
@@ -68,12 +69,6 @@ public class SolrIndexConfig implements
   
   public InfoStream infoStream = InfoStream.NO_OUTPUT;
 
-  // Available lock types
-  public final static String LOCK_TYPE_SIMPLE = "simple";
-  public final static String LOCK_TYPE_NATIVE = "native";
-  public final static String LOCK_TYPE_SINGLE = "single";
-  public final static String LOCK_TYPE_NONE   = "none";
-
   /**
    * Internal constructor for setting defaults based on Lucene Version
    */
@@ -86,7 +81,7 @@ public class SolrIndexConfig implements
     mergeFactor = -1;
     ramBufferSizeMB = 100;
     writeLockTimeout = -1;
-    lockType = LOCK_TYPE_NATIVE;
+    lockType = DirectoryFactory.LOCK_TYPE_NATIVE;
     mergePolicyInfo = null;
     mergeSchedulerInfo = null;
     defaultMergePolicyClassName = TieredMergePolicy.class.getName();

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/CachingDirectoryFactoryTest.java
Thu Jan  7 17:39:43 2016
@@ -193,10 +193,10 @@ public class CachingDirectoryFactoryTest
             if (tracker == null) {
               tracker = new Tracker();
               tracker.path = path;
-              tracker.dir = df.get(path, DirContext.DEFAULT, "single");
+              tracker.dir = df.get(path, DirContext.DEFAULT, DirectoryFactory.LOCK_TYPE_SINGLE);
               dirs.put(path, tracker);
             } else {
-              tracker.dir = df.get(path, DirContext.DEFAULT, "single");
+              tracker.dir = df.get(path, DirContext.DEFAULT, DirectoryFactory.LOCK_TYPE_SINGLE);
             }
             tracker.refCnt.incrementAndGet();
           }

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/RAMDirectoryFactoryTest.java
Thu Jan  7 17:39:43 2016
@@ -44,8 +44,8 @@ public class RAMDirectoryFactoryTest ext
       }
     };
     String path = "/fake/path";
-    Directory dir1 = factory.get(path, DirContext.DEFAULT, "single");
-    Directory dir2 = factory.get(path, DirContext.DEFAULT, "single");
+    Directory dir1 = factory.get(path, DirContext.DEFAULT, DirectoryFactory.LOCK_TYPE_SINGLE);
+    Directory dir2 = factory.get(path, DirContext.DEFAULT, DirectoryFactory.LOCK_TYPE_SINGLE);
     assertEquals("RAMDirectoryFactory should not create new instance of RefCntRamDirectory
" +
         "every time open() is called for the same path", dir1, dir2);
 
@@ -56,7 +56,7 @@ public class RAMDirectoryFactoryTest ext
 
   private void dotestOpenSucceedForEmptyDir() throws IOException {
     RAMDirectoryFactory factory = new RAMDirectoryFactory();
-    Directory dir = factory.get("/fake/path", DirContext.DEFAULT, "single");
+    Directory dir = factory.get("/fake/path", DirContext.DEFAULT, DirectoryFactory.LOCK_TYPE_SINGLE);
     assertNotNull("RAMDirectoryFactory should create RefCntRamDirectory even if the path
doen't lead " +
         "to index directory on the file system", dir);
     factory.release(dir);

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/SolrCoreCheckLockOnStartupTest.java
Thu Jan  7 17:39:43 2016
@@ -59,7 +59,7 @@ public class SolrCoreCheckLockOnStartupT
 
     ignoreException("locked");
     try {
-      System.setProperty("solr.tests.lockType","simple");
+      System.setProperty("solr.tests.lockType",DirectoryFactory.LOCK_TYPE_SIMPLE);
       //opening a new core on the same index
       initCore("solrconfig-basic.xml", "schema.xml");
       if (checkForCoreInitException(LockObtainFailedException.class))
@@ -85,7 +85,7 @@ public class SolrCoreCheckLockOnStartupT
 
     ignoreException("locked");
     try {
-      System.setProperty("solr.tests.lockType","native");
+      System.setProperty("solr.tests.lockType",DirectoryFactory.LOCK_TYPE_NATIVE);
       //opening a new core on the same index
       initCore("solrconfig-basic.xml", "schema.xml");
       CoreContainer cc = h.getCoreContainer();

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestConfig.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestConfig.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestConfig.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/core/TestConfig.java
Thu Jan  7 17:39:43 2016
@@ -124,7 +124,7 @@ public class TestConfig extends SolrTest
 
     ++numDefaultsTested; assertEquals("default ramBufferSizeMB", 100.0D, sic.ramBufferSizeMB,
0.0D);
     ++numDefaultsTested; assertEquals("default writeLockTimeout", -1, sic.writeLockTimeout);
-    ++numDefaultsTested; assertEquals("default LockType", SolrIndexConfig.LOCK_TYPE_NATIVE,
sic.lockType);
+    ++numDefaultsTested; assertEquals("default LockType", DirectoryFactory.LOCK_TYPE_NATIVE,
sic.lockType);
 
     ++numDefaultsTested; assertEquals("default infoStream", InfoStream.NO_OUTPUT, sic.infoStream);
 

Modified: lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java?rev=1723602&r1=1723601&r2=1723602&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java
(original)
+++ lucene/dev/branches/branch_5x/solr/core/src/test/org/apache/solr/update/SolrIndexConfigTest.java
Thu Jan  7 17:39:43 2016
@@ -25,6 +25,7 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.index.SimpleMergedSegmentWarmer;
 import org.apache.lucene.index.TieredMergePolicy;
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.core.DirectoryFactory;
 import org.apache.solr.core.SolrConfig;
 import org.apache.solr.core.TestMergePolicyConfig;
 import org.apache.solr.schema.IndexSchema;
@@ -129,10 +130,10 @@ public class SolrIndexConfigTest extends
     ++mSizeExpected; assertTrue(m.get("lockType") instanceof String);
     {
       final String lockType = (String)m.get("lockType");
-      assertTrue(SolrIndexConfig.LOCK_TYPE_SIMPLE.equals(lockType) ||
-          SolrIndexConfig.LOCK_TYPE_NATIVE.equals(lockType) ||
-          SolrIndexConfig.LOCK_TYPE_SINGLE.equals(lockType) ||
-          SolrIndexConfig.LOCK_TYPE_NONE.equals(lockType));
+      assertTrue(DirectoryFactory.LOCK_TYPE_SIMPLE.equals(lockType) ||
+          DirectoryFactory.LOCK_TYPE_NATIVE.equals(lockType) ||
+          DirectoryFactory.LOCK_TYPE_SINGLE.equals(lockType) ||
+          DirectoryFactory.LOCK_TYPE_NONE.equals(lockType));
     }
 
     ++mSizeExpected; assertTrue(m.get("infoStreamEnabled") instanceof Boolean);



Mime
View raw message