mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix the build
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29348 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1012,13 +1012,14 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="solrAdminClient" class="org.alfresco.repo.solr.SOLRAdminClient" init-method="init">
|
<bean id="solrAdminClient" class="org.alfresco.repo.solr.SOLRAdminClient" init-method="init" destroy-method="shutdown">
|
||||||
<property name="solrHost" value="${solr.solrHost}"/>
|
<property name="solrHost" value="${solr.solrHost}"/>
|
||||||
<property name="solrPort" value="${solr.solrAdminPort}"/>
|
<property name="solrPort" value="${solr.solrAdminPort}"/>
|
||||||
<property name="solrUrl" value="${solr.solrUrl}"/>
|
<property name="solrUrl" value="${solr.solrUrl}"/>
|
||||||
<property name="solrUser" value="${solr.solrUser}"/>
|
<property name="solrUser" value="${solr.solrUser}"/>
|
||||||
<property name="solrPassword" value="${solr.solrPassword}"/>
|
<property name="solrPassword" value="${solr.solrPassword}"/>
|
||||||
<property name="solrPingCronExpression" value="${solr.solrPingCronExpression}"/>
|
<property name="solrPingCronExpression" value="${solr.solrPingCronExpression}"/>
|
||||||
|
<property name="solrConnectTimeout" value="${solr.solrConnectTimeout}"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="solr" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
|
<bean id="solr" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
|
||||||
|
@@ -692,7 +692,8 @@ solr.solrUrl=http://${solr.solrHost}:8080/solr
|
|||||||
solr.solrUser=solr
|
solr.solrUser=solr
|
||||||
solr.solrPassword=solr
|
solr.solrPassword=solr
|
||||||
solr.secureComms.enabled=true
|
solr.secureComms.enabled=true
|
||||||
|
# ms
|
||||||
|
solr.solrConnectTimeout=5000
|
||||||
solr.solrPingCronExpression=0 0/5 * * * ? *
|
solr.solrPingCronExpression=0 0/5 * * * ? *
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@@ -29,6 +29,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|||||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.apache.commons.httpclient.Credentials;
|
import org.apache.commons.httpclient.Credentials;
|
||||||
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
||||||
import org.apache.commons.httpclient.auth.AuthScope;
|
import org.apache.commons.httpclient.auth.AuthScope;
|
||||||
@@ -61,8 +62,9 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
private String solrUrl;
|
private String solrUrl;
|
||||||
private String solrUser;
|
private String solrUser;
|
||||||
private String solrPassword;
|
private String solrPassword;
|
||||||
private String solrPingCronExpression; // s
|
private String solrPingCronExpression;
|
||||||
private CommonsHttpSolrServer server;
|
private CommonsHttpSolrServer server;
|
||||||
|
private int solrConnectTimeout; // ms
|
||||||
|
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
private ApplicationEventPublisher applicationEventPublisher;
|
||||||
private SolrTracker solrTracker;
|
private SolrTracker solrTracker;
|
||||||
@@ -96,6 +98,11 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
this.solrPassword = solrPassword;
|
this.solrPassword = solrPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSolrConnectTimeout(String solrConnectTimeout)
|
||||||
|
{
|
||||||
|
this.solrConnectTimeout = Integer.parseInt(solrConnectTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
|
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
|
||||||
{
|
{
|
||||||
@@ -109,13 +116,21 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
|
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
|
ParameterCheck.mandatory("solrHost", solrHost);
|
||||||
|
ParameterCheck.mandatory("solrPort", solrPort);
|
||||||
|
ParameterCheck.mandatory("solrPassword", solrPassword);
|
||||||
|
ParameterCheck.mandatory("solrPingCronExpression", solrPingCronExpression);
|
||||||
|
ParameterCheck.mandatory("solrPort", solrPort);
|
||||||
|
ParameterCheck.mandatory("solrConnectTimeout", solrConnectTimeout);
|
||||||
|
ParameterCheck.mandatory("solrUser", solrUser);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
server = new CommonsHttpSolrServer(solrUrl);
|
server = new CommonsHttpSolrServer(solrUrl);
|
||||||
Credentials defaultcreds = new UsernamePasswordCredentials(solrUser, solrPassword);
|
Credentials defaultcreds = new UsernamePasswordCredentials(solrUser, solrPassword);
|
||||||
server.getHttpClient().getState().setCredentials(new AuthScope(solrHost, solrPort, AuthScope.ANY_REALM),
|
server.getHttpClient().getState().setCredentials(new AuthScope(solrHost, solrPort, AuthScope.ANY_REALM),
|
||||||
defaultcreds);
|
defaultcreds);
|
||||||
server.setConnectionTimeout(2000);
|
server.setConnectionTimeout(solrConnectTimeout);
|
||||||
|
|
||||||
this.solrTracker = new SolrTracker();
|
this.solrTracker = new SolrTracker();
|
||||||
}
|
}
|
||||||
@@ -125,6 +140,11 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown()
|
||||||
|
{
|
||||||
|
this.solrTracker.shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
public QueryResponse basicQuery(ModifiableSolrParams params)
|
public QueryResponse basicQuery(ModifiableSolrParams params)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -163,12 +183,12 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tracks the availablity of Solr.
|
* Tracks the availability of Solr.
|
||||||
*
|
*
|
||||||
* @since 4.0
|
* @since 4.0
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SolrTracker
|
class SolrTracker
|
||||||
{
|
{
|
||||||
private final WriteLock writeLock;
|
private final WriteLock writeLock;
|
||||||
private boolean solrActive = false;
|
private boolean solrActive = false;
|
||||||
@@ -178,7 +198,7 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
|
|
||||||
private List<String> cores;
|
private List<String> cores;
|
||||||
|
|
||||||
public SolrTracker()
|
SolrTracker()
|
||||||
{
|
{
|
||||||
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||||
writeLock = lock.writeLock();
|
writeLock = lock.writeLock();
|
||||||
@@ -217,7 +237,7 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSolrActive(boolean active)
|
void setSolrActive(boolean active)
|
||||||
{
|
{
|
||||||
boolean statusChanged = false;
|
boolean statusChanged = false;
|
||||||
|
|
||||||
@@ -258,7 +278,7 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSolrActive()
|
boolean isSolrActive()
|
||||||
{
|
{
|
||||||
return solrActive;
|
return solrActive;
|
||||||
}
|
}
|
||||||
@@ -276,7 +296,6 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
factory.initialize(properties);
|
factory.initialize(properties);
|
||||||
scheduler = factory.getScheduler();
|
scheduler = factory.getScheduler();
|
||||||
|
|
||||||
// TODO start and stop as needed?
|
|
||||||
scheduler.start();
|
scheduler.start();
|
||||||
|
|
||||||
JobDetail job = new JobDetail("SolrWatcher", "Solr", SOLRWatcherJob.class);
|
JobDetail job = new JobDetail("SolrWatcher", "Solr", SOLRWatcherJob.class);
|
||||||
@@ -286,7 +305,6 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
|
|
||||||
trigger = new CronTrigger("SolrWatcherTrigger", "Solr", solrPingCronExpression);
|
trigger = new CronTrigger("SolrWatcherTrigger", "Solr", solrPingCronExpression);
|
||||||
scheduler.scheduleJob(job, trigger);
|
scheduler.scheduleJob(job, trigger);
|
||||||
//stopTimer();
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
@@ -304,7 +322,19 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
scheduler.pauseTrigger(trigger.getName(), trigger.getGroup());
|
scheduler.pauseTrigger(trigger.getName(), trigger.getGroup());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCores(List<String> cores)
|
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();
|
writeLock.lock();
|
||||||
try
|
try
|
||||||
@@ -318,7 +348,7 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public List<String> getRegisteredCores()
|
List<String> getRegisteredCores()
|
||||||
{
|
{
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try
|
try
|
||||||
|
Reference in New Issue
Block a user