mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ALF-19885 Solr continues working with the wrong data about host
- moved all beans, jmx etc inside the solr search sub-system git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55568 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1079,30 +1079,6 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="solrHttpClientFactory" class="org.alfresco.httpclient.HttpClientFactory" init-method="init">
|
||||
<property name="secureCommsType" value="${solr.secureComms}"/>
|
||||
<property name="sSLEncryptionParameters" ref="sslEncryptionParameters"/>
|
||||
<property name="keyResourceLoader" ref="springKeyResourceLoader"/>
|
||||
<property name="keyStoreParameters" ref="keyStoreParameters"/>
|
||||
<property name="encryptionParameters" ref="md5EncryptionParameters"/>
|
||||
<property name="host" value="${solr.host}"/>
|
||||
<property name="port" value="${solr.port}"/>
|
||||
<property name="sslPort" value="${solr.port.ssl}"/>
|
||||
<property name="maxTotalConnections" value="${solr.max.total.connections}"/>
|
||||
<property name="maxHostConnections" value="${solr.max.host.connections}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="solrAdminClient" class="org.alfresco.repo.solr.SOLRAdminClient" init-method="init" destroy-method="shutdown">
|
||||
<property name="solrHost" value="${solr.host}"/>
|
||||
<property name="solrPort" value="${solr.port}"/>
|
||||
<property name="solrsslPort" value="${solr.port.ssl}"/>
|
||||
<property name="solrUser" value="${solr.solrUser}"/>
|
||||
<property name="solrPassword" value="${solr.solrPassword}"/>
|
||||
<property name="solrPingCronExpression" value="${solr.solrPingCronExpression}"/>
|
||||
<property name="solrConnectTimeout" value="${solr.solrConnectTimeout}"/>
|
||||
<property name="httpClientFactory" ref="solrHttpClientFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="solr" class="org.alfresco.repo.search.impl.solr.SolrChildApplicationContextFactory" parent="abstractPropertyBackedBean">
|
||||
<property name="autoStart">
|
||||
<value>false</value>
|
||||
|
@@ -111,6 +111,34 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="solrHttpClientFactory" class="org.alfresco.httpclient.HttpClientFactory" init-method="init">
|
||||
<property name="secureCommsType" value="${solr.secureComms}"/>
|
||||
<property name="sSLEncryptionParameters" ref="sslEncryptionParameters"/>
|
||||
<property name="keyResourceLoader" ref="springKeyResourceLoader"/>
|
||||
<property name="keyStoreParameters" ref="keyStoreParameters"/>
|
||||
<property name="encryptionParameters" ref="md5EncryptionParameters"/>
|
||||
<property name="host" value="${solr.host}"/>
|
||||
<property name="port" value="${solr.port}"/>
|
||||
<property name="sslPort" value="${solr.port.ssl}"/>
|
||||
<property name="maxTotalConnections" value="${solr.max.total.connections}"/>
|
||||
<property name="maxHostConnections" value="${solr.max.host.connections}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="solrAdminClient" class="org.alfresco.repo.solr.SOLRAdminClient" init-method="init">
|
||||
<property name="solrHost" value="${solr.host}"/>
|
||||
<property name="solrPort" value="${solr.port}"/>
|
||||
<property name="solrsslPort" value="${solr.port.ssl}"/>
|
||||
<property name="solrUser" value="${solr.solrUser}"/>
|
||||
<property name="solrPassword" value="${solr.solrPassword}"/>
|
||||
<property name="solrPingCronExpression" value="${solr.solrPingCronExpression}"/>
|
||||
<property name="solrConnectTimeout" value="${solr.solrConnectTimeout}"/>
|
||||
<property name="httpClientFactory" ref="solrHttpClientFactory"/>
|
||||
<property name="scheduler">
|
||||
<ref bean="searchSchedulerFactory" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<bean id="search.solrAdminHTTPCLient" class="org.alfresco.repo.search.impl.solr.SolrAdminHTTPClient" init-method="init">
|
||||
<property name="httpClientFactory" ref="solrHttpClientFactory"/>
|
||||
</bean>
|
||||
|
@@ -24,7 +24,6 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
|
||||
@@ -46,7 +45,7 @@ import org.quartz.JobDetail;
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.quartz.Trigger;
|
||||
import org.quartz.impl.StdSchedulerFactory;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
|
||||
@@ -57,7 +56,7 @@ import org.springframework.context.ApplicationEventPublisherAware;
|
||||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
public class SOLRAdminClient implements ApplicationEventPublisherAware, DisposableBean
|
||||
{
|
||||
private String solrHost;
|
||||
private int solrPort;
|
||||
@@ -67,12 +66,13 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
private String solrPassword;
|
||||
private String solrPingCronExpression;
|
||||
private CommonsHttpSolrServer server;
|
||||
private int solrConnectTimeout; // ms
|
||||
private int solrConnectTimeout = 30000; // ms
|
||||
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
private SolrTracker solrTracker;
|
||||
|
||||
private HttpClientFactory httpClientFactory;
|
||||
private Scheduler scheduler;
|
||||
|
||||
public SOLRAdminClient()
|
||||
{
|
||||
@@ -124,6 +124,14 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
this.httpClientFactory = httpClientFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param scheduler the scheduler to set
|
||||
*/
|
||||
public void setScheduler(Scheduler scheduler)
|
||||
{
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
ParameterCheck.mandatory("solrHost", solrHost);
|
||||
@@ -150,8 +158,9 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
server.getHttpClient().getState().setCredentials(new AuthScope(solrHost, solrPort, AuthScope.ANY_REALM),
|
||||
defaultcreds);
|
||||
server.setConnectionTimeout(solrConnectTimeout);
|
||||
server.setSoTimeout(20000);
|
||||
|
||||
this.solrTracker = new SolrTracker();
|
||||
this.solrTracker = new SolrTracker(scheduler);
|
||||
}
|
||||
catch(MalformedURLException e)
|
||||
{
|
||||
@@ -159,11 +168,6 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
this.solrTracker.shutdown();
|
||||
}
|
||||
|
||||
public QueryResponse basicQuery(ModifiableSolrParams params)
|
||||
{
|
||||
try
|
||||
@@ -217,8 +221,9 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
|
||||
private List<String> cores;
|
||||
|
||||
SolrTracker()
|
||||
SolrTracker(Scheduler scheduler)
|
||||
{
|
||||
this.scheduler = scheduler;
|
||||
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
writeLock = lock.writeLock();
|
||||
|
||||
@@ -306,19 +311,6 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
{
|
||||
try
|
||||
{
|
||||
StdSchedulerFactory factory = new StdSchedulerFactory();
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("org.quartz.scheduler.instanceName", "SolrWatcherScheduler");
|
||||
properties.setProperty("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool");
|
||||
properties.setProperty("org.quartz.threadPool.threadCount", "3");
|
||||
properties.setProperty("org.quartz.threadPool.makeThreadsDaemons", "true");
|
||||
properties.setProperty("org.quartz.scheduler.makeSchedulerThreadDaemon", "true");
|
||||
properties.setProperty("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
|
||||
factory.initialize(properties);
|
||||
scheduler = factory.getScheduler();
|
||||
|
||||
scheduler.start();
|
||||
|
||||
final String jobName = "SolrWatcher";
|
||||
final String jobGroup = "Solr";
|
||||
|
||||
@@ -356,18 +348,6 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
scheduler.pauseTrigger(trigger.getName(), trigger.getGroup());
|
||||
}
|
||||
|
||||
void shutdown()
|
||||
{
|
||||
try
|
||||
{
|
||||
scheduler.shutdown();
|
||||
}
|
||||
catch(SchedulerException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unable to shut down Solr Tracker cleanly", e);
|
||||
}
|
||||
}
|
||||
|
||||
void registerCores(List<String> cores)
|
||||
{
|
||||
writeLock.lock();
|
||||
@@ -396,4 +376,13 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.springframework.beans.factory.DisposableBean#destroy()
|
||||
*/
|
||||
@Override
|
||||
public void destroy() throws Exception
|
||||
{
|
||||
solrTracker.stopTimer();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user