-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ALFREDOPS-864] bug fix for integration tests
- Loading branch information
Showing
14 changed files
with
212 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 14 additions & 38 deletions
52
.../main/java/eu/xenit/alfresco/healthprocessor/fixer/solr/SolrDuplicateNodeFixerPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,18 @@ | ||
package eu.xenit.alfresco.healthprocessor.fixer.solr; | ||
|
||
import eu.xenit.alfresco.healthprocessor.fixer.api.NodeFixReport; | ||
import eu.xenit.alfresco.healthprocessor.fixer.api.NodeFixStatus; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.NodeIndexHealthReport; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.NodeIndexHealthReport.IndexHealthStatus; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.SolrRequestExecutor; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.SolrRequestExecutor.SolrNodeCommand; | ||
import eu.xenit.alfresco.healthprocessor.reporter.api.NodeHealthReport; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import eu.xenit.alfresco.healthprocessor.fixer.api.ToggleableHealthFixerPlugin; | ||
|
||
public class SolrDuplicateNodeFixerPlugin extends AbstractSolrNodeFixerPlugin { | ||
/** | ||
* <p> | ||
* Interface representation of the {@link SolrDuplicateNodeFixerPluginImpl} class. | ||
* </p> | ||
* <p> | ||
* The reason for tbe existence this interface is to allow the {@link org.alfresco.repo.management.subsystems.SubsystemProxyFactory} | ||
* to create a proxy of the {@link SolrDuplicateNodeFixerPluginImpl} class from the health processor application context | ||
* in the main application context. | ||
* This proxy is only used as part of the integration tests from the health processor repo. | ||
* </p> | ||
*/ | ||
public interface SolrDuplicateNodeFixerPlugin extends ToggleableHealthFixerPlugin { | ||
|
||
public SolrDuplicateNodeFixerPlugin(SolrRequestExecutor solrRequestExecutor) { | ||
super(solrRequestExecutor); | ||
} | ||
|
||
@Override | ||
protected Set<NodeFixReport> handleHealthReport(NodeHealthReport unhealthyReport, | ||
NodeIndexHealthReport endpointHealthReport) { | ||
if (endpointHealthReport.getHealthStatus() != IndexHealthStatus.DUPLICATE) { | ||
return Collections.emptySet(); | ||
} | ||
// When a duplicate node is detected, purge it from the index and reindex it | ||
// According to MetadataTracker#maintenance(), purge is processed before reindex | ||
// Even if it is executed in the same maintenance cycle. | ||
// Ref: https://github.com/Alfresco/SearchServices/blob/e7f05e2f13a709cd28afa3ae6acfd3d0000b22ff/search-services/alfresco-search/src/main/java/org/alfresco/solr/tracker/MetadataTracker.java#L257-L266 | ||
// Purge has to be done before reindex, else we end up with a broken index which will only be fixed | ||
// by a subsequent health processor cycle, which would be unacceptable. | ||
Set<NodeFixReport> fixReports = new HashSet<>(); | ||
NodeFixReport purgeStatus = trySendSolrCommand(unhealthyReport, endpointHealthReport, SolrNodeCommand.PURGE); | ||
fixReports.add(purgeStatus); | ||
if(purgeStatus.getFixStatus() == NodeFixStatus.SUCCEEDED) { | ||
fixReports.add(trySendSolrCommand(unhealthyReport, endpointHealthReport, SolrNodeCommand.REINDEX)); | ||
} | ||
|
||
return fixReports; | ||
} | ||
|
||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...n/java/eu/xenit/alfresco/healthprocessor/fixer/solr/SolrDuplicateNodeFixerPluginImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package eu.xenit.alfresco.healthprocessor.fixer.solr; | ||
|
||
import eu.xenit.alfresco.healthprocessor.fixer.api.NodeFixReport; | ||
import eu.xenit.alfresco.healthprocessor.fixer.api.NodeFixStatus; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.NodeIndexHealthReport; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.NodeIndexHealthReport.IndexHealthStatus; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.SolrRequestExecutor; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.SolrRequestExecutor.SolrNodeCommand; | ||
import eu.xenit.alfresco.healthprocessor.reporter.api.NodeHealthReport; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public class SolrDuplicateNodeFixerPluginImpl extends AbstractSolrNodeFixerPlugin implements SolrDuplicateNodeFixerPlugin { | ||
|
||
public SolrDuplicateNodeFixerPluginImpl(SolrRequestExecutor solrRequestExecutor) { | ||
super(solrRequestExecutor); | ||
} | ||
|
||
@Override | ||
protected Set<NodeFixReport> handleHealthReport(NodeHealthReport unhealthyReport, | ||
NodeIndexHealthReport endpointHealthReport) { | ||
if (endpointHealthReport.getHealthStatus() != IndexHealthStatus.DUPLICATE) { | ||
return Collections.emptySet(); | ||
} | ||
// When a duplicate node is detected, purge it from the index and reindex it | ||
// According to MetadataTracker#maintenance(), purge is processed before reindex | ||
// Even if it is executed in the same maintenance cycle. | ||
// Ref: https://github.com/Alfresco/SearchServices/blob/e7f05e2f13a709cd28afa3ae6acfd3d0000b22ff/search-services/alfresco-search/src/main/java/org/alfresco/solr/tracker/MetadataTracker.java#L257-L266 | ||
// Purge has to be done before reindex, else we end up with a broken index which will only be fixed | ||
// by a subsequent health processor cycle, which would be unacceptable. | ||
Set<NodeFixReport> fixReports = new HashSet<>(); | ||
NodeFixReport purgeStatus = trySendSolrCommand(unhealthyReport, endpointHealthReport, SolrNodeCommand.PURGE); | ||
fixReports.add(purgeStatus); | ||
if(purgeStatus.getFixStatus() == NodeFixStatus.SUCCEEDED) { | ||
fixReports.add(trySendSolrCommand(unhealthyReport, endpointHealthReport, SolrNodeCommand.REINDEX)); | ||
} | ||
|
||
return fixReports; | ||
} | ||
|
||
} |
88 changes: 14 additions & 74 deletions
88
...rc/main/java/eu/xenit/alfresco/healthprocessor/fixer/solr/SolrMissingNodeFixerPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,18 @@ | ||
package eu.xenit.alfresco.healthprocessor.fixer.solr; | ||
|
||
import eu.xenit.alfresco.healthprocessor.fixer.api.NodeFixReport; | ||
import eu.xenit.alfresco.healthprocessor.fixer.api.NodeFixStatus; | ||
import eu.xenit.alfresco.healthprocessor.plugins.api.HealthProcessorPlugin; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.NodeIndexHealthReport; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.NodeIndexHealthReport.IndexHealthStatus; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.SolrRequestExecutor; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.SolrRequestExecutor.SolrNodeCommand; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.endpoint.SearchEndpoint; | ||
import eu.xenit.alfresco.healthprocessor.reporter.api.NodeHealthReport; | ||
import lombok.Value; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.alfresco.service.cmr.repository.NodeRef; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
@Slf4j | ||
public class SolrMissingNodeFixerPlugin extends AbstractSolrNodeFixerPlugin { | ||
private Map<SearchEndpointTxId, NodeFixReport> searchEndpointTxCache = new HashMap<>(); | ||
|
||
public SolrMissingNodeFixerPlugin(SolrRequestExecutor solrRequestExecutor) { | ||
super(solrRequestExecutor); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Set<NodeFixReport> fix(Class<? extends HealthProcessorPlugin> pluginClass, | ||
Set<NodeHealthReport> unhealthyReports) { | ||
clearCache(); | ||
return super.fix(pluginClass, unhealthyReports); | ||
} | ||
|
||
@Override | ||
protected Set<NodeFixReport> handleHealthReport(NodeHealthReport unhealthyReport, | ||
NodeIndexHealthReport endpointHealthReport) { | ||
if (endpointHealthReport.getHealthStatus() != IndexHealthStatus.NOT_FOUND) { | ||
return Collections.emptySet(); | ||
} | ||
|
||
NodeRef.Status nodeStatus = endpointHealthReport.getNodeRefStatus(); | ||
SearchEndpointTxId searchEndpointTxId = new SearchEndpointTxId(endpointHealthReport.getEndpoint(), nodeStatus.getDbTxnId()); | ||
if (searchEndpointTxCache.containsKey(searchEndpointTxId)) { | ||
NodeFixReport cachedNodeFixReport = searchEndpointTxCache.get(searchEndpointTxId); | ||
log.trace("We already have a fix report for {}: {}", searchEndpointTxId, cachedNodeFixReport); | ||
//If a successful reindex action was already sent for this tx to this endpoint, do not schedule another one | ||
if (cachedNodeFixReport.getFixStatus() == NodeFixStatus.SUCCEEDED) { | ||
log.trace("Fix for TX of {} has already succeeded, sending existing fix report messages.", unhealthyReport); | ||
return Collections.singleton(new NodeFixReport(cachedNodeFixReport.getFixStatus(), unhealthyReport, | ||
cachedNodeFixReport.getMessages())); | ||
} | ||
} | ||
|
||
log.trace("Performing reindex for {}", searchEndpointTxId); | ||
|
||
// Action not yet (successfully) sent | ||
NodeFixReport nodeFixReport = trySendSolrCommand(unhealthyReport, endpointHealthReport, | ||
SolrNodeCommand.REINDEX_TRANSACTION); | ||
|
||
searchEndpointTxCache.put(searchEndpointTxId, nodeFixReport); | ||
return Collections.singleton(nodeFixReport); | ||
} | ||
|
||
@Value | ||
public static class SearchEndpointTxId { | ||
private final SearchEndpoint searchEndpoint; | ||
private final Long txId; | ||
} | ||
|
||
private void clearCache() { | ||
searchEndpointTxCache.clear(); | ||
} | ||
import eu.xenit.alfresco.healthprocessor.fixer.api.ToggleableHealthFixerPlugin; | ||
|
||
/** | ||
* <p> | ||
* Interface representation of the {@link SolrMissingNodeFixerPluginImpl} class. | ||
* </p> | ||
* <p> | ||
* The reason for tbe existence this interface is to allow the {@link org.alfresco.repo.management.subsystems.SubsystemProxyFactory} | ||
* to create a proxy of the {@link SolrMissingNodeFixerPluginImpl} class from the health processor application context | ||
* in the main application context. | ||
* This proxy is only used as part of the integration tests from the health processor repo. | ||
* </p> | ||
*/ | ||
public interface SolrMissingNodeFixerPlugin extends ToggleableHealthFixerPlugin { | ||
|
||
} |
79 changes: 79 additions & 0 deletions
79
...ain/java/eu/xenit/alfresco/healthprocessor/fixer/solr/SolrMissingNodeFixerPluginImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package eu.xenit.alfresco.healthprocessor.fixer.solr; | ||
|
||
import eu.xenit.alfresco.healthprocessor.fixer.api.NodeFixReport; | ||
import eu.xenit.alfresco.healthprocessor.fixer.api.NodeFixStatus; | ||
import eu.xenit.alfresco.healthprocessor.plugins.api.HealthProcessorPlugin; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.NodeIndexHealthReport; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.NodeIndexHealthReport.IndexHealthStatus; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.SolrRequestExecutor; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.SolrRequestExecutor.SolrNodeCommand; | ||
import eu.xenit.alfresco.healthprocessor.plugins.solr.endpoint.SearchEndpoint; | ||
import eu.xenit.alfresco.healthprocessor.reporter.api.NodeHealthReport; | ||
import lombok.Value; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.alfresco.service.cmr.repository.NodeRef; | ||
|
||
import javax.annotation.Nonnull; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
@Slf4j | ||
public class SolrMissingNodeFixerPluginImpl extends AbstractSolrNodeFixerPlugin implements SolrMissingNodeFixerPlugin { | ||
|
||
private Map<SearchEndpointTxId, NodeFixReport> searchEndpointTxCache = new HashMap<>(); | ||
|
||
public SolrMissingNodeFixerPluginImpl(SolrRequestExecutor solrRequestExecutor) { | ||
super(solrRequestExecutor); | ||
} | ||
|
||
@Nonnull | ||
@Override | ||
public Set<NodeFixReport> fix(Class<? extends HealthProcessorPlugin> pluginClass, | ||
Set<NodeHealthReport> unhealthyReports) { | ||
clearCache(); | ||
return super.fix(pluginClass, unhealthyReports); | ||
} | ||
|
||
@Override | ||
protected Set<NodeFixReport> handleHealthReport(NodeHealthReport unhealthyReport, | ||
NodeIndexHealthReport endpointHealthReport) { | ||
if (endpointHealthReport.getHealthStatus() != IndexHealthStatus.NOT_FOUND) { | ||
return Collections.emptySet(); | ||
} | ||
|
||
NodeRef.Status nodeStatus = endpointHealthReport.getNodeRefStatus(); | ||
SearchEndpointTxId searchEndpointTxId = new SearchEndpointTxId(endpointHealthReport.getEndpoint(), nodeStatus.getDbTxnId()); | ||
if (searchEndpointTxCache.containsKey(searchEndpointTxId)) { | ||
NodeFixReport cachedNodeFixReport = searchEndpointTxCache.get(searchEndpointTxId); | ||
log.trace("We already have a fix report for {}: {}", searchEndpointTxId, cachedNodeFixReport); | ||
//If a successful reindex action was already sent for this tx to this endpoint, do not schedule another one | ||
if (cachedNodeFixReport.getFixStatus() == NodeFixStatus.SUCCEEDED) { | ||
log.trace("Fix for TX of {} has already succeeded, sending existing fix report messages.", unhealthyReport); | ||
return Collections.singleton(new NodeFixReport(cachedNodeFixReport.getFixStatus(), unhealthyReport, | ||
cachedNodeFixReport.getMessages())); | ||
} | ||
} | ||
|
||
log.trace("Performing reindex for {}", searchEndpointTxId); | ||
|
||
// Action not yet (successfully) sent | ||
NodeFixReport nodeFixReport = trySendSolrCommand(unhealthyReport, endpointHealthReport, | ||
SolrNodeCommand.REINDEX_TRANSACTION); | ||
|
||
searchEndpointTxCache.put(searchEndpointTxId, nodeFixReport); | ||
return Collections.singleton(nodeFixReport); | ||
} | ||
|
||
@Value | ||
public static class SearchEndpointTxId { | ||
private final SearchEndpoint searchEndpoint; | ||
private final Long txId; | ||
} | ||
|
||
private void clearCache() { | ||
searchEndpointTxCache.clear(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.