diff --git a/pom.xml b/pom.xml index 421dc4dcbf..6ca9651b9d 100644 --- a/pom.xml +++ b/pom.xml @@ -37,7 +37,7 @@ ${project.build.directory}/alf_data convert - 7.134.5 + 7.134.6 8.50.2.1 7.22 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/java/org/alfresco/repo/web/scripts/solr/TransactionIntervalGet.java b/src/main/java/org/alfresco/repo/web/scripts/solr/TransactionIntervalGet.java new file mode 100644 index 0000000000..fc551a5c20 --- /dev/null +++ b/src/main/java/org/alfresco/repo/web/scripts/solr/TransactionIntervalGet.java @@ -0,0 +1,69 @@ +/* + * #%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 minimum and the maximum commit time for transactions in a node id range. + * This webscript is used by Shards using DB_ID_RANGE in order to + * identify the transaction time window that needs to be indexed. + * + * @author aborroy + * + */ +public class TransactionIntervalGet 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 fromNodeId = Long.parseLong(req.getParameter("fromNodeId")); + Long toNodeId = Long.parseLong(req.getParameter("toNodeId")); + + Map model = new HashMap<>(); + model.put("minTransactionCommitTimeMs", nodeDAO.getMinTxInNodeIdRange(fromNodeId, toNodeId)); + model.put("maxTransactionCommitTimeMs", nodeDAO.getMaxTxInNodeIdRange(fromNodeId, toNodeId)); + 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/templates/webscripts/org/alfresco/repository/solr/transactionInterval.get.desc.xml b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/transactionInterval.get.desc.xml new file mode 100644 index 0000000000..2005bf06fb --- /dev/null +++ b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/transactionInterval.get.desc.xml @@ -0,0 +1,14 @@ + + Get the minimum and the maximum commit times for transactions in a range of node ids + + Get the minimum and the maximum commit times for transactions in a range of node ids: [fromNodeId TO toNodeId] + If the nodes don't exist in the repository, -1 is returned in both fields. + + /api/solr/transactionInterval?fromNodeId={fromNodeId}&toNodeId={toNodeId} + argument + + none + required + internal + SOLR + diff --git a/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/transactionInterval.get.json.ftl b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/transactionInterval.get.json.ftl new file mode 100644 index 0000000000..2e8a8667fb --- /dev/null +++ b/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/solr/transactionInterval.get.json.ftl @@ -0,0 +1,4 @@ +{ + "minTransactionCommitTimeMs": <#if minTransactionCommitTimeMs??>${minTransactionCommitTimeMs?c}<#else>-1, + "maxTransactionCommitTimeMs": <#if maxTransactionCommitTimeMs??>${maxTransactionCommitTimeMs?c}<#else>-1 +} diff --git a/src/main/resources/alfresco/web-scripts-application-context.xml b/src/main/resources/alfresco/web-scripts-application-context.xml index 1cb6c41f62..e22c316784 100644 --- a/src/main/resources/alfresco/web-scripts-application-context.xml +++ b/src/main/resources/alfresco/web-scripts-application-context.xml @@ -1260,6 +1260,20 @@ + + + + + + + + + +