From 7df658c7b1b960ad996925998175cb21a17a4ffe Mon Sep 17 00:00:00 2001 From: Angel Borroy <48685308+aborroy@users.noreply.github.com> Date: Mon, 20 Jan 2020 13:39:15 +0100 Subject: [PATCH] SEARCH-2028: New Web Script service to provide the next transaction commit time from a given time commit. (#508) This feature will be used by SOLR MetadataTracker to improve performance. --- pom.xml | 2 +- .../web/scripts/solr/NextTransactionGet.java | 66 +++++++++++++++++++ .../nextTransactionCommitTime.get.desc.xml | 14 ++++ .../nextTransactionCommitTime.get.json.ftl | 3 + .../web-scripts-application-context.xml | 7 ++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 src/main/java/org/alfresco/repo/web/scripts/solr/NextTransactionGet.java create mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/nextTransactionCommitTime.get.desc.xml create mode 100644 src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/nextTransactionCommitTime.get.json.ftl diff --git a/pom.xml b/pom.xml index b98175c635..07345473cf 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ ${project.build.directory}/alf_data convert - 8.86 + 8.89 8.85 8.20 diff --git a/src/main/java/org/alfresco/repo/web/scripts/solr/NextTransactionGet.java b/src/main/java/org/alfresco/repo/web/scripts/solr/NextTransactionGet.java new file mode 100644 index 0000000000..c72cd71f72 --- /dev/null +++ b/src/main/java/org/alfresco/repo/web/scripts/solr/NextTransactionGet.java @@ -0,0 +1,66 @@ +/* + * #%L + * Alfresco Repository + * %% + * Copyright (C) 2005 - 2019 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.repo.web.scripts.solr; + +import java.util.HashMap; +import java.util.Map; + +import org.alfresco.repo.domain.node.ibatis.NodeDAOImpl; +import org.springframework.extensions.webscripts.DeclarativeWebScript; +import org.springframework.extensions.webscripts.Status; +import org.springframework.extensions.webscripts.WebScriptRequest; + +/** + * Returns the next transaction commit time from a given commit time. + * This webscript is used to skip long periods where the repository is not ingesting new content. + * + * @author aborroy + * + */ +public class NextTransactionGet extends DeclarativeWebScript +{ + + private NodeDAOImpl nodeDAO; + + /* (non-Javadoc) + * @see org.alfresco.web.scripts.DeclarativeWebScript#executeImpl(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse) + */ + @Override + protected Map executeImpl(WebScriptRequest req, Status status) + { + Long fromCommitTime = Long.parseLong(req.getParameter("fromCommitTime")); + + Map model = new HashMap<>(); + model.put("nextTransactionCommitTimeMs", nodeDAO.getNextTxCommitTime(fromCommitTime)); + return model; + } + + public void setNodeDAO(NodeDAOImpl nodeDAO) + { + this.nodeDAO = nodeDAO; + } + +} diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/nextTransactionCommitTime.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/nextTransactionCommitTime.get.desc.xml new file mode 100644 index 0000000000..c8b2c3ccaf --- /dev/null +++ b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/nextTransactionCommitTime.get.desc.xml @@ -0,0 +1,14 @@ + + Get the next transaction commit time from a given transaction commit time + + Get the next transaction commit time from a given transaction commit time [fromCommitTime] + If no new transaction exists, -1 is returned. + + /api/solr/nextTransaction?fromCommitTime={fromCommitTime} + argument + + none + required + internal + SOLR + \ No newline at end of file diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/nextTransactionCommitTime.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/nextTransactionCommitTime.get.json.ftl new file mode 100644 index 0000000000..b7e7b2d392 --- /dev/null +++ b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/nextTransactionCommitTime.get.json.ftl @@ -0,0 +1,3 @@ +{ + "nextTransactionCommitTimeMs": <#if nextTransactionCommitTimeMs??>${nextTransactionCommitTimeMs?c}<#else>-1 +} \ No newline at end of file diff --git a/src/main/resources/alfresco/web-scripts-application-context.xml b/src/main/resources/alfresco/web-scripts-application-context.xml index 9f371bd16e..8273942fc7 100644 --- a/src/main/resources/alfresco/web-scripts-application-context.xml +++ b/src/main/resources/alfresco/web-scripts-application-context.xml @@ -1266,6 +1266,13 @@ parent="webscript"> + + + + +