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>
|
||||
</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="solrPort" value="${solr.solrAdminPort}"/>
|
||||
<property name="solrUrl" value="${solr.solrUrl}"/>
|
||||
<property name="solrUser" value="${solr.solrUser}"/>
|
||||
<property name="solrPassword" value="${solr.solrPassword}"/>
|
||||
<property name="solrPingCronExpression" value="${solr.solrPingCronExpression}"/>
|
||||
<property name="solrConnectTimeout" value="${solr.solrConnectTimeout}"/>
|
||||
</bean>
|
||||
|
||||
<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.solrPassword=solr
|
||||
solr.secureComms.enabled=true
|
||||
|
||||
# ms
|
||||
solr.solrConnectTimeout=5000
|
||||
solr.solrPingCronExpression=0 0/5 * * * ? *
|
||||
|
||||
#
|
||||
|
@@ -29,6 +29,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.apache.commons.httpclient.Credentials;
|
||||
import org.apache.commons.httpclient.UsernamePasswordCredentials;
|
||||
import org.apache.commons.httpclient.auth.AuthScope;
|
||||
@@ -61,8 +62,9 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
private String solrUrl;
|
||||
private String solrUser;
|
||||
private String solrPassword;
|
||||
private String solrPingCronExpression; // s
|
||||
private String solrPingCronExpression;
|
||||
private CommonsHttpSolrServer server;
|
||||
private int solrConnectTimeout; // ms
|
||||
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
private SolrTracker solrTracker;
|
||||
@@ -95,6 +97,11 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
{
|
||||
this.solrPassword = solrPassword;
|
||||
}
|
||||
|
||||
public void setSolrConnectTimeout(String solrConnectTimeout)
|
||||
{
|
||||
this.solrConnectTimeout = Integer.parseInt(solrConnectTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
|
||||
@@ -109,13 +116,21 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
|
||||
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
|
||||
{
|
||||
server = new CommonsHttpSolrServer(solrUrl);
|
||||
Credentials defaultcreds = new UsernamePasswordCredentials(solrUser, solrPassword);
|
||||
server.getHttpClient().getState().setCredentials(new AuthScope(solrHost, solrPort, AuthScope.ANY_REALM),
|
||||
defaultcreds);
|
||||
server.setConnectionTimeout(2000);
|
||||
server.setConnectionTimeout(solrConnectTimeout);
|
||||
|
||||
this.solrTracker = new SolrTracker();
|
||||
}
|
||||
@@ -125,6 +140,11 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown()
|
||||
{
|
||||
this.solrTracker.shutdown();
|
||||
}
|
||||
|
||||
public QueryResponse basicQuery(ModifiableSolrParams params)
|
||||
{
|
||||
try
|
||||
@@ -163,12 +183,12 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
}
|
||||
|
||||
/**
|
||||
* Tracks the availablity of Solr.
|
||||
* Tracks the availability of Solr.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
*/
|
||||
public class SolrTracker
|
||||
class SolrTracker
|
||||
{
|
||||
private final WriteLock writeLock;
|
||||
private boolean solrActive = false;
|
||||
@@ -178,7 +198,7 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
|
||||
private List<String> cores;
|
||||
|
||||
public SolrTracker()
|
||||
SolrTracker()
|
||||
{
|
||||
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
writeLock = lock.writeLock();
|
||||
@@ -217,7 +237,7 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
}
|
||||
}
|
||||
|
||||
public void setSolrActive(boolean active)
|
||||
void setSolrActive(boolean active)
|
||||
{
|
||||
boolean statusChanged = false;
|
||||
|
||||
@@ -258,7 +278,7 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSolrActive()
|
||||
boolean isSolrActive()
|
||||
{
|
||||
return solrActive;
|
||||
}
|
||||
@@ -276,7 +296,6 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
factory.initialize(properties);
|
||||
scheduler = factory.getScheduler();
|
||||
|
||||
// TODO start and stop as needed?
|
||||
scheduler.start();
|
||||
|
||||
JobDetail job = new JobDetail("SolrWatcher", "Solr", SOLRWatcherJob.class);
|
||||
@@ -286,7 +305,6 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
|
||||
trigger = new CronTrigger("SolrWatcherTrigger", "Solr", solrPingCronExpression);
|
||||
scheduler.scheduleJob(job, trigger);
|
||||
//stopTimer();
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
@@ -304,7 +322,19 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
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();
|
||||
try
|
||||
@@ -318,7 +348,7 @@ public class SOLRAdminClient implements ApplicationEventPublisherAware
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getRegisteredCores()
|
||||
List<String> getRegisteredCores()
|
||||
{
|
||||
writeLock.lock();
|
||||
try
|
||||
|
Reference in New Issue
Block a user