mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
REPO-5376 Query Accelerator Remove all temporary code (#308)
* REPO-5376 Remove all temporary code * Remove DBStats, SingleTaskRestartableWatch * Remove propertiesCache and aspectsCache from DBQueryEngine as they were marked as temporary * Remove further temporary code Co-authored-by: Nana Insaidoo <insaidoo.nana@yahoo.it>
This commit is contained in:
@@ -25,12 +25,6 @@
|
||||
*/
|
||||
package org.alfresco.rest.api.search;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.search.impl.querymodel.impl.db.DBStats;
|
||||
import org.alfresco.repo.search.impl.querymodel.impl.db.SingleTaskRestartableWatch;
|
||||
import org.alfresco.rest.api.model.Node;
|
||||
import org.alfresco.rest.api.search.context.SearchRequestContext;
|
||||
import org.alfresco.rest.api.search.impl.ResultMapper;
|
||||
@@ -51,14 +45,14 @@ import org.alfresco.service.cmr.search.SearchParameters;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.extensions.webscripts.AbstractWebScript;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.util.StopWatch;
|
||||
import org.springframework.util.StopWatch.TaskInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* An implementation of the {{baseUrl}}/{{networkId}}/public/search/versions/1/search endpoint
|
||||
@@ -68,15 +62,12 @@ import org.springframework.util.StopWatch.TaskInfo;
|
||||
public class SearchApiWebscript extends AbstractWebScript implements RecognizedParamsExtractor, RequestReader, ResponseWriter,
|
||||
InitializingBean
|
||||
{
|
||||
protected static final Log logger = LogFactory.getLog(SearchApiWebscript.class);
|
||||
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private SearchService searchService;
|
||||
private SearchMapper searchMapper;
|
||||
private ResultMapper resultMapper;
|
||||
protected ApiAssistant assistant;
|
||||
protected ResourceWebScriptHelper helper;
|
||||
private boolean statsEnabled;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet()
|
||||
@@ -91,7 +82,6 @@ public class SearchApiWebscript extends AbstractWebScript implements RecognizedP
|
||||
@Override
|
||||
public void execute(WebScriptRequest webScriptRequest, WebScriptResponse webScriptResponse) throws IOException
|
||||
{
|
||||
StopWatch apiStopWatch = new StopWatch();
|
||||
try {
|
||||
//Turn JSON into a Java object respresentation
|
||||
SearchQuery searchQuery = extractJsonContent(webScriptRequest, assistant.getJsonHelper(), SearchQuery.class);
|
||||
@@ -106,43 +96,12 @@ public class SearchApiWebscript extends AbstractWebScript implements RecognizedP
|
||||
SearchParameters searchParams = searchMapper.toSearchParameters(params, searchQuery, searchRequestContext);
|
||||
|
||||
//Call searchService
|
||||
apiStopWatch.start("nodes");
|
||||
ResultSet results = searchService.query(searchParams);
|
||||
apiStopWatch.stop();
|
||||
|
||||
//Turn solr results into JSON
|
||||
apiStopWatch.start("props");
|
||||
CollectionWithPagingInfo<Node> resultJson = resultMapper.toCollectionWithPagingInfo(params, searchRequestContext, searchQuery, results);
|
||||
|
||||
//Post-process the request and pass in params, eg. params.getFilter()
|
||||
Object toRender = helper.processAdditionsToTheResponse(null, null, null, params, resultJson);
|
||||
apiStopWatch.stop();
|
||||
|
||||
// store execution stats in a special header if enabled
|
||||
if (statsEnabled)
|
||||
{
|
||||
// store execution time in a special header
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
sb.append("api={");
|
||||
sb.append("tot=").append(apiStopWatch.getTotalTimeMillis()).append("ms,");
|
||||
addStopWatchStats(sb, apiStopWatch);
|
||||
sb.append("}; ");
|
||||
|
||||
sb.append("db={");
|
||||
addStopWatchStats(sb, DBStats.queryStopWatch());
|
||||
sb.append("}; ");
|
||||
|
||||
sb.append("query={");
|
||||
addStopWatchStats(sb, DBStats.handlerStopWatch());
|
||||
sb.append(",");
|
||||
addStopWatchStats(sb, DBStats.aclReadStopWatch());
|
||||
sb.append(",");
|
||||
addStopWatchStats(sb, DBStats.aclOwnerStopWatch());
|
||||
sb.append("}");
|
||||
|
||||
webScriptResponse.addHeader("X-Response-Stats", sb.toString());
|
||||
}
|
||||
|
||||
//Write response
|
||||
setResponse(webScriptResponse, DEFAULT_SUCCESS);
|
||||
@@ -153,44 +112,6 @@ public class SearchApiWebscript extends AbstractWebScript implements RecognizedP
|
||||
}
|
||||
}
|
||||
|
||||
private void addStopWatchStats(StringBuilder sb, StopWatch watch)
|
||||
{
|
||||
boolean first = true;
|
||||
|
||||
for (TaskInfo task : watch.getTaskInfo())
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(",");
|
||||
}
|
||||
|
||||
sb.append(task.getTaskName())
|
||||
.append("=")
|
||||
.append(task.getTimeMillis())
|
||||
.append("ms");
|
||||
|
||||
int pc = Math.round(100 * task.getTimeNanos() / watch.getTotalTimeNanos());
|
||||
sb.append("(")
|
||||
.append(pc).append("%")
|
||||
.append(")");
|
||||
}
|
||||
}
|
||||
|
||||
private void addStopWatchStats(StringBuilder sb, SingleTaskRestartableWatch watch)
|
||||
{
|
||||
long decimillis = (watch.getTotalTimeMicros()+5)/100;
|
||||
double millis = decimillis/10.0;
|
||||
|
||||
sb.append(watch.getName())
|
||||
.append("=")
|
||||
.append(millis)
|
||||
.append("ms");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Params object, parameters come from the SearchQuery json not the request
|
||||
* @param webScriptRequest
|
||||
@@ -243,10 +164,4 @@ public class SearchApiWebscript extends AbstractWebScript implements RecognizedP
|
||||
{
|
||||
this.helper = helper;
|
||||
}
|
||||
|
||||
// receiving as a string because of known issue: https://jira.spring.io/browse/SPR-9989
|
||||
public void setStatsEnabled(String enabled) {
|
||||
this.statsEnabled = Boolean.valueOf(enabled);
|
||||
logger.info("API stats header: " + (this.statsEnabled ? "enabled" : "disabled"));
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,4 @@
|
||||
# See issue REPO-2575 for details.
|
||||
alfresco.restApi.basicAuthScheme=false
|
||||
# REPO-4388 allow CORS headers in transaction response
|
||||
webscripts.transaction.preserveHeadersPattern=Access-Control-.*
|
||||
|
||||
# REPO-5371 enable stats header in API response (only search atm)
|
||||
webscripts.stats.enabled=false
|
||||
webscripts.transaction.preserveHeadersPattern=Access-Control-.*
|
@@ -1024,7 +1024,6 @@
|
||||
<property name="helper" ref="webscriptHelper" />
|
||||
<property name="resultMapper" ref="searchapiResultMapper" />
|
||||
<property name="searchMapper" ref="searchapiSearchMapper" />
|
||||
<property name="statsEnabled" value="${webscripts.stats.enabled}" />
|
||||
</bean>
|
||||
|
||||
<bean id="webscript.org.alfresco.api.SearchSQLApiWebscript.post"
|
||||
|
Reference in New Issue
Block a user