Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public synchronized void runAgent(User user, final SingleConsole singleConsole,
"\nPlease restart perftest after few minutes.");
}

hazelcastService.put(CACHE_RECENTLY_USED_AGENTS, user.getUserId(), necessaryAgents);
hazelcastService.put(DIST_MAP_NAME_RECENTLY_USED_AGENTS, user.getUserId(), necessaryAgents);

LOGGER.info("{} agents are starting for user {}", agentCount, user.getUserId());
for (AgentInfo agentInfo : necessaryAgents) {
Expand Down Expand Up @@ -386,7 +386,7 @@ private boolean hasOldVersionAgent(Set<AgentInfo> agentInfos) {
* @return selected agents.
*/
Set<AgentInfo> selectAgent(User user, Set<AgentInfo> allFreeAgents, int agentCount) {
Set<AgentInfo> recentlyUsedAgents = hazelcastService.getOrDefault(CACHE_RECENTLY_USED_AGENTS, user.getUserId(), emptySet());
Set<AgentInfo> recentlyUsedAgents = hazelcastService.getOrDefault(DIST_MAP_NAME_RECENTLY_USED_AGENTS, user.getUserId(), emptySet());

Comparator<AgentInfo> recentlyUsedPriorityComparator = (agent1, agent2) -> {
if (recentlyUsedAgents.contains(agent1)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ public interface CacheConstants {
String DIST_MAP_NAME_SAMPLING = "sampling";
String DIST_MAP_NAME_MONITORING = "monitoring";
String DIST_MAP_NAME_AGENT = "agent";
String DIST_MAP_NAME_RECENTLY_USED_AGENTS = "recently_used_agents";

String CACHE_USERS = "users";
String CACHE_FILE_ENTRIES = "file_entries";
String DIST_CACHE_USERS = "users";
String DIST_CACHE_FILE_ENTRIES = "file_entries";

String CACHE_RIGHT_PANEL_ENTRIES = "right_panel_entries";
String CACHE_LEFT_PANEL_ENTRIES = "left_panel_entries";
String CACHE_CURRENT_PERFTEST_STATISTICS = "current_perftest_statistics";
String CACHE_RECENTLY_USED_AGENTS = "recently_used_agents";
String LOCAL_CACHE_RIGHT_PANEL_ENTRIES = "right_panel_entries";
String LOCAL_CACHE_LEFT_PANEL_ENTRIES = "left_panel_entries";
String LOCAL_CACHE_CURRENT_PERFTEST_STATISTICS = "current_perftest_statistics";

String REGION_ATTR_KEY = "region";
String REGION_EXECUTOR_SERVICE_NAME = "region_executor";
Expand All @@ -41,8 +41,8 @@ public interface CacheConstants {

String CACHE_USER_ENTITY = "org.ngrinder.model.User";

String CACHE_GITHUB_SCRIPTS = "github_scripts";
String CACHE_GITHUB_IS_MAVEN_GROOVY = "github_is_maven_groovy";
String LOCAL_CACHE_GITHUB_SCRIPTS = "github_scripts";
String LOCAL_CACHE_GITHUB_IS_MAVEN_GROOVY = "github_is_maven_groovy";

int REGION_CACHE_TIME_TO_LIVE_SECONDS = 20;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import java.net.URL;
import java.util.*;

import static org.ngrinder.common.constant.CacheConstants.CACHE_LEFT_PANEL_ENTRIES;
import static org.ngrinder.common.constant.CacheConstants.CACHE_RIGHT_PANEL_ENTRIES;
import static org.ngrinder.common.constant.CacheConstants.LOCAL_CACHE_LEFT_PANEL_ENTRIES;
import static org.ngrinder.common.constant.CacheConstants.LOCAL_CACHE_RIGHT_PANEL_ENTRIES;
import static org.ngrinder.common.util.TypeConvertUtils.cast;

/**
Expand All @@ -56,7 +56,7 @@ public class HomeService {
* @return the list of {@link PanelEntry}
*/
@SuppressWarnings("unchecked")
@Cacheable(CACHE_LEFT_PANEL_ENTRIES)
@Cacheable(LOCAL_CACHE_LEFT_PANEL_ENTRIES)
public List<PanelEntry> getLeftPanelEntries(String feedURL) {
return getPanelEntries(feedURL, PANEL_ENTRY_SIZE, false);
}
Expand All @@ -68,7 +68,7 @@ public List<PanelEntry> getLeftPanelEntries(String feedURL) {
* @param feedURL rss url message
* @return {@link PanelEntry} list
*/
@Cacheable(CACHE_RIGHT_PANEL_ENTRIES)
@Cacheable(LOCAL_CACHE_RIGHT_PANEL_ENTRIES)
public List<PanelEntry> getRightPanelEntries(String feedURL) {
return getPanelEntries(feedURL, PANEL_ENTRY_SIZE, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,16 +149,16 @@ public CacheConfigHolder cacheConfigMap() {
cm.addDistMap(DIST_MAP_NAME_SAMPLING, 15);
cm.addDistMap(DIST_MAP_NAME_MONITORING, 15);
cm.addDistMap(DIST_MAP_NAME_AGENT, 10);
cm.addDistMap(DIST_MAP_NAME_RECENTLY_USED_AGENTS, 1 * DAY);

cm.addDistCache(CACHE_USERS, 30, 300);
cm.addDistCache(CACHE_FILE_ENTRIES, 1 * HOUR + 40 * MIN, 300);
cm.addDistCache(DIST_CACHE_USERS, 30, 300);
cm.addDistCache(DIST_CACHE_FILE_ENTRIES, 1 * HOUR + 40 * MIN, 300);

cm.addLocalCache(CACHE_GITHUB_SCRIPTS, 5 * MIN, 300);
cm.addLocalCache(CACHE_RIGHT_PANEL_ENTRIES, 1 * DAY, 1);
cm.addLocalCache(CACHE_LEFT_PANEL_ENTRIES, 1 * DAY, 1);
cm.addLocalCache(CACHE_CURRENT_PERFTEST_STATISTICS, 5, 1);
cm.addLocalCache(CACHE_GITHUB_IS_MAVEN_GROOVY, 5 * MIN, 300);
cm.addLocalCache(CACHE_RECENTLY_USED_AGENTS, 1 * DAY, 100);
cm.addLocalCache(LOCAL_CACHE_GITHUB_SCRIPTS, 5 * MIN, 300);
cm.addLocalCache(LOCAL_CACHE_RIGHT_PANEL_ENTRIES, 1 * DAY, 1);
cm.addLocalCache(LOCAL_CACHE_LEFT_PANEL_ENTRIES, 1 * DAY, 1);
cm.addLocalCache(LOCAL_CACHE_CURRENT_PERFTEST_STATISTICS, 5, 1);
cm.addLocalCache(LOCAL_CACHE_GITHUB_IS_MAVEN_GROOVY, 5 * MIN, 300);
return cm;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ public void addCommentOn(User user, Long testId, String testComment, String tagS
*
* @return PerfTestStatisticsList PerfTestStatistics list
*/
@Cacheable(CACHE_CURRENT_PERFTEST_STATISTICS)
@Cacheable(LOCAL_CACHE_CURRENT_PERFTEST_STATISTICS)
@Transactional
public Collection<PerfTestStatistics> getCurrentPerfTestStatistics() {
Map<User, PerfTestStatistics> perfTestPerUser = newHashMap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import static com.google.common.collect.Lists.newArrayList;
import static java.util.Collections.unmodifiableList;
import static org.apache.commons.compress.utils.CharsetNames.UTF_8;
import static org.ngrinder.common.constant.CacheConstants.CACHE_FILE_ENTRIES;
import static org.ngrinder.common.constant.CacheConstants.DIST_CACHE_FILE_ENTRIES;
import static org.ngrinder.common.util.CollectionUtils.buildMap;
import static org.ngrinder.common.util.CollectionUtils.newHashMap;
import static org.ngrinder.common.util.ExceptionUtils.processException;
Expand Down Expand Up @@ -97,7 +97,7 @@ public void init() {
}
});
svnClientManager = fileEntityRepository.getSVNClientManager();
fileEntryCache = cacheManager.getCache(CACHE_FILE_ENTRIES);
fileEntryCache = cacheManager.getCache(DIST_CACHE_FILE_ENTRIES);
}

/**
Expand Down Expand Up @@ -162,7 +162,7 @@ private File getUserRepoDirectory(User user) {
* @param user user
* @return cached {@link FileEntry} list
*/
@Cacheable(value = CACHE_FILE_ENTRIES, key = "#user.userId")
@Cacheable(value = DIST_CACHE_FILE_ENTRIES, key = "#user.userId")
public List<FileEntry> getAll(User user) {
prepare(user);
List<FileEntry> allFileEntries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
import static org.apache.commons.io.FilenameUtils.getName;
import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.apache.commons.lang.StringUtils.isNotEmpty;
import static org.ngrinder.common.constant.CacheConstants.CACHE_GITHUB_IS_MAVEN_GROOVY;
import static org.ngrinder.common.constant.CacheConstants.CACHE_GITHUB_SCRIPTS;
import static org.ngrinder.common.constant.CacheConstants.LOCAL_CACHE_GITHUB_IS_MAVEN_GROOVY;
import static org.ngrinder.common.constant.CacheConstants.LOCAL_CACHE_GITHUB_SCRIPTS;
import static org.ngrinder.common.constant.ControllerConstants.PROP_CONTROLLER_GITHUB_BASE_URL;
import static org.ngrinder.common.util.AopUtils.proxy;
import static org.ngrinder.common.util.CollectionUtils.buildMap;
Expand Down Expand Up @@ -185,7 +185,7 @@ private boolean isSvnWorkingCopyDir(File directory) {
return new File(directory.getPath() + "/.svn").exists();
}

@Cacheable(value = CACHE_GITHUB_IS_MAVEN_GROOVY, key = "#ghRepository.svnUrl + #scriptPath + #activeBranch")
@Cacheable(value = LOCAL_CACHE_GITHUB_IS_MAVEN_GROOVY, key = "#ghRepository.svnUrl + #scriptPath + #activeBranch")
public boolean isGroovyMavenProject(GHRepository ghRepository, String scriptPath, String activeBranch) {
if (!groovyMavenProjectScriptHandler.isGroovyMavenPath(scriptPath)) {
return false;
Expand Down Expand Up @@ -331,7 +331,7 @@ private Map<String, String> parseGitHubConfigurationErrorMessage(String errorMes
*
* @since 3.5.0
*/
@Cacheable(value = CACHE_GITHUB_SCRIPTS, key = "#user.userId")
@Cacheable(value = LOCAL_CACHE_GITHUB_SCRIPTS, key = "#user.userId")
public Map<String, List<GHTreeEntry>> getScripts(User user) throws FileNotFoundException {
Map<String, List<GHTreeEntry>> scriptMap = new HashMap<>();
getAllGitHubConfig(user).forEach(gitHubConfig -> {
Expand Down Expand Up @@ -424,12 +424,12 @@ private String getGitHubBaseUrl(GitHubConfig gitHubConfig) {
return (!configuredGitHubBaseUrl.isEmpty()) ? configuredGitHubBaseUrl : config.getControllerProperties().getProperty(PROP_CONTROLLER_GITHUB_BASE_URL);
}

@CacheEvict(value = CACHE_GITHUB_SCRIPTS, key = "#user.userId")
@CacheEvict(value = LOCAL_CACHE_GITHUB_SCRIPTS, key = "#user.userId")
public void evictGitHubScriptCache(User user) {
noOp();
}

@CacheEvict(value = CACHE_GITHUB_IS_MAVEN_GROOVY, key = "#ghRepository.svnUrl + #scriptPath + #activeBranch")
@CacheEvict(value = LOCAL_CACHE_GITHUB_IS_MAVEN_GROOVY, key = "#ghRepository.svnUrl + #scriptPath + #activeBranch")
public void evictGitHubMavenGroovyCache(GHRepository ghRepository, String scriptPath, String activeBranch) {
noOp();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

import static org.apache.commons.lang.StringUtils.isBlank;
import static org.hibernate.Hibernate.initialize;
import static org.ngrinder.common.constant.CacheConstants.CACHE_USERS;
import static org.ngrinder.common.constant.CacheConstants.DIST_CACHE_USERS;
import static org.ngrinder.common.constant.CacheConstants.CACHE_USER_ENTITY;
import static org.springframework.data.domain.Sort.Direction.*;
import static org.springframework.data.domain.Sort.by;
Expand Down Expand Up @@ -81,7 +81,7 @@ public UserService(UserRepository userRepository, PerfTestService perfTestServic

@PostConstruct
public void init() {
userCache = cacheManager.getCache(CACHE_USERS);
userCache = cacheManager.getCache(DIST_CACHE_USERS);
userModelCache = cacheManager.getCache(CACHE_USER_ENTITY);
}

Expand All @@ -92,7 +92,7 @@ public void init() {
* @return user
*/
@Transactional
@Cacheable(value = CACHE_USERS, key = "#userId")
@Cacheable(value = DIST_CACHE_USERS, key = "#userId")
@Override
public User getOne(String userId) {
User user = userRepository.findOneByUserId(userId);
Expand Down Expand Up @@ -134,7 +134,7 @@ public void encodePassword(User user) {
* @return User
*/
@Transactional
@CachePut(value = CACHE_USERS, key = "#user.userId")
@CachePut(value = DIST_CACHE_USERS, key = "#user.userId")
@Override
public User save(User user) {
encodePassword(user);
Expand All @@ -148,7 +148,7 @@ public User save(User user) {
* @return User
*/
@Transactional
@CachePut(value = CACHE_USERS, key = "#user.userId")
@CachePut(value = DIST_CACHE_USERS, key = "#user.userId")
@Override
public User saveWithoutPasswordEncoding(User user) {
final List<User> followers = getFollowers(user.getFollowersStr());
Expand All @@ -166,7 +166,7 @@ public User saveWithoutPasswordEncoding(User user) {
}

@Transactional
@CachePut(value = CACHE_USERS, key = "#user.userId")
@CachePut(value = DIST_CACHE_USERS, key = "#user.userId")
public User saveWithoutFollowers(User user) {
if (user.getPassword() != null && isBlank(user.getPassword())) {
user.setPassword(null);
Expand Down Expand Up @@ -210,7 +210,7 @@ private List<User> getFollowers(String followersStr) {
*/
@SuppressWarnings("SpringElInspection")
@Transactional
@CacheEvict(value = CACHE_USERS, key = "#userId")
@CacheEvict(value = DIST_CACHE_USERS, key = "#userId")
public void delete(String userId) {
User user = getOne(userId);
List<PerfTest> deletePerfTests = perfTestService.deleteAll(user);
Expand Down Expand Up @@ -282,7 +282,7 @@ public Page<User> getPagedAll(String keyword, Pageable pageable) {
* @return User
*/
@Transactional
@CachePut(value = CACHE_USERS, key = "#user.userId")
@CachePut(value = DIST_CACHE_USERS, key = "#user.userId")
@Override
public User createUser(User user) {
encodePassword(user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.ngrinder.common.constant.CacheConstants.CACHE_RECENTLY_USED_AGENTS;
import static org.ngrinder.common.constant.CacheConstants.DIST_MAP_CACHE_RECENTLY_USED_AGENTS;
import static org.ngrinder.common.util.CollectionUtils.newHashSet;

public class AgentServiceTest extends AbstractNGrinderTransactionalTest {
Expand All @@ -39,7 +39,7 @@ public class AgentServiceTest extends AbstractNGrinderTransactionalTest {
@Test
public void selectAgentsTest() {
Set<AgentInfo> recentlyUsedAgents = getRecentlyUsedAgents();
hazelcastService.put(CACHE_RECENTLY_USED_AGENTS, TEST_USER_ID, recentlyUsedAgents);
hazelcastService.put(DIST_MAP_CACHE_RECENTLY_USED_AGENTS, TEST_USER_ID, recentlyUsedAgents);

User testUser = new User();
testUser.setUserId(TEST_USER_ID);
Expand All @@ -65,7 +65,7 @@ public void selectAgentsTest() {

recentlyUsedAgents.add(createAgentInfo("test-agent-11", "test-region_owned_test-user"));
recentlyUsedAgents.add(createAgentInfo("test-agent-14", "test-region_owned_test-user"));
hazelcastService.put(CACHE_RECENTLY_USED_AGENTS, TEST_USER_ID, recentlyUsedAgents);
hazelcastService.put(DIST_MAP_CACHE_RECENTLY_USED_AGENTS, TEST_USER_ID, recentlyUsedAgents);

// Add owned agents for another test.
allFreeAgents.add(createAgentInfo("test-agent-8", "test-region_owned_test-user"));
Expand All @@ -85,7 +85,7 @@ public void selectAgentsTest() {
assertTrue(selectedAgents.contains(createAgentInfo("test-agent-11", "test-region_owned_test-user")));
assertTrue(selectedAgents.contains(createAgentInfo("test-agent-14", "test-region_owned_test-user")));

hazelcastService.delete(CACHE_RECENTLY_USED_AGENTS, TEST_USER_ID);
hazelcastService.delete(DIST_MAP_CACHE_RECENTLY_USED_AGENTS, TEST_USER_ID);
}

private Set<AgentInfo> getRecentlyUsedAgents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import java.util.Set;

import static org.ngrinder.common.constant.CacheConstants.CACHE_RECENTLY_USED_AGENTS;
import static org.ngrinder.common.constant.CacheConstants.DIST_MAP_CACHE_RECENTLY_USED_AGENTS;

@Profile("unit-test")
@Service
Expand All @@ -44,7 +44,7 @@ public synchronized void runAgent(User user, final SingleConsole singleConsole,
final Set<AgentInfo> allFreeAgents = getAllAttachedFreeApprovedAgentsForUser(user.getUserId());
final Set<AgentInfo> necessaryAgents = selectAgent(user, allFreeAgents, agentCount);

hazelcastService.put(CACHE_RECENTLY_USED_AGENTS, user.getUserId(), necessaryAgents);
hazelcastService.put(DIST_MAP_CACHE_RECENTLY_USED_AGENTS, user.getUserId(), necessaryAgents);

LOGGER.info("{} agents are starting for user {}", agentCount, user.getUserId());
for (AgentInfo agentInfo : necessaryAgents) {
Expand Down