Fix for ACE-4575 SOLR 4 - Sharded - Backup should fail gracefully

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@117847 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2015-11-18 10:54:15 +00:00
parent 9425e15f90
commit 3d4f9a07c0
4 changed files with 54 additions and 1 deletions

View File

@@ -49,6 +49,9 @@
<property name="solrAdminClient">
<ref bean="solrAdminClient" />
</property>
<property name="solrQueryHTTPClient">
<ref bean="search.solrQueryHTTPCLient" />
</property>
</bean>
<!-- archive://SpacesStore - archive -->
@@ -98,6 +101,9 @@
<property name="solrAdminClient">
<ref bean="solrAdminClient" />
</property>
<property name="solrQueryHTTPClient">
<ref bean="search.solrQueryHTTPCLient" />
</property>
</bean>
</beans>

View File

@@ -52,6 +52,9 @@
<property name="fixNumberToKeepOffByOneError">
<value>true</value>
</property>
<property name="solrQueryHTTPClient">
<ref bean="search.solrQueryHTTPCLient" />
</property>
</bean>
<!-- archive://SpacesStore - archive -->
@@ -104,6 +107,9 @@
<property name="fixNumberToKeepOffByOneError">
<value>true</value>
</property>
<property name="solrQueryHTTPClient">
<ref bean="search.solrQueryHTTPCLient" />
</property>
</bean>
</beans>

View File

@@ -55,8 +55,8 @@ public class SolrBackupClient implements InitializingBean
private boolean fixNumberToKeepOffByOneError = false;
private SOLRAdminClient solrAdminClient;
private SolrQueryHTTPClient solrQueryHTTPClient;
/**
@@ -87,6 +87,11 @@ public class SolrBackupClient implements InitializingBean
this.remoteBackupLocation = remoteBackupLocation;
}
public void setSolrQueryHTTPClient(SolrQueryHTTPClient solrQueryHTTPClient)
{
this.solrQueryHTTPClient = solrQueryHTTPClient;
}
/**
* @param numberToKeep the numberToKeep to set
*/
@@ -97,6 +102,10 @@ public class SolrBackupClient implements InitializingBean
public void execute()
{
if(solrQueryHTTPClient.isSharded())
{
return;
}
String lockToken = getLock(60000);
if (lockToken == null)

View File

@@ -36,6 +36,7 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.opencmis.dictionary.CMISStrictDictionaryService;
import org.alfresco.repo.admin.RepositoryState;
import org.alfresco.repo.domain.node.NodeDAO;
import org.alfresco.repo.index.shard.Floc;
import org.alfresco.repo.index.shard.ShardInstance;
import org.alfresco.repo.index.shard.ShardRegistry;
import org.alfresco.repo.search.impl.lucene.JSONResult;
@@ -931,4 +932,35 @@ public class SolrQueryHTTPClient implements BeanFactoryAware, InitializingBean
throw new LuceneQueryParserException("", e);
}
}
/**
* @return
*/
public boolean isSharded()
{
if((shardRegistry != null) && useDynamicShardRegistration)
{
for( Floc floc : shardRegistry.getFlocs().keySet())
{
if(floc.getNumberOfShards() > 1)
{
return true;
}
}
return false;
}
else
{
for(SolrStoreMappingWrapper mapping : mappingLookup.values())
{
if(mapping.isSharded())
{
return true;
}
}
return false;
}
}
}