Clear up some error detection logic and error messages.
This commit is contained in:
parent
350faa50fa
commit
1c2b7f64d0
1 changed files with 22 additions and 14 deletions
|
@ -3,6 +3,7 @@
|
||||||
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
package edu.cornell.mannlib.vitro.webapp.search.solr;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -10,7 +11,6 @@ import java.util.List;
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.ServletContextEvent;
|
import javax.servlet.ServletContextEvent;
|
||||||
|
|
||||||
import org.apache.commons.httpclient.HttpClient;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.apache.solr.client.solrj.SolrServer;
|
import org.apache.solr.client.solrj.SolrServer;
|
||||||
|
@ -51,24 +51,33 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
|
||||||
ServletContext context = sce.getServletContext();
|
ServletContext context = sce.getServletContext();
|
||||||
StartupStatus ss = StartupStatus.getBean(context);
|
StartupStatus ss = StartupStatus.getBean(context);
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
/* setup the http connection with the solr server */
|
/* setup the http connection with the solr server */
|
||||||
String solrServerUrl = ConfigurationProperties.getBean(sce).getProperty("vitro.local.solr.url");
|
String solrServerUrlString = ConfigurationProperties.getBean(sce).getProperty("vitro.local.solr.url");
|
||||||
if( solrServerUrl == null ){
|
if( solrServerUrlString == null ){
|
||||||
log.error("Could not find vitro.local.solr.url in deploy.properties. "+
|
ss.fatal(this, "Could not find vitro.local.solr.url in deploy.properties. "+
|
||||||
"Vitro application needs a URL of a solr server that it can use to index its data. " +
|
"Vitro application needs a URL of a solr server that it can use to index its data. " +
|
||||||
"It should be something like http://localhost:${port}" + context.getContextPath() + "solr"
|
"It should be something like http://localhost:${port}" + context.getContextPath() + "solr"
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
URL solrServerUrl = null;
|
||||||
|
try {
|
||||||
|
solrServerUrl = new URL(solrServerUrlString);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
ss.fatal(this, "Can't connect with the solr server. " +
|
||||||
|
"The value for vitro.local.solr.url in deploy.properties is not a valid URL: " + solrServerUrlString);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
//HttpClient httpClient = new HttpClient();
|
//HttpClient httpClient = new HttpClient();
|
||||||
|
|
||||||
CommonsHttpSolrServer server;
|
CommonsHttpSolrServer server;
|
||||||
boolean useMultiPartPost = true;
|
boolean useMultiPartPost = true;
|
||||||
//It would be nice to use the default binary handler but there seem to be library problems
|
//It would be nice to use the default binary handler but there seem to be library problems
|
||||||
server = new CommonsHttpSolrServer(new URL( solrServerUrl ),null,new XMLResponseParser(),useMultiPartPost);
|
server = new CommonsHttpSolrServer(solrServerUrl,null,new XMLResponseParser(),useMultiPartPost);
|
||||||
server.setSoTimeout(10000); // socket read timeout
|
server.setSoTimeout(10000); // socket read timeout
|
||||||
server.setConnectionTimeout(10000);
|
server.setConnectionTimeout(10000);
|
||||||
server.setDefaultMaxConnectionsPerHost(100);
|
server.setDefaultMaxConnectionsPerHost(100);
|
||||||
|
@ -131,7 +140,6 @@ public class SolrSetup implements javax.servlet.ServletContextListener{
|
||||||
SearchReindexingListener srl = new SearchReindexingListener( builder );
|
SearchReindexingListener srl = new SearchReindexingListener( builder );
|
||||||
ModelContext.registerListenerForChanges(ctx, srl);
|
ModelContext.registerListenerForChanges(ctx, srl);
|
||||||
|
|
||||||
log.info("Setup of Solr index completed.");
|
|
||||||
ss.info(this, "Setup of Solr index completed.");
|
ss.info(this, "Setup of Solr index completed.");
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
ss.fatal(this, "could not setup local solr server",e);
|
ss.fatal(this, "could not setup local solr server",e);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue