You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gora.apache.org by le...@apache.org on 2014/06/09 21:46:05 UTC

[1/2] git commit: Make Solrj solr server impl configurable from within gora.properties

Repository: gora
Updated Branches:
  refs/heads/master 8bdb4559e -> a497d14c1


Make Solrj solr server impl configurable from within gora.properties


Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/5f55f9e5
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/5f55f9e5
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/5f55f9e5

Branch: refs/heads/master
Commit: 5f55f9e57cde7a85a9bd86fc9c7184fa182aa819
Parents: 740253c
Author: Lewis John McGibbney <le...@jpl.nasa.gov>
Authored: Mon Jun 9 15:44:59 2014 -0400
Committer: Lewis John McGibbney <le...@jpl.nasa.gov>
Committed: Mon Jun 9 15:44:59 2014 -0400

----------------------------------------------------------------------
 gora-hbase/src/test/conf/gora.properties        | 14 +++++
 .../org/apache/gora/solr/store/SolrStore.java   | 54 ++++++++++++++++++--
 gora-solr/src/test/conf/gora.properties         | 17 ++++++
 gora-tutorial/conf/gora.properties              |  2 +-
 pom.xml                                         |  5 +-
 5 files changed, 84 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/gora/blob/5f55f9e5/gora-hbase/src/test/conf/gora.properties
----------------------------------------------------------------------
diff --git a/gora-hbase/src/test/conf/gora.properties b/gora-hbase/src/test/conf/gora.properties
index 58bfa47..8cb2c32 100644
--- a/gora-hbase/src/test/conf/gora.properties
+++ b/gora-hbase/src/test/conf/gora.properties
@@ -1,3 +1,17 @@
+# 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.
 
 #Datastore is configured programatically in the tests
 #gora.datastore.default=

http://git-wip-us.apache.org/repos/asf/gora/blob/5f55f9e5/gora-solr/src/main/java/org/apache/gora/solr/store/SolrStore.java
----------------------------------------------------------------------
diff --git a/gora-solr/src/main/java/org/apache/gora/solr/store/SolrStore.java b/gora-solr/src/main/java/org/apache/gora/solr/store/SolrStore.java
index 46a3386..74aaeb6 100644
--- a/gora-solr/src/main/java/org/apache/gora/solr/store/SolrStore.java
+++ b/gora-solr/src/main/java/org/apache/gora/solr/store/SolrStore.java
@@ -15,6 +15,7 @@
 package org.apache.gora.solr.store;
 
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -41,9 +42,13 @@ import org.apache.gora.store.DataStoreFactory;
 import org.apache.gora.store.impl.DataStoreBase;
 import org.apache.gora.util.AvroUtils;
 import org.apache.gora.util.IOUtils;
+import org.apache.hadoop.util.StringUtils;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.CloudSolrServer;
+import org.apache.solr.client.solrj.impl.ConcurrentUpdateSolrServer;
 import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.client.solrj.impl.LBHttpSolrServer;
 import org.apache.solr.client.solrj.request.CoreAdminRequest;
 import org.apache.solr.client.solrj.response.CoreAdminResponse;
 import org.apache.solr.client.solrj.response.QueryResponse;
@@ -72,7 +77,7 @@ public class SolrStore<K, T extends PersistentBase> extends DataStoreBase<K, T>
 
   protected static final String SOLR_BATCH_SIZE_PROPERTY = "solr.batchSize";
 
-  // protected static final String SOLR_SOLRJSERVER_IMPL = "solr.solrjserver";
+  protected static final String SOLR_SOLRJSERVER_IMPL = "solr.solrjserver";
 
   protected static final String SOLR_COMMIT_WITHIN_PROPERTY = "solr.commitWithin";
 
@@ -86,7 +91,7 @@ public class SolrStore<K, T extends PersistentBase> extends DataStoreBase<K, T>
 
   private SolrMapping mapping;
 
-  private String solrServerUrl, solrConfig, solrSchema;
+  private String solrServerUrl, solrConfig, solrSchema, solrJServerImpl;
 
   private SolrServer server, adminServer;
 
@@ -134,9 +139,48 @@ public class SolrStore<K, T extends PersistentBase> extends DataStoreBase<K, T>
         SOLR_CONFIG_PROPERTY, null);
     solrSchema = DataStoreFactory.findProperty(properties, this,
         SOLR_SCHEMA_PROPERTY, null);
+    solrJServerImpl = DataStoreFactory.findProperty(properties, this, 
+        SOLR_SOLRJSERVER_IMPL, "http");
     LOG.info("Using Solr server at " + solrServerUrl);
-    adminServer = new HttpSolrServer(solrServerUrl);
-    server = new HttpSolrServer(solrServerUrl + "/" + mapping.getCoreName());
+    String solrJServerType = ((solrJServerImpl == null || solrJServerImpl.equals(""))?"http":solrJServerImpl);
+    // HttpSolrServer - denoted by "http" in properties
+    if (solrJServerType.toString().toLowerCase().equals("http")) {
+      LOG.info("Using HttpSolrServer Solrj implementation.");
+      this.adminServer = new HttpSolrServer(solrServerUrl);
+      this.server = new HttpSolrServer( solrServerUrl + "/" + mapping.getCoreName() );
+      // CloudSolrServer - denoted by "cloud" in properties
+    } else if (solrJServerType.toString().toLowerCase().equals("cloud")) {
+      LOG.info("Using CloudSolrServer Solrj implementation.");
+      try {
+        this.adminServer = new CloudSolrServer(solrServerUrl);
+      } catch (MalformedURLException e) {
+        e.printStackTrace();
+      }
+      try {
+        this.server = new CloudSolrServer( solrServerUrl + "/" + mapping.getCoreName() );
+      } catch (MalformedURLException e) {
+        e.printStackTrace();
+      }
+      // ConcurrentUpdateSolrServer - denoted by "concurrent" in properties
+    } else if (solrJServerType.toString().toLowerCase().equals("concurrent")) {
+      LOG.info("Using ConcurrentUpdateSolrServer Solrj implementation.");
+      this.adminServer = new ConcurrentUpdateSolrServer(solrServerUrl, 1000, 10);
+      this.server = new ConcurrentUpdateSolrServer( solrServerUrl + "/" + mapping.getCoreName(), 1000, 10);
+      // LBHttpSolrServer - denoted by "loadbalance" in properties
+    } else if (solrJServerType.toString().toLowerCase().equals("loadbalance")) {
+      LOG.info("Using LBHttpSolrServer Solrj implementation.");
+      String[] solrUrlElements = StringUtils.split(solrServerUrl);
+      try {
+        this.adminServer = new LBHttpSolrServer(solrUrlElements);
+      } catch (MalformedURLException e) {
+        e.printStackTrace();
+      }
+      try {
+        this.server = new LBHttpSolrServer( solrUrlElements + "/" + mapping.getCoreName() );
+      } catch (MalformedURLException e) {
+        e.printStackTrace();
+      }
+    }
     if (autoCreateSchema) {
       createSchema();
     }
@@ -473,7 +517,7 @@ public class SolrStore<K, T extends PersistentBase> extends DataStoreBase<K, T>
       doc.addField(sf, v);
 
     }
-    LOG.info("DOCUMENT: " + doc);
+    LOG.info("Putting DOCUMENT: " + doc);
     batch.add(doc);
     if (batch.size() >= batchSize) {
       try {

http://git-wip-us.apache.org/repos/asf/gora/blob/5f55f9e5/gora-solr/src/test/conf/gora.properties
----------------------------------------------------------------------
diff --git a/gora-solr/src/test/conf/gora.properties b/gora-solr/src/test/conf/gora.properties
index 2fcddaf..d64e267 100644
--- a/gora-solr/src/test/conf/gora.properties
+++ b/gora-solr/src/test/conf/gora.properties
@@ -1,2 +1,19 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+gora.solrstore.solr.solrjserver=http
+# 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.
+
 gora.solrstore.solr.url=http://localhost:9876/solr
 gora.datastore.solr.commitWithin=0
+gora.solrstore.solr.solrjserver=http

http://git-wip-us.apache.org/repos/asf/gora/blob/5f55f9e5/gora-tutorial/conf/gora.properties
----------------------------------------------------------------------
diff --git a/gora-tutorial/conf/gora.properties b/gora-tutorial/conf/gora.properties
index bed90f4..2e5c113 100644
--- a/gora-tutorial/conf/gora.properties
+++ b/gora-tutorial/conf/gora.properties
@@ -50,5 +50,5 @@ gora.solrstore.solr.commitwithin=0
 gora.solrstore.solr.batchsize=100
 # set which Solrj server impl you wish to use 
 # cloud, concurrent, http, loadbalance
-#gora.solrstore.solr.solrjserver=http
+gora.solrstore.solr.solrjserver=http
 

http://git-wip-us.apache.org/repos/asf/gora/blob/5f55f9e5/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 0396ee4..a89f5af 100644
--- a/pom.xml
+++ b/pom.xml
@@ -584,13 +584,14 @@
         <module>gora-compiler</module>
         <module>gora-compiler-cli</module>
         <module>gora-core</module>
-        <module>gora-hbase</module>
         <module>gora-accumulo</module>
         <module>gora-cassandra</module>
-        <module>gora-solr</module>
+        <module>gora-hbase</module>
+        <!--module>gora-lucene</module-->
         <!--module>gora-dynamodb</module-->
         <!--module>gora-sql</module-->
         <module>gora-mongodb</module>
+        <module>gora-solr</module>
         <module>gora-tutorial</module>
         <module>sources-dist</module>
     </modules>


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/gora

Posted by le...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/gora


Project: http://git-wip-us.apache.org/repos/asf/gora/repo
Commit: http://git-wip-us.apache.org/repos/asf/gora/commit/a497d14c
Tree: http://git-wip-us.apache.org/repos/asf/gora/tree/a497d14c
Diff: http://git-wip-us.apache.org/repos/asf/gora/diff/a497d14c

Branch: refs/heads/master
Commit: a497d14c1bb59672954d5f16e91154ac8dc5a726
Parents: 5f55f9e 8bdb455
Author: Lewis John McGibbney <le...@jpl.nasa.gov>
Authored: Mon Jun 9 15:45:29 2014 -0400
Committer: Lewis John McGibbney <le...@jpl.nasa.gov>
Committed: Mon Jun 9 15:45:29 2014 -0400

----------------------------------------------------------------------
 .../java/org/apache/gora/examples/TestWebPageDataCreator.java     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------