use of org.olat.core.util.coordinate.SyncerExecutor in project OpenOLAT by OpenOLAT.
the class CoordinatorTest method testDoInSyncPerformance.
@Test
public void testDoInSyncPerformance() {
final OLATResourceable ores = OresHelper.createOLATResourceableInstance(UUID.randomUUID().toString(), new Long("123989456"));
OLATResource r = CoreSpringFactory.getImpl(OLATResourceManager.class).findOrPersistResourceable(ores);
int maxLoop = 500;
final RepositoryEntry re = repositoryService.create("test", "perfTest", "testPerf", "perfTest description", r);
// create security group
repositoryService.update(re);
DBFactory.getInstance().commitAndCloseSession();
// 1. Do job without doInSync
log.info("testDoInSyncPerformance: start test with doInSync");
long startTimeWithoutSync = System.currentTimeMillis();
for (int i = 0; i < maxLoop; i++) {
doTestPerformanceJob(re);
DBFactory.getInstance().closeSession();
}
long endTimeWithoutSync = System.currentTimeMillis();
// 2. Do job with doInSync
log.info("testDoInSyncPerformance: start test with doInSync");
long startTimeDoInSync = System.currentTimeMillis();
for (int i = 0; i < maxLoop; i++) {
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
public void execute() {
doTestPerformanceJob(re);
}
});
// end syncerCallback
DBFactory.getInstance().closeSession();
}
long endTimeDoInSync = System.currentTimeMillis();
// Compare time
long timeWithoutSync = endTimeWithoutSync - startTimeWithoutSync;
float perJobWithoutSync = (float) timeWithoutSync / maxLoop;
log.info("testDoInSyncPerformance timeWithoutSync=" + timeWithoutSync + " ms for loop with " + maxLoop + " iterations");
log.info("testDoInSyncPerformance perJobWithoutSync=" + perJobWithoutSync + " ms");
long timeWithDoInSync = endTimeDoInSync - startTimeDoInSync;
float perJobWithDoInSync = (float) timeWithDoInSync / maxLoop;
log.info("testDoInSyncPerformance timeWithDoInSync=" + timeWithDoInSync + " ms for loop with " + maxLoop + " iterations");
log.info("testDoInSyncPerformance perJobWithDoInSync=" + perJobWithDoInSync + " ms");
long timeDiffLoop = timeWithDoInSync - timeWithoutSync;
float timeDiffPerCall = perJobWithDoInSync - perJobWithoutSync;
log.info("testDoInSyncPerformance diffLoop=" + timeDiffLoop + " ms for loop with " + maxLoop + " iterations");
log.info("testDoInSyncPerformance diffPerCall=" + timeDiffPerCall + " ms");
}
use of org.olat.core.util.coordinate.SyncerExecutor in project OpenOLAT by OpenOLAT.
the class Path method cache.
/**
* A feed contains many URLs and links etc. The validation of the URL and
* verification of access should only be done once for performance reasons.
* That's where caching comes in. We'll store the URL as the key and give it a
* boolean value whether access has been successfully granted or not.
*/
public void cache(OLATResourceable ores, final boolean accessible) {
final String key = getKey();
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(ores, new SyncerExecutor() {
public void execute() {
if (validatedUriCache.get(key) == null) {
validatedUriCache.put(key, accessible);
} else {
validatedUriCache.update(key, accessible);
}
}
});
}
use of org.olat.core.util.coordinate.SyncerExecutor in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerImpl method deleteProject.
/**
* Delete a project and delete project-groups related to this project.
* This method is cluster-save.
* @see org.olat.course.nodes.projectbroker.service.ProjectBrokerManager#deleteProject(org.olat.course.nodes.projectbroker.datamodel.Project)
*/
public void deleteProject(final Project project, final boolean deleteGroup, final CourseEnvironment courseEnv, final CourseNode cNode) {
logDebug("start deleteProject project=" + project);
final Long projectBrokerId = project.getProjectBroker().getKey();
OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {
public void execute() {
Project reloadedProject = (Project) dbInstance.loadObject(project, true);
// delete first candidate-group, project-group will be deleted after deleting project
SecurityGroup candidateGroup = reloadedProject.getCandidateGroup();
if ((courseEnv != null) && (cNode != null)) {
deleteAllAttachmentFilesOfProject(reloadedProject, courseEnv, cNode);
deleteAllDropboxFilesOfProject(reloadedProject, courseEnv, cNode);
deleteAllReturnboxFilesOfProject(reloadedProject, courseEnv, cNode);
}
dbInstance.deleteObject(reloadedProject);
logInfo("deleteSecurityGroup(project.getCandidateGroup())=" + candidateGroup.getKey());
securityManager.deleteSecurityGroup(candidateGroup);
// invalide with removing from cache
projectCache.remove(projectBrokerId.toString());
}
});
if (deleteGroup) {
logDebug("start deleteProjectGroupFor project=" + project);
projectGroupManager.deleteProjectGroupFor(project);
}
logDebug("DONE deleteProjectGroupFor project=" + project);
}
use of org.olat.core.util.coordinate.SyncerExecutor in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerImpl method createAndSaveProjectFor.
public Project createAndSaveProjectFor(String title, String description, final Long projectBrokerId, BusinessGroup projectGroup) {
OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
final Project project = new ProjectImpl(title, description, projectGroup, getProjectBroker(projectBrokerId));
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {
public void execute() {
dbInstance.saveObject(project);
ProjectBroker projectBroker = getOrLoadProjectBoker(projectBrokerId);
if (!projectBroker.getProjects().contains(project)) {
projectBroker.getProjects().add(project);
}
projectCache.update(projectBrokerId.toString(), projectBroker);
}
});
return project;
}
use of org.olat.core.util.coordinate.SyncerExecutor in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerImpl method updateProject.
@Override
public void updateProject(final Project project) {
final Long projectBrokerId = project.getProjectBroker().getKey();
OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {
@Override
public void execute() {
updateProjectAndInvalidateCache(project);
}
});
}
Aggregations