mirror of
https://github.com/Alfresco/SearchServices.git
synced 2026-09-16 18:12:56 +00:00
SEARCH-2223 Revert some exception handling in SolrInformationServer to fix intermittent tests.
This commit is contained in:
+40
-10
@@ -106,6 +106,7 @@ import com.carrotsearch.hppc.IntArrayList;
|
|||||||
import com.carrotsearch.hppc.LongHashSet;
|
import com.carrotsearch.hppc.LongHashSet;
|
||||||
import com.carrotsearch.hppc.cursors.LongCursor;
|
import com.carrotsearch.hppc.cursors.LongCursor;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.httpclient.AuthenticationException;
|
import org.alfresco.httpclient.AuthenticationException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.opencmis.dictionary.CMISStrictDictionaryService;
|
import org.alfresco.opencmis.dictionary.CMISStrictDictionaryService;
|
||||||
@@ -1526,6 +1527,10 @@ public class SolrInformationServer implements InformationServer
|
|||||||
{
|
{
|
||||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||||
nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||||
|
if (nodeMetaDatas == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeMetaData nodeMetaData;
|
NodeMetaData nodeMetaData;
|
||||||
@@ -1575,7 +1580,7 @@ public class SolrInformationServer implements InformationServer
|
|||||||
AddUpdateCommand addDocCmd = new AddUpdateCommand(request);
|
AddUpdateCommand addDocCmd = new AddUpdateCommand(request);
|
||||||
addDocCmd.overwrite = overwrite;
|
addDocCmd.overwrite = overwrite;
|
||||||
|
|
||||||
if (!nodeMetaDatas.isEmpty())
|
if (nodeMetaDatas != null && !nodeMetaDatas.isEmpty())
|
||||||
{
|
{
|
||||||
NodeMetaData nodeMetaData = nodeMetaDatas.iterator().next();
|
NodeMetaData nodeMetaData = nodeMetaDatas.iterator().next();
|
||||||
if(node.getTxnId() == Long.MAX_VALUE) {
|
if(node.getTxnId() == Long.MAX_VALUE) {
|
||||||
@@ -1670,7 +1675,7 @@ public class SolrInformationServer implements InformationServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<NodeMetaData> getCascadeNodes(List<Long> txnIds) throws AuthenticationException, IOException, JSONException
|
public List<NodeMetaData> getCascadeNodes(List<Long> txnIds) throws IOException, JSONException
|
||||||
{
|
{
|
||||||
List<FieldInstance> list = AlfrescoSolrDataModel.getInstance().getIndexedFieldNamesForProperty(ContentModel.PROP_CASCADE_TX).getFields();
|
List<FieldInstance> list = AlfrescoSolrDataModel.getInstance().getIndexedFieldNamesForProperty(ContentModel.PROP_CASCADE_TX).getFields();
|
||||||
FieldInstance fieldInstance = list.get(0);
|
FieldInstance fieldInstance = list.get(0);
|
||||||
@@ -1737,8 +1742,11 @@ public class SolrInformationServer implements InformationServer
|
|||||||
nmdp.setMaxResults(1);
|
nmdp.setMaxResults(1);
|
||||||
// Gets only one
|
// Gets only one
|
||||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||||
|
if (nodeMetaDatas != null)
|
||||||
|
{
|
||||||
allNodeMetaDatas.addAll(nodeMetaDatas);
|
allNodeMetaDatas.addAll(nodeMetaDatas);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return allNodeMetaDatas;
|
return allNodeMetaDatas;
|
||||||
}
|
}
|
||||||
@@ -1884,7 +1892,13 @@ public class SolrInformationServer implements InformationServer
|
|||||||
nmdp.setIncludePaths(false);
|
nmdp.setIncludePaths(false);
|
||||||
nmdp.setIncludeParentAssociations(false);
|
nmdp.setIncludeParentAssociations(false);
|
||||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||||
nodeMetaDatas.addAll(getNodesMetaDataFromRepository(nmdp));
|
Collection<NodeMetaData> nodesMetaDataFromRepository = getNodesMetaDataFromRepository(nmdp);
|
||||||
|
if (nodesMetaDataFromRepository == null)
|
||||||
|
{
|
||||||
|
// Using exception for flow handling to jump to single node processing.
|
||||||
|
throw new Exception("Error loading node metadata from repository for bulk delete.");
|
||||||
|
}
|
||||||
|
nodeMetaDatas.addAll(nodesMetaDataFromRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (NodeMetaData nodeMetaData : nodeMetaDatas)
|
for (NodeMetaData nodeMetaData : nodeMetaDatas)
|
||||||
@@ -1931,6 +1945,11 @@ public class SolrInformationServer implements InformationServer
|
|||||||
// Fetches bulk metadata
|
// Fetches bulk metadata
|
||||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||||
|
if (nodeMetaDatas == null)
|
||||||
|
{
|
||||||
|
// Using exception for flow handling to jump to single node processing.
|
||||||
|
throw new Exception("Error loading node metadata from repository for bulk update.");
|
||||||
|
}
|
||||||
|
|
||||||
NEXT_NODE:
|
NEXT_NODE:
|
||||||
for (NodeMetaData nodeMetaData : nodeMetaDatas)
|
for (NodeMetaData nodeMetaData : nodeMetaDatas)
|
||||||
@@ -2501,14 +2520,17 @@ public class SolrInformationServer implements InformationServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SolrInputDocument recreateSolrDoc(long dbId, String tenant) throws AuthenticationException, IOException,
|
private SolrInputDocument recreateSolrDoc(long dbId, String tenant) throws JSONException
|
||||||
JSONException
|
|
||||||
{
|
{
|
||||||
NodeMetaDataParameters nmdp = new NodeMetaDataParameters();
|
NodeMetaDataParameters nmdp = new NodeMetaDataParameters();
|
||||||
nmdp.setFromNodeId(dbId);
|
nmdp.setFromNodeId(dbId);
|
||||||
nmdp.setToNodeId(dbId);
|
nmdp.setToNodeId(dbId);
|
||||||
nmdp.setMaxResults(Integer.MAX_VALUE);
|
nmdp.setMaxResults(Integer.MAX_VALUE);
|
||||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||||
|
if (nodeMetaDatas == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException("Unable to recreate Solr doc for node with DB_ID " + dbId);
|
||||||
|
}
|
||||||
SolrInputDocument newDoc = null;
|
SolrInputDocument newDoc = null;
|
||||||
if (!nodeMetaDatas.isEmpty())
|
if (!nodeMetaDatas.isEmpty())
|
||||||
{
|
{
|
||||||
@@ -3341,7 +3363,7 @@ public class SolrInformationServer implements InformationServer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void cascadeUpdateV2(NodeMetaData parentNodeMetaData, boolean overwrite, SolrQueryRequest request,
|
private void cascadeUpdateV2(NodeMetaData parentNodeMetaData, boolean overwrite, SolrQueryRequest request,
|
||||||
UpdateRequestProcessor processor) throws AuthenticationException, IOException, JSONException
|
UpdateRequestProcessor processor) throws IOException, JSONException
|
||||||
{
|
{
|
||||||
RefCounted<SolrIndexSearcher> refCounted = null;
|
RefCounted<SolrIndexSearcher> refCounted = null;
|
||||||
IntArrayList docList;
|
IntArrayList docList;
|
||||||
@@ -3396,7 +3418,7 @@ public class SolrInformationServer implements InformationServer
|
|||||||
// Gets only one
|
// Gets only one
|
||||||
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
Collection<NodeMetaData> nodeMetaDatas = getNodesMetaDataFromRepository(nmdp);
|
||||||
|
|
||||||
if (!nodeMetaDatas.isEmpty())
|
if (nodeMetaDatas != null && !nodeMetaDatas.isEmpty())
|
||||||
{
|
{
|
||||||
NodeMetaData nodeMetaData = nodeMetaDatas.iterator().next();
|
NodeMetaData nodeMetaData = nodeMetaDatas.iterator().next();
|
||||||
|
|
||||||
@@ -3850,21 +3872,29 @@ public class SolrInformationServer implements InformationServer
|
|||||||
solrContentStore.flushChangeSet();
|
solrContentStore.flushChangeSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the metadata for the specified nodes from the repository.
|
||||||
|
*
|
||||||
|
* @param parameters A parameters object containing either a list of nodes ({@link NodeMetaDataParameters.getNodeIds})
|
||||||
|
* or a node range ({@link NodeMetaDataParameters.getFromNodeId} and {@link NodeMetaDataParameters.getToNodeId}).
|
||||||
|
* @return Either the metadata returned by the repository, or null if there was a problem.
|
||||||
|
*/
|
||||||
private Collection<NodeMetaData> getNodesMetaDataFromRepository(NodeMetaDataParameters parameters)
|
private Collection<NodeMetaData> getNodesMetaDataFromRepository(NodeMetaDataParameters parameters)
|
||||||
{
|
{
|
||||||
|
Collection<NodeMetaData> nodeMetaDataCollection = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return notNullOrEmpty(repositoryClient.getNodesMetaData(parameters));
|
nodeMetaDataCollection = notNullOrEmpty(repositoryClient.getNodesMetaData(parameters));
|
||||||
}
|
}
|
||||||
catch (JSONException exception)
|
catch (JSONException exception)
|
||||||
{
|
{
|
||||||
// Nothing to be done here: the exception has been already logged in repositoryClient
|
// Nothing to be done here: the exception has been already logged in repositoryClient
|
||||||
return Collections.emptyList();
|
LOGGER.debug("JSON exception raised while getting node metadata from repository.", exception);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
LOGGER.error("Unable to get nodes metadata from repository. See the stacktrace below for further details.", exception);
|
LOGGER.error("Unable to get nodes metadata from repository. See the stacktrace below for further details.", exception);
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
|
return nodeMetaDataCollection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user