mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Checkin of remaining files for ALF-8793: "RSOLR 036: Update IndexChecker to call SOLR check APIs"
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29244 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -672,6 +672,7 @@ encryption.macAlgorithm=HmacSHA1
|
||||
|
||||
# SOLR connection details
|
||||
solr.solrHost=localhost
|
||||
solr.solrAdminPort=8834
|
||||
solr.solrUrl=http://${solr.solrHost}:8080/solr
|
||||
solr.solrUser=solr
|
||||
solr.solrPassword=solr
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
<!-- SOLR Tracking -->
|
||||
|
||||
<bean id="search.solrTrackingComponent" class="org.alfresco.repo.solr.SOLRTrackingComponentImpl" init-method="init">
|
||||
<bean id="solrTrackingComponent" class="org.alfresco.repo.solr.SOLRTrackingComponentImpl" init-method="init">
|
||||
<property name="permissionService" ref="permissionService"/>
|
||||
<property name="dictionaryService" ref="dictionaryService"/>
|
||||
<property name="ownableService" ref="ownableService"/>
|
||||
@@ -20,6 +20,23 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="solrTrackingMethodInterceptor" class="org.alfresco.repo.solr.SolrTrackingMethodInterceptor">
|
||||
</bean>
|
||||
|
||||
<bean id="search.solrTrackingComponent" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||
<property name="proxyInterfaces">
|
||||
<value>org.alfresco.repo.solr.SOLRTrackingComponent</value>
|
||||
</property>
|
||||
<property name="target">
|
||||
<ref bean="solrTrackingComponent"/>
|
||||
</property>
|
||||
<property name="interceptorNames">
|
||||
<list>
|
||||
<idref local="solrTrackingMethodInterceptor"/>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Query Register Component -->
|
||||
|
||||
<bean id="search.queryRegisterComponent" class="org.alfresco.repo.search.QueryRegisterComponentImpl">
|
||||
|
13
source/java/org/alfresco/repo/solr/SolrActiveEvent.java
Normal file
13
source/java/org/alfresco/repo/solr/SolrActiveEvent.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package org.alfresco.repo.solr;
|
||||
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
public class SolrActiveEvent extends ApplicationEvent
|
||||
{
|
||||
private static final long serialVersionUID = -7361024456694701653L;
|
||||
|
||||
public SolrActiveEvent(Object source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,66 @@
|
||||
package org.alfresco.repo.solr;
|
||||
|
||||
import java.util.concurrent.locks.ReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
|
||||
/**
|
||||
* A method interceptor that intercepts method calls on the {@link SOLRTrackingComponent}
|
||||
* in order to determine if a remote Solr instance is active. If so, an application event
|
||||
* is generated to indicate this.
|
||||
*
|
||||
* This is used by the Solr JMX code to export Solr mbeans only if the remote Solr instance
|
||||
* is active.
|
||||
*
|
||||
* since 4.0
|
||||
*
|
||||
*/
|
||||
public class SolrTrackingMethodInterceptor implements MethodInterceptor, ApplicationEventPublisherAware
|
||||
{
|
||||
private final WriteLock writeLock;
|
||||
private boolean solrActive = false;
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
public SolrTrackingMethodInterceptor()
|
||||
{
|
||||
ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
|
||||
writeLock = lock.writeLock();
|
||||
}
|
||||
|
||||
private void broadcastSolrActive()
|
||||
{
|
||||
applicationEventPublisher.publishEvent(new SolrActiveEvent(this));
|
||||
solrActive = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher)
|
||||
{
|
||||
this.applicationEventPublisher = applicationEventPublisher;
|
||||
}
|
||||
|
||||
public Object invoke(MethodInvocation mi) throws Throwable
|
||||
{
|
||||
writeLock.lock();
|
||||
try
|
||||
{
|
||||
if(!solrActive)
|
||||
{
|
||||
broadcastSolrActive();
|
||||
solrActive = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
writeLock.unlock();
|
||||
}
|
||||
|
||||
return mi.proceed();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user