From 3d4f9a07c01473860f2b090c6ce1b0bb70f1b02b Mon Sep 17 00:00:00 2001 From: Andrew Hind Date: Wed, 18 Nov 2015 10:54:15 +0000 Subject: [PATCH] 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 --- .../Search/solr/solr-backup-context.xml | 6 ++++ .../Search/solr4/solr-backup-context.xml | 6 ++++ .../search/impl/solr/SolrBackupClient.java | 11 ++++++- .../search/impl/solr/SolrQueryHTTPClient.java | 32 +++++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) diff --git a/config/alfresco/subsystems/Search/solr/solr-backup-context.xml b/config/alfresco/subsystems/Search/solr/solr-backup-context.xml index 7e031d0927..2c4259b85a 100644 --- a/config/alfresco/subsystems/Search/solr/solr-backup-context.xml +++ b/config/alfresco/subsystems/Search/solr/solr-backup-context.xml @@ -49,6 +49,9 @@ + + + @@ -98,6 +101,9 @@ + + + \ No newline at end of file diff --git a/config/alfresco/subsystems/Search/solr4/solr-backup-context.xml b/config/alfresco/subsystems/Search/solr4/solr-backup-context.xml index e15522e030..652cfe0077 100644 --- a/config/alfresco/subsystems/Search/solr4/solr-backup-context.xml +++ b/config/alfresco/subsystems/Search/solr4/solr-backup-context.xml @@ -52,6 +52,9 @@ true + + + @@ -104,6 +107,9 @@ true + + + \ No newline at end of file diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrBackupClient.java b/source/java/org/alfresco/repo/search/impl/solr/SolrBackupClient.java index 2ca30100bf..ea138f95b7 100644 --- a/source/java/org/alfresco/repo/search/impl/solr/SolrBackupClient.java +++ b/source/java/org/alfresco/repo/search/impl/solr/SolrBackupClient.java @@ -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) diff --git a/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java b/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java index 2aef3e8fab..13b3491daf 100644 --- a/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java +++ b/source/java/org/alfresco/repo/search/impl/solr/SolrQueryHTTPClient.java @@ -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; + } + + } }