Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-06-13 07:06:24 +0000
committerspingel2009-06-13 07:06:24 +0000
commit1fbda3496447ed471f5e929fab036be0168a403e (patch)
tree32cf26f87ee2023727bd2d43614dedc8e5a56b9f /org.eclipse.mylyn.trac.core
parent4baf499d7c56f0b535f5a251bbf702000d25257f (diff)
downloadorg.eclipse.mylyn.tasks-1fbda3496447ed471f5e929fab036be0168a403e.tar.gz
org.eclipse.mylyn.tasks-1fbda3496447ed471f5e929fab036be0168a403e.tar.xz
org.eclipse.mylyn.tasks-1fbda3496447ed471f5e929fab036be0168a403e.zip
NEW - bug 264930: [performance] Avoid duplicate task updates for non-disjunct queries in scheduled synchronizations
https://bugs.eclipse.org/bugs/show_bug.cgi?id=264930
Diffstat (limited to 'org.eclipse.mylyn.trac.core')
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java50
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java2
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java14
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java9
-rw-r--r--org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracSearch.java11
5 files changed, 69 insertions, 17 deletions
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
index 65b6e7ca1..fa2e33997 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracRepositoryConnector.java
@@ -448,28 +448,54 @@ public class TracRepositoryConnector extends AbstractRepositoryConnector {
ITracClient client;
try {
- client = getClientManager().getTracClient(repository);
- List<TracTicket> tickets = new ArrayList<TracTicket>();
- client.search(search, tickets, monitor);
-
Map<String, ITask> taskById = null;
+
+ client = getClientManager().getTracClient(repository);
client.updateAttributes(monitor, false);
- for (TracTicket ticket : tickets) {
- TaskData taskData = taskDataHandler.createTaskDataFromTicket(client, repository, ticket, monitor);
- taskData.setPartial(true);
- if (session != null && !session.isFullSynchronization() && hasRichEditor(repository)) {
+
+ if (session != null && session.isFullSynchronization() && hasRichEditor(repository)
+ && !session.getTasks().isEmpty()) {
+ // performance optimization: only fetch task ids, all changed tasks have already been marked stale by preSynchronization()
+ List<Integer> ticketIds = new ArrayList<Integer>();
+ client.searchForTicketIds(search, ticketIds, monitor);
+
+ for (Integer id : ticketIds) {
if (taskById == null) {
taskById = new HashMap<String, ITask>();
for (ITask task : session.getTasks()) {
taskById.put(task.getTaskId(), task);
}
}
- ITask task = taskById.get(ticket.getId() + ""); //$NON-NLS-1$
- if (task != null && hasTaskChanged(repository, task, taskData)) {
- session.markStale(task);
+ TaskData taskData = new TaskData(taskDataHandler.getAttributeMapper(repository),
+ TracCorePlugin.CONNECTOR_KIND, repository.getRepositoryUrl(), id + ""); //$NON-NLS-1$
+ taskData.setPartial(true);
+ TaskAttribute attribute = TracTaskDataHandler.createAttribute(taskData, TracAttribute.ID);
+ attribute.setValue(id + ""); //$NON-NLS-1$
+ resultCollector.accept(taskData);
+ }
+ } else {
+ List<TracTicket> tickets = new ArrayList<TracTicket>();
+ client.search(search, tickets, monitor);
+
+ for (TracTicket ticket : tickets) {
+ TaskData taskData = taskDataHandler.createTaskDataFromTicket(client, repository, ticket,
+ monitor);
+ taskData.setPartial(true);
+ if (session != null && !session.isFullSynchronization() && hasRichEditor(repository)) {
+ if (taskById == null) {
+ taskById = new HashMap<String, ITask>();
+ for (ITask task : session.getTasks()) {
+ taskById.put(task.getTaskId(), task);
+ }
+ }
+ // preSyncronization() only handles full synchronizations
+ ITask task = taskById.get(ticket.getId() + ""); //$NON-NLS-1$
+ if (task != null && hasTaskChanged(repository, task, taskData)) {
+ session.markStale(task);
+ }
}
+ resultCollector.accept(taskData);
}
- resultCollector.accept(taskData);
}
} catch (OperationCanceledException e) {
throw e;
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
index 056196c48..25ab803ef 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/TracTaskDataHandler.java
@@ -349,7 +349,7 @@ public class TracTaskDataHandler extends AbstractTaskDataHandler {
}
}
- private static TaskAttribute createAttribute(TaskData data, TracAttribute tracAttribute) {
+ public static TaskAttribute createAttribute(TaskData data, TracAttribute tracAttribute) {
TaskAttribute attr = data.getRoot().createAttribute(tracAttribute.getTracKey());
TaskAttributeMetaData metaData = attr.getMetaData();
metaData.setType(tracAttribute.getType());
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java
index 32a19f691..f223687b0 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/ITracClient.java
@@ -118,14 +118,24 @@ public interface ITracClient {
* the search criteria
* @param result
* the list of found tickets
- * @param monitor
- * TODO
* @throws TracException
* thrown in case of a connection error
*/
void search(TracSearch query, List<TracTicket> result, IProgressMonitor monitor) throws TracException;
/**
+ * Queries ticket id from repository. All found tickets are added to <code>result</code>.
+ *
+ * @param query
+ * the search criteria
+ * @param result
+ * the list of found tickets
+ * @throws TracException
+ * thrown in case of a connection error
+ */
+ void searchForTicketIds(TracSearch query, List<Integer> result, IProgressMonitor monitor) throws TracException;
+
+ /**
* Validates the repository connection.
*
* @throws TracException
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java
index d22af7b64..c506bd963 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/client/TracWebClient.java
@@ -298,6 +298,15 @@ public class TracWebClient extends AbstractTracClient {
}
}
+ public void searchForTicketIds(TracSearch query, List<Integer> result, IProgressMonitor monitor)
+ throws TracException {
+ List<TracTicket> ticketResult = new ArrayList<TracTicket>();
+ search(query, ticketResult, monitor);
+ for (TracTicket tracTicket : ticketResult) {
+ result.add(tracTicket.getId());
+ }
+ }
+
public void search(TracSearch query, List<TracTicket> tickets, IProgressMonitor monitor) throws TracException {
GetMethod method = connect(repositoryUrl + ITracClient.QUERY_URL + query.toUrl(), monitor);
try {
diff --git a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracSearch.java b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracSearch.java
index 8dfc77e6c..3f9308303 100644
--- a/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracSearch.java
+++ b/org.eclipse.mylyn.trac.core/src/org/eclipse/mylyn/internal/trac/core/model/TracSearch.java
@@ -90,12 +90,19 @@ public class TracSearch {
}
/**
+ * @see #toQuery(boolean)
+ */
+ public String toQuery() {
+ return toQuery(false);
+ }
+
+ /**
* Returns a Trac query string that conforms to the format defined at {@link http
* ://projects.edgewall.com/trac/wiki/TracQuery#QueryLanguage}.
*
* @return the empty string, if no search order and criteria are defined; a string that starts with &amp;, otherwise
*/
- public String toQuery() {
+ public String toQuery(boolean supportsMax) {
StringBuilder sb = new StringBuilder();
if (orderBy != null) {
sb.append("&order="); //$NON-NLS-1$
@@ -104,7 +111,7 @@ public class TracSearch {
sb.append("&desc=1"); //$NON-NLS-1$
}
}
- if (max != -1) {
+ if (supportsMax && max != -1) {
sb.append("&max="); //$NON-NLS-1$
sb.append(max);
}

Back to the top