use of jetbrains.buildServer.server.rest.model.project.Projects in project teamcity-rest by JetBrains.
the class ProjectRequestTest method memoryTest.
// @Test
public void memoryTest() throws InterruptedException {
final ProjectRequest request = new ProjectRequest();
request.setInTests(myProjectFinder, myBranchFinder, myBeanContext);
final String locator = "archived:false,affectedProject:_Root";
final String fields = "count,project(id,internalId,name,parentProjectId,archived,readOnlyUI,buildTypes(buildType(id,paused,internalId,projectId,name,type,description)),description)";
Queue<Pair<Integer, ProjectEx>> q = new ArrayDeque<>();
q.add(new Pair<>(0, myProject));
final int max = 2;
final int children = 4;
int counter = 0;
while (!q.isEmpty()) {
Pair<Integer, ProjectEx> p = q.poll();
String prefix = "Bt" + StringUtils.repeat('a', 10 * p.getFirst());
for (int i = 0; i < children; i++) {
ProjectEx c = myFixture.createProject("z-" + p.first + "-" + counter++, p.second);
if (p.first < max) {
q.add(new Pair<>(p.first + 1, c));
}
for (int j = 0; j < children * 4; j++) c.createBuildType(prefix + j);
}
}
System.out.println(counter + " projects created.");
Thread[] ts = new Thread[100];
for (int i = 0; i < ts.length; i++) {
final int threadIdx = i;
ts[i] = new Thread(() -> {
new RestContext(z -> null).run(() -> {
for (int j = 0; j < 100; j++) {
final PagedSearchResult<SProject> result = myProjectFinder.getItems(locator);
Projects projects = new Projects(result.myEntries, null, new Fields(fields), myBeanContext);
projects.projects.stream().flatMap(p -> p.buildTypes.buildTypes.stream()).forEach(bt -> {
bt.getId();
bt.isPaused();
bt.getInternalId();
bt.getProjectId();
bt.getName();
bt.getType();
bt.getDescription();
});
System.out.println(String.format("Finished %d requests in thread %d", j, threadIdx));
}
return null;
});
});
ts[i].start();
}
for (Thread t : ts) t.join();
}
use of jetbrains.buildServer.server.rest.model.project.Projects in project teamcity-rest by JetBrains.
the class AgentPoolRequest method replaceProjects.
/**
* Associates the posted set of projects with the pool which replaces earlier associations on this pool
* @param agentPoolLocator
* @param projects
* @return
*/
@PUT
@Path("/{agentPoolLocator}/projects")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update projects of the matching agent pool.", nickname = "setAgentPoolProjects")
public Projects replaceProjects(@ApiParam(format = LocatorName.AGENT_POOL) @PathParam("agentPoolLocator") String agentPoolLocator, Projects projects) {
final jetbrains.buildServer.serverSide.agentPools.AgentPool agentPool = myAgentPoolFinder.getItem(agentPoolLocator);
final AgentPoolManager agentPoolManager = myServiceLocator.getSingletonService(AgentPoolManager.class);
final int agentPoolId = agentPool.getAgentPoolId();
final List<SProject> projectsList = projects.getProjectsFromPosted(myProjectFinder);
final Set<String> projectIds = new HashSet<String>(projectsList.size());
for (SProject project : projectsList) {
projectIds.add(project.getProjectId());
}
try {
agentPoolManager.dissociateProjectsFromPool(agentPoolId, agentPoolManager.getPoolProjects(agentPoolId));
agentPoolManager.associateProjectsWithPool(agentPoolId, projectIds);
} catch (NoSuchAgentPoolException e) {
throw new BadRequestException("Agent pool with id \'" + agentPoolId + "' is not found.");
}
return new Projects(myAgentPoolFinder.getPoolProjects(agentPool), null, Fields.LONG, myBeanContext);
}
Aggregations