It's all about the answers!

Ask a question

Improve performance of fetching contributor details using Java RTC API


David Morehouse (111) | asked Jun 09 '20, 11:59 a.m.

 Hi,


I'm using code largely based off of the following blog post:


In our test environments it worked fine, however in production environments with projects that have thousands of users the performance is much much slower.

I ran the code attached to the above blog post (20121209_AnalyzeProjectAreaContributorsAndRoles.zip) and it took over 19 minutes to fetch about 7000 users in one project.

My code takes about 6 minutes to similar fetch details about users in a project (user id and user name):

public Map<String, String> getUsers(ITeamRepository repo, IProjectArea projectArea) throws TeamRepositoryException{
IProcessArea processArea = (IProcessArea) projectArea;

Map<String, String> users = new LinkedHashMap<String, String>();
LOGGER.info("Users-------------------------");

for (IContributorHandle m : processArea.getMembers()) {
IContributor contributor = (IContributor) repo.itemManager()
.fetchCompleteItem(m, IItemManager.DEFAULT, null);
users.put(contributor.getUserId(), contributor.getName());
LOGGER.info(contributor.getName());

}

LOGGER.info("Admin-------------------------");
for (IContributorHandle m : processArea.getAdministrators()) {
IContributor contributor = (IContributor) repo.itemManager()
.fetchCompleteItem(m, IItemManager.DEFAULT, null);
users.put(contributor.getUserId(), contributor.getName());
LOGGER.info(contributor.getName());
}


Is there anyway to improve it, such as by mass fetching all the users in a project at once, and not one by one?

One answer



permanent link
Param S (233) | answered Jun 14 '20, 10:07 p.m.

 Utilize fetchCompleteItems method for quicker results. 

If only partial data is ultimately required, use fetchPartialItems from the same itemManager interface of team repository interface.

More speed can be got by using an executor service, to have two tasks, to get data for members and administrators.

If speed is only your concern, you use a GET Httpconnection to query RPT Rest service of your server, to quickly get user information in XML format and its response is generally way fast than plain Java API, as the results are processed and formatted at server side itself.

Your answer


Register or to post your answer.