Every D Ranked bug is fixed.

This commit is contained in:
Angel Borroy
2019-08-26 16:37:51 +02:00
parent 81a4717c51
commit fed32bdf73
14 changed files with 107 additions and 85 deletions
@@ -951,7 +951,7 @@ public class AlfrescoCoreAdminHandler extends CoreAdminHandler
{
if (maxNodeId >= midpoint)
{
if(density >= 1)
if(density >= 1 || density == 0)
{
//This is fully dense shard. I'm not sure if it's possible to have more nodes on the shards
//then the offset, but if it does happen don't expand.
@@ -1195,8 +1195,7 @@ public class AlfrescoSolrDataModel implements QueryConstants
public void removeModel(QName modelQName)
{
// FIXME: this has no effect. The method should be changed (SEARCH-1482)
modelErrors.remove(modelQName);
modelErrors.remove(getM2Model(modelQName).getName());
dictionaryDAO.removeModel(modelQName);
}
@@ -957,9 +957,10 @@ public class SolrInformationServer implements InformationServer
SolrIndexSearcher solrIndexSearcher = refCounted.get();
coreSummary.add("Searcher", solrIndexSearcher.getStatistics());
Map<String, SolrInfoMBean> infoRegistry = core.getInfoRegistry();
for (String key : infoRegistry.keySet())
for (Entry<String, SolrInfoMBean> infos : infoRegistry.entrySet())
{
SolrInfoMBean infoMBean = infoRegistry.get(key);
SolrInfoMBean infoMBean = infos.getValue();
String key = infos.getKey();
if (key.equals("/alfresco"))
{
// TODO Do we really need to fixStats in solr4?
@@ -2117,8 +2118,9 @@ public class SolrInformationServer implements InformationServer
static void addPropertiesToDoc(Map<QName, PropertyValue> properties, boolean isContentIndexedForNode,
SolrInputDocument newDoc, SolrInputDocument cachedDoc, boolean transformContentFlag)
{
for (QName propertyQName : properties.keySet())
for (Entry<QName, PropertyValue> property : properties.entrySet())
{
QName propertyQName = property.getKey();
newDoc.addField(FIELD_PROPERTIES, propertyQName.toString());
newDoc.addField(FIELD_PROPERTIES, propertyQName.getPrefixString());
@@ -3412,10 +3414,15 @@ public class SolrInformationServer implements InformationServer
SolrQueryRequest request, UpdateRequestProcessor processor, LinkedHashSet<Long> stack)
throws AuthenticationException, IOException, JSONException
{
if ((skipDescendantDocsForSpecificTypes && typesForSkippingDescendantDocs.contains(parentNodeMetaData.getType())) ||
(skipDescendantDocsForSpecificAspects && shouldBeIgnoredByAnyAspect(parentNodeMetaData.getAspects())))
// skipDescendantDocsForSpecificAspects is initialised on a synchronised method, so access must be also synchronised
synchronized (this)
{
return;
if ((skipDescendantDocsForSpecificTypes && typesForSkippingDescendantDocs.contains(parentNodeMetaData.getType())) ||
(skipDescendantDocsForSpecificAspects && shouldBeIgnoredByAnyAspect(parentNodeMetaData.getAspects())))
{
return;
}
}
Set<Long> childIds = new HashSet<>();
@@ -41,6 +41,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
@@ -472,8 +473,9 @@ public class AsyncBuildSuggestComponent extends SearchComponent implements SolrC
@Override
public long ramBytesUsed() {
long sizeInBytes = 0;
for (String key : suggesters.keySet()) {
sizeInBytes += suggesters.get(key).get(ASYNC_CACHE_KEY).ramBytesUsed();
for (Entry<String, SuggesterCache> suggester : suggesters.entrySet())
{
sizeInBytes += suggester.getValue().get(ASYNC_CACHE_KEY).ramBytesUsed();
}
return sizeInBytes;
}
@@ -91,7 +91,7 @@ public class RewriteFacetParametersComponent extends SearchComponent
String rows = params.get("rows");
if(rows != null && !rows.isEmpty())
{
Integer row = new Integer(rows);
Integer row = Integer.valueOf(rows);
// Avoid +1 in SOLR code which produces null:java.lang.NegativeArraySizeException at at org.apache.lucene.util.PriorityQueue.<init>(PriorityQueue.java:56)
if(row > 1000000)
{
@@ -19,7 +19,6 @@
package org.alfresco.solr.component;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -53,9 +52,9 @@ public class TempFileWarningLogger
log.debug("Looking for temp files matching " + glob + " in directory " + dir);
}
try(DirectoryStream<Path> stream = Files.newDirectoryStream(dir, glob))
try
{
for (Path file : stream)
for (Path file : Files.newDirectoryStream(dir, glob))
{
if (log.isDebugEnabled())
{
@@ -74,9 +73,9 @@ public class TempFileWarningLogger
public void removeFiles()
{
try(DirectoryStream<Path> stream = Files.newDirectoryStream(dir, glob))
try
{
for (Path file : stream)
for (Path file : Files.newDirectoryStream(dir, glob))
{
file.toFile().delete();
}
@@ -47,7 +47,7 @@ public abstract class AbstractSolrCachingScorer extends Scorer
static {
for(int i = 0; i < cache.length; i++)
cache[i] = new Long(i);
cache[i] = Long.valueOf(i);
}
}
@@ -20,6 +20,7 @@ package org.alfresco.solr.query;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map.Entry;
import org.alfresco.solr.AlfrescoSolrDataModel;
import org.alfresco.solr.AlfrescoSolrDataModel.FieldUse;
@@ -111,10 +112,9 @@ public class MimetypeGroupingCollector extends DelegatingCollector
rb.rsp.add("analytics", analytics);
NamedList<Object> fieldCounts = new NamedList<>();
analytics.add("mimetype()", fieldCounts);
for(String key : counters.keySet())
for (Entry<String, Counter> counter : counters.entrySet())
{
Counter counter = counters.get(key);
fieldCounts.add(key, counter.get());
fieldCounts.add(counter.getKey(), counter.getValue().get());
}
if(this.delegate instanceof DelegatingCollector) {
@@ -3301,43 +3301,34 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
protected String getToken(String field, String value, AnalysisMode analysisMode) throws ParseException
{
try (TokenStream source = getAnalyzer().tokenStream(field, new StringReader(value)))
{
String tokenised = null;
while (source.incrementToken())
{
CharTermAttribute cta = source.getAttribute(CharTermAttribute.class);
OffsetAttribute offsetAtt = source.getAttribute(OffsetAttribute.class);
TypeAttribute typeAtt = null;
if (source.hasAttribute(TypeAttribute.class))
{
typeAtt = source.getAttribute(TypeAttribute.class);
}
PositionIncrementAttribute posIncAtt = null;
if (source.hasAttribute(PositionIncrementAttribute.class))
{
posIncAtt = source.getAttribute(PositionIncrementAttribute.class);
}
PackedTokenAttributeImpl token = new PackedTokenAttributeImpl();
token.setEmpty().copyBuffer(cta.buffer(), 0, cta.length());
token.setOffset(offsetAtt.startOffset(), offsetAtt.endOffset());
if (typeAtt != null)
{
token.setType(typeAtt.type());
}
if (posIncAtt != null)
{
token.setPositionIncrement(posIncAtt.getPositionIncrement());
}
TokenStream source = getAnalyzer().tokenStream(field, new StringReader(value));
tokenised = token.toString();
}
return tokenised;
} catch (IOException e)
CharTermAttribute cta = source.getAttribute(CharTermAttribute.class);
OffsetAttribute offsetAtt = source.getAttribute(OffsetAttribute.class);
TypeAttribute typeAtt = null;
if (source.hasAttribute(TypeAttribute.class))
{
throw new ParseException("IO" + e.getMessage());
typeAtt = source.getAttribute(TypeAttribute.class);
}
PositionIncrementAttribute posIncAtt = null;
if (source.hasAttribute(PositionIncrementAttribute.class))
{
posIncAtt = source.getAttribute(PositionIncrementAttribute.class);
}
PackedTokenAttributeImpl token = new PackedTokenAttributeImpl();
token.setEmpty().copyBuffer(cta.buffer(), 0, cta.length());
token.setOffset(offsetAtt.startOffset(), offsetAtt.endOffset());
if (typeAtt != null)
{
token.setType(typeAtt.type());
}
if (posIncAtt != null)
{
token.setPositionIncrement(posIncAtt.getPositionIncrement());
}
return token.toString();
}
@@ -5472,11 +5463,13 @@ public class Solr4QueryParser extends QueryParser implements QueryConstants
}
protected BytesRef analyzeMultitermTerm(String field, String part, Analyzer analyzerIn) {
if (analyzerIn == null) analyzerIn = getAnalyzer();
try (TokenStream source = analyzerIn.tokenStream(field, part)) {
source.reset();
try
{
TokenStream source = analyzerIn.tokenStream(field, part);
TermToBytesRefAttribute termAtt = source.getAttribute(TermToBytesRefAttribute.class);
if (!source.incrementToken())
@@ -55,6 +55,13 @@ public class DateQuarterRouter implements DocRouter
calendar.setTime(date);
int month = calendar.get(Calendar.MONTH);
int year = calendar.get(Calendar.YEAR);
return Math.ceil(((year * 12) + (month+1)) / 3) % numShards == shardInstance;
// Avoid using Math.ceil with Integer
int countMonths = ((year * 12) + (month+1));
int grouping = 3;
int ceilGroupInstance = countMonths / grouping + ((countMonths % grouping == 0) ? 0 : 1);
return ceilGroupInstance % numShards == shardInstance;
}
}
@@ -280,7 +280,7 @@ public class AlfrescoSolrClusteringComponent extends SearchComponent implements
list.add(doc);
if (ids != null) {
ids.put(doc, new Integer(docid));
ids.put(doc, Integer.valueOf(docid));
}
}
return list;
@@ -356,7 +356,7 @@ public class AlfrescoSolrClusteringComponent extends SearchComponent implements
/**
* @return Expose for tests.
*/
Map<String, SearchClusteringEngine> getSearchClusteringEngines() {
Map<String, SearchClusteringEngine> getSearchClusteringEnginesView() {
return searchClusteringEnginesView;
}
@@ -26,6 +26,8 @@
package org.alfresco.solr;
import java.util.concurrent.atomic.AtomicInteger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -65,7 +67,20 @@ public class TrackerState
private volatile boolean checkedLastTransactionTime = false;
private volatile boolean check = false;
private volatile int trackerCycles;
// Handle Thread Safe operations
private volatile TrackerCyclesInteger trackerCycles;
class TrackerCyclesInteger
{
private AtomicInteger value = new AtomicInteger(0);
private void increase()
{
value.incrementAndGet();
}
private int getValue()
{
return value.get();
}
}
private long timeToStopIndexing;
private long lastGoodChangeSetCommitTimeInIndex;
@@ -237,13 +252,13 @@ public class TrackerState
public int getTrackerCycles()
{
return this.trackerCycles;
return this.trackerCycles.getValue();
}
public synchronized void incrementTrackerCycles()
{
log.debug("incrementTrackerCycles from :" + trackerCycles);
this.trackerCycles++;
this.trackerCycles.increase();
log.debug("incremented TrackerCycles to :" + trackerCycles);
}
@@ -38,6 +38,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
@@ -741,7 +742,7 @@ public class SOLRAPIClient
String localeStr = o.has("locale") && !o.isNull("locale") ? o.getString("locale") : null;
Locale locale = (o.has("locale") && !o.isNull("locale") ? deserializer.deserializeValue(Locale.class, localeStr) : null);
Long size = o.has("size") && !o.isNull("size") ? o.getLong("size") : null;
long size = o.has("size") && !o.isNull("size") ? o.getLong("size") : 0;
String encoding = o.has("encoding") && !o.isNull("encoding") ? o.getString("encoding") : null;
String mimetype = o.has("mimetype") && !o.isNull("mimetype") ? o.getString("mimetype") : null;
@@ -1247,15 +1248,11 @@ public class SOLRAPIClient
this.namespaceDAO = namespaceDAO;
// add all default converters to this converter
// TODO find a better way of doing this
Map<Class<?>, Map<Class<?>, Converter<?,?>>> converters = DefaultTypeConverter.INSTANCE.getConverters();
for(Class source : converters.keySet())
for (Entry<Class<?>, Map<Class<?>, Converter<?, ?>>> source : DefaultTypeConverter.INSTANCE.getConverters().entrySet())
{
Map<Class<?>, Converter<?,?>> converters1 = converters.get(source);
for(Class dest : converters1.keySet())
for (Entry<Class<?>, Converter<?, ?>> dest : source.getValue().entrySet())
{
Converter<?,?> converter = converters1.get(dest);
instance.addConverter(source, dest, converter);
instance.addConverter((Class) source.getKey(), (Class) dest.getKey(), dest.getValue());
}
}
@@ -30,8 +30,11 @@ import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.concurrent.NotThreadSafe;
import org.alfresco.solr.InformationServerCollectionProvider;
import org.alfresco.solr.adapters.ISimpleOrderedMap;
import org.alfresco.util.Pair;
@@ -283,10 +286,9 @@ public class TrackerStats
map.add("StdDev", getStandardDeviation());
if (incdludeDetail)
{
for (String key : copies.keySet())
for (Entry<String, IncrementalStats> copy : copies.entrySet())
{
IncrementalStats value = copies.get(key);
map.add(key, value.getNamedList(includeHist, includeValues));
map.add(copy.getKey(), copy.getValue().getNamedList(includeHist, includeValues));
}
}
@@ -382,6 +384,7 @@ public class TrackerStats
}
@NotThreadSafe
public static class IncrementalStats
{
Date start = new Date();
@@ -769,7 +772,7 @@ public class TrackerStats
{
IncrementalStats copy = new IncrementalStats(this.scale, this.buckets, this.server);
copy.start = this.start;
copy.max = this.max;
copy.max = this.getMax();
copy.min = this.min;
copy.moments[0] = this.moments[0];
copy.moments[1] = this.moments[1];