Return-Path: X-Original-To: apmail-gora-commits-archive@www.apache.org Delivered-To: apmail-gora-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E9999114C7 for ; Mon, 9 Jun 2014 19:46:05 +0000 (UTC) Received: (qmail 78233 invoked by uid 500); 9 Jun 2014 19:46:05 -0000 Delivered-To: apmail-gora-commits-archive@gora.apache.org Received: (qmail 78192 invoked by uid 500); 9 Jun 2014 19:46:05 -0000 Mailing-List: contact commits-help@gora.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@gora.apache.org Delivered-To: mailing list commits@gora.apache.org Received: (qmail 78177 invoked by uid 99); 9 Jun 2014 19:46:05 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 Jun 2014 19:46:05 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 985B390146B; Mon, 9 Jun 2014 19:46:05 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lewismc@apache.org To: commits@gora.apache.org Date: Mon, 09 Jun 2014 19:46:05 -0000 Message-Id: <62b5195e59bd42b9ab913f71fa687a64@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [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 Authored: Mon Jun 9 15:44:59 2014 -0400 Committer: Lewis John McGibbney 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 extends DataStoreBase 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 extends DataStoreBase 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 extends DataStoreBase 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 extends DataStoreBase 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 @@ gora-compiler gora-compiler-cli gora-core - gora-hbase gora-accumulo gora-cassandra - gora-solr + gora-hbase + gora-mongodb + gora-solr gora-tutorial sources-dist