jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1486862 - in /jackrabbit/oak/trunk: oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/ oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/ oak-solr-core/src/test/java/org/apache/jackrabbit...
Date Tue, 28 May 2013 11:03:35 GMT
Author: tommaso
Date: Tue May 28 11:03:34 2013
New Revision: 1486862

URL: http://svn.apache.org/r1486862
Log:
OAK-844 - core name is only handled internally on SolrServerProviders

Modified:
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java
    jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java
    jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java
    jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
    jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfigurationTest.java
    jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java
    jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrServerProvider.java

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java?rev=1486862&r1=1486861&r2=1486862&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/OakSolrConfiguration.java
Tue May 28 11:03:34 2013
@@ -63,12 +63,4 @@ public interface OakSolrConfiguration {
      */
     public CommitPolicy getCommitPolicy();
 
-    /**
-     * Provide the name of the Solr core to be used
-     *
-     * @return a <code>String</code> representing the name of the Solr core to
-     *         be used fo Oak
-     */
-    public String getCoreName();
-
 }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java?rev=1486862&r1=1486861&r2=1486862&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/index/SolrIndexHookProvider.java
Tue May 28 11:03:34 2013
@@ -66,8 +66,7 @@ public class SolrIndexHookProvider imple
                 if (log.isDebugEnabled()) {
                     log.debug("Creating a Solr index hook");
                 }
-                IndexEditor indexHook = new SolrIndexDiff(builder, solrServerProvider.getSolrServer(),
oakSolrConfigurationProvider.getConfiguration());
-                return indexHook;
+                return new SolrIndexDiff(builder, solrServerProvider.getSolrServer(), oakSolrConfigurationProvider.getConfiguration());
             } catch (Exception e) {
                 log.error("unable to create Solr IndexHook ", e);
             }

Modified: jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java?rev=1486862&r1=1486861&r2=1486862&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/TestUtils.java
Tue May 28 11:03:34 2013
@@ -138,10 +138,6 @@ public class TestUtils {
                 return CommitPolicy.HARD;
             }
 
-            @Override
-            public String getCoreName() {
-                return "oak";
-            }
         };
     }
 }

Modified: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java?rev=1486862&r1=1486861&r2=1486862&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/EmbeddedSolrConfiguration.java
Tue May 28 11:03:34 2013
@@ -16,8 +16,6 @@
  */
 package org.apache.jackrabbit.oak.plugins.index.solr.embedded;
 
-import javax.jcr.PropertyType;
-
 import org.apache.jackrabbit.oak.api.Type;
 import org.apache.jackrabbit.oak.plugins.index.solr.CommitPolicy;
 import org.apache.jackrabbit.oak.plugins.index.solr.OakSolrConfiguration;
@@ -77,8 +75,4 @@ public class EmbeddedSolrConfiguration i
         return CommitPolicy.SOFT;
     }
 
-    @Override
-    public String getCoreName() {
-        return SolrServerConfigurationDefaults.CORE_NAME;
-    }
 }

Modified: jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java?rev=1486862&r1=1486861&r2=1486862&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/OakSolrNodeStateConfiguration.java
Tue May 28 11:03:34 2013
@@ -77,11 +77,6 @@ public abstract class OakSolrNodeStateCo
         return CommitPolicy.valueOf(getStringValueFor(Properties.COMMIT_POLICY, CommitPolicy.SOFT.toString()));
     }
 
-    @Override
-    public String getCoreName() {
-        return getStringValueFor(Properties.CORE_NAME, SolrServerConfigurationDefaults.CORE_NAME);
-    }
-
     protected String getStringValueFor(String propertyName, String defaultValue) {
         String value = null;
         NodeState configurationNodeState = getConfigurationNodeState();
@@ -90,9 +85,9 @@ public abstract class OakSolrNodeStateCo
             if (property != null) {
                 value = property.getValue(Type.STRING);
             }
-            if (value == null || value.length() == 0) {
-                value = defaultValue;
-            }
+        }
+        if (value == null || value.length() == 0) {
+            value = defaultValue;
         }
         return value;
     }
@@ -101,12 +96,13 @@ public abstract class OakSolrNodeStateCo
     public SolrServerConfiguration getSolrServerConfiguration() {
         String solrHomePath = getStringValueFor(Properties.SOLRHOME_PATH, SolrServerConfigurationDefaults.SOLR_HOME_PATH);
         String solrConfigPath = getStringValueFor(Properties.SOLRCONFIG_PATH, SolrServerConfigurationDefaults.SOLR_CONFIG_PATH);
+        String coreName = getStringValueFor(Properties.CORE_NAME, SolrServerConfigurationDefaults.CORE_NAME);
 
         String context = getStringValueFor(Properties.CONTEXT, SolrServerConfigurationDefaults.CONTEXT);
         Integer httpPort = Integer.valueOf(getStringValueFor(Properties.HTTP_PORT, SolrServerConfigurationDefaults.HTTP_PORT));
 
         return new SolrServerConfiguration(solrHomePath,
-                solrConfigPath, getCoreName()).withHttpConfiguration(context, httpPort);
+                solrConfigPath, coreName).withHttpConfiguration(context, httpPort);
     }
 
     /**
@@ -117,7 +113,7 @@ public abstract class OakSolrNodeStateCo
         public static final String SOLRHOME_PATH = "solrHomePath";
         public static final String SOLRCONFIG_PATH = "solrConfigPath";
         public static final String CONTEXT = "solrContext";
-        public static final String HTTP_PORT = "solrContext";
+        public static final String HTTP_PORT = "httpPort";
         public static final String CORE_NAME = "coreName";
         public static final String PATH_FIELD = "pathField";
         public static final String PARENT_FIELD = "parentField";

Modified: jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfigurationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfigurationTest.java?rev=1486862&r1=1486861&r2=1486862&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfigurationTest.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-embedded/src/test/java/org/apache/jackrabbit/oak/plugins/index/solr/embedded/UpToDateNodeStateConfigurationTest.java
Tue May 28 11:03:34 2013
@@ -25,7 +25,7 @@ import org.junit.Test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertNotNull;
 
 /**
  * Testcase for {@link UpToDateNodeStateConfiguration}
@@ -38,7 +38,7 @@ public class UpToDateNodeStateConfigurat
     public void setUp() throws Exception {
         MicroKernel microKernel = new MicroKernelImpl();
         String jsop = "^\"a\":1 ^\"b\":2 ^\"c\":3 +\"x\":{} +\"y\":{} +\"z\":{} " +
-                "+\"oak:index\":{\"solrIdx\":{\"coreName\":\"cn\", \"solrHome\":\"sh\", \"solrConfig\":\"sc\"}}
";
+                "+\"oak:index\":{\"solrIdx\":{\"coreName\":\"cn\", \"solrHomePath\":\"sh\",
\"solrConfigPath\":\"sc\"}} ";
         microKernel.commit("/", jsop, microKernel.getHeadRevision(), "test data");
         store = new KernelNodeStore(microKernel);
     }
@@ -47,7 +47,11 @@ public class UpToDateNodeStateConfigurat
     public void testExistingPath() throws Exception {
         String path = "oak:index/solrIdx";
         UpToDateNodeStateConfiguration upToDateNodeStateConfiguration = new UpToDateNodeStateConfiguration(store,
path);
-        assertEquals("cn", upToDateNodeStateConfiguration.getCoreName()); // property defined
in the node state
+        SolrServerConfiguration solrServerConfiguration = upToDateNodeStateConfiguration.getSolrServerConfiguration();
+        assertNotNull(solrServerConfiguration);
+        assertEquals("sh", solrServerConfiguration.getSolrHomePath()); // property defined
in the node state
+        assertEquals("cn", solrServerConfiguration.getCoreName()); // property defined in
the node state
+        assertEquals("sc", solrServerConfiguration.getSolrConfigPath()); // property defined
in the node state
         assertEquals("path_exact", upToDateNodeStateConfiguration.getPathField()); // using
default as this property not defined in the node state
     }
 
@@ -55,7 +59,7 @@ public class UpToDateNodeStateConfigurat
     public void testNonExistingPath() throws Exception {
         String path = "some/path/to/oak:index/solrIdx";
         UpToDateNodeStateConfiguration upToDateNodeStateConfiguration = new UpToDateNodeStateConfiguration(store,
path);
-        assertNull(upToDateNodeStateConfiguration.getCoreName());
+        assertNotNull(upToDateNodeStateConfiguration.getSolrServerConfiguration());
     }
 
     @Test

Modified: jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java?rev=1486862&r1=1486861&r2=1486862&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrConfigurationProvider.java
Tue May 28 11:03:34 2013
@@ -34,7 +34,7 @@ import org.osgi.service.component.Compon
  * the default behavior that properties are indexed by name.
  * Possible extensions of this class may trigger type based property indexing / search.
  */
-@Component
+@Component(metatype = true)
 @Service(OakSolrConfigurationProvider.class)
 public class RemoteSolrConfigurationProvider implements OakSolrConfigurationProvider {
 
@@ -42,29 +42,23 @@ public class RemoteSolrConfigurationProv
     private static final String DEFAULT_CHILD_FIELD = "path_child";
     private static final String DEFAULT_PARENT_FIELD = "path_anc";
     private static final String DEFAULT_PATH_FIELD = "path_exact";
-    private static final String DEFAULT_CORE_NAME = "oak";
 
-    @Property(value = DEFAULT_DESC_FIELD)
+    @Property(value = DEFAULT_DESC_FIELD, name = "field for descendants search")
     private static final String PATH_DESCENDANTS_FIELD = "path.desc.field";
 
-    @Property(value = DEFAULT_CHILD_FIELD)
+    @Property(value = DEFAULT_CHILD_FIELD, name = "field for children search")
     private static final String PATH_CHILDREN_FIELD = "path.child.field";
 
-    @Property(value = DEFAULT_PARENT_FIELD)
+    @Property(value = DEFAULT_PARENT_FIELD, name = "field for parent search")
     private static final String PATH_PARENT_FIELD = "path.parent.field";
 
-    @Property(value = DEFAULT_PATH_FIELD)
+    @Property(value = DEFAULT_PATH_FIELD, name = "field for path search")
     private static final String PATH_EXACT_FIELD = "path.exact.field";
 
-    @Property(value = DEFAULT_CORE_NAME)
-    private static final String CORE_NAME = "core.name";
-
-
     private String pathChildrenFieldName;
     private String pathParentFieldName;
     private String pathDescendantsFieldName;
     private String pathExactFieldName;
-    private String coreName;
 
     private OakSolrConfiguration oakSolrConfiguration;
 
@@ -73,17 +67,14 @@ public class RemoteSolrConfigurationProv
         this.pathDescendantsFieldName = DEFAULT_DESC_FIELD;
         this.pathExactFieldName = DEFAULT_PATH_FIELD;
         this.pathParentFieldName = DEFAULT_PARENT_FIELD;
-        this.coreName = DEFAULT_CORE_NAME;
     }
 
     public RemoteSolrConfigurationProvider(String pathChildrenFieldName, String pathParentFieldName,
-                                           String pathDescendantsFieldName, String pathExactFieldName,
-                                           String coreName) {
+                                           String pathDescendantsFieldName, String pathExactFieldName)
{
         this.pathChildrenFieldName = pathChildrenFieldName;
         this.pathParentFieldName = pathParentFieldName;
         this.pathDescendantsFieldName = pathDescendantsFieldName;
         this.pathExactFieldName = pathExactFieldName;
-        this.coreName = coreName;
     }
 
     protected void activate(ComponentContext componentContext) throws Exception {
@@ -91,7 +82,6 @@ public class RemoteSolrConfigurationProv
         pathParentFieldName = String.valueOf(componentContext.getProperties().get(PATH_PARENT_FIELD));
         pathExactFieldName = String.valueOf(componentContext.getProperties().get(PATH_EXACT_FIELD));
         pathDescendantsFieldName = String.valueOf(componentContext.getProperties().get(PATH_DESCENDANTS_FIELD));
-        coreName = String.valueOf(componentContext.getProperties().get(CORE_NAME));
     }
 
     @Override
@@ -147,10 +137,6 @@ public class RemoteSolrConfigurationProv
                     return CommitPolicy.SOFT;
                 }
 
-                 @Override
-                public String getCoreName() {
-                    return coreName;
-                }
             };
         }
         return oakSolrConfiguration;

Modified: jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrServerProvider.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrServerProvider.java?rev=1486862&r1=1486861&r2=1486862&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrServerProvider.java
(original)
+++ jackrabbit/oak/trunk/oak-solr-remote/src/main/java/org/apache/jackrabbit/oak/plugins/index/solr/http/RemoteSolrServerProvider.java
Tue May 28 11:03:34 2013
@@ -46,36 +46,44 @@ public class RemoteSolrServerProvider im
     private static final String DEFAULT_HTTP_URL = "http://127.0.0.1:8983/solr";
     private static final String DEFAULT_ZK_HOST = "localhost:9983";
 
-    @Property(value = DEFAULT_HTTP_URL)
+    @Property(value = DEFAULT_HTTP_URL, name = "Default Solr HTTP URL")
     private static final String SOLR_HTTP_URL = "solr.http.url";
 
-    @Property(value = DEFAULT_ZK_HOST)
+    @Property(value = DEFAULT_ZK_HOST, name = "Zookeeper host")
     private static final String SOLR_ZK_HOST = "solr.zk.host";
 
+    @Property(value = DEFAULT_COLLECTION, name = "Default collection")
+    private static final String SOLR_COLLECTION = "solr.collection";
+
     private SolrServer solrServer;
     private String solrHttpUrl;
     private String solrZkHost;
+    private String solrCollection;
 
     public RemoteSolrServerProvider() {
         this.solrHttpUrl = DEFAULT_HTTP_URL;
         this.solrZkHost = DEFAULT_ZK_HOST;
+        this.solrCollection = DEFAULT_COLLECTION;
     }
 
-    public RemoteSolrServerProvider(String solrHttpUrl, String solrZkHost) {
+    public RemoteSolrServerProvider(String solrHttpUrl, String solrZkHost, String solrCollection)
{
         this.solrHttpUrl = solrHttpUrl;
         this.solrZkHost = solrZkHost;
+        this.solrCollection = solrCollection;
     }
 
     @Activate
     protected void activate(ComponentContext componentContext) throws Exception {
         solrHttpUrl = String.valueOf(componentContext.getProperties().get(SOLR_HTTP_URL));
         solrZkHost = String.valueOf(componentContext.getProperties().get(SOLR_ZK_HOST));
+        solrCollection = String.valueOf(componentContext.getProperties().get(SOLR_COLLECTION));
     }
 
     @Deactivate
     protected void deactivate() throws Exception {
         solrHttpUrl = null;
         solrZkHost = null;
+        solrCollection = null;
         if (solrServer != null) {
             solrServer.shutdown();
             solrServer = null;



Mime
View raw message