Merge pull request #1507 from stianst/master

KEYCLOAK-1699 There are 3 failed tests when running testsuite with -P…
This commit is contained in:
Stian Thorgersen 2015-07-27 09:57:52 +02:00
commit e4f4ed923d
2 changed files with 15 additions and 4 deletions

View file

@ -2,6 +2,7 @@ package org.keycloak.models.sessions.infinispan;
import org.infinispan.Cache; import org.infinispan.Cache;
import org.infinispan.distexec.mapreduce.MapReduceTask; import org.infinispan.distexec.mapreduce.MapReduceTask;
import org.jboss.logging.Logger;
import org.keycloak.models.ClientModel; import org.keycloak.models.ClientModel;
import org.keycloak.models.ClientSessionModel; import org.keycloak.models.ClientSessionModel;
import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSession;
@ -41,6 +42,8 @@ import java.util.Map;
*/ */
public class InfinispanUserSessionProvider implements UserSessionProvider { public class InfinispanUserSessionProvider implements UserSessionProvider {
private static final Logger log = Logger.getLogger(InfinispanUserSessionProvider.class);
private final KeycloakSession session; private final KeycloakSession session;
private final Cache<String, SessionEntity> sessionCache; private final Cache<String, SessionEntity> sessionCache;
private final Cache<LoginFailureKey, LoginFailureEntity> loginFailureCache; private final Cache<LoginFailureKey, LoginFailureEntity> loginFailureCache;
@ -473,6 +476,8 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
} }
public void put(Cache cache, Object key, Object value) { public void put(Cache cache, Object key, Object value) {
log.tracev("Adding cache operation: {0} on {1}", CacheOperation.ADD, key);
if (tasks.containsKey(key)) { if (tasks.containsKey(key)) {
throw new IllegalStateException("Can't add session: task in progress for session"); throw new IllegalStateException("Can't add session: task in progress for session");
} else { } else {
@ -481,6 +486,8 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
} }
public void replace(Cache cache, Object key, Object value) { public void replace(Cache cache, Object key, Object value) {
log.tracev("Adding cache operation: {0} on {1}", CacheOperation.REPLACE, key);
CacheTask current = tasks.get(key); CacheTask current = tasks.get(key);
if (current != null) { if (current != null) {
switch (current.operation) { switch (current.operation) {
@ -489,7 +496,7 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
current.value = value; current.value = value;
return; return;
case REMOVE: case REMOVE:
throw new IllegalStateException("Can't remove session: task in progress for session"); return;
} }
} else { } else {
tasks.put(key, new CacheTask(cache, CacheOperation.REPLACE, key, value)); tasks.put(key, new CacheTask(cache, CacheOperation.REPLACE, key, value));
@ -497,6 +504,8 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
} }
public void remove(Cache cache, Object key) { public void remove(Cache cache, Object key) {
log.tracev("Adding cache operation: {0} on {1}", CacheOperation.REMOVE, key);
tasks.put(key, new CacheTask(cache, CacheOperation.REMOVE, key, null)); tasks.put(key, new CacheTask(cache, CacheOperation.REMOVE, key, null));
} }
@ -514,6 +523,8 @@ public class InfinispanUserSessionProvider implements UserSessionProvider {
} }
public void execute() { public void execute() {
log.tracev("Executing cache operation: {0} on {1}", operation, key);
switch (operation) { switch (operation) {
case ADD: case ADD:
cache.put(key, value); cache.put(key, value);

View file

@ -23,15 +23,15 @@
}, },
"userSessions": { "userSessions": {
"provider" : "${keycloak.userSessions.provider:mem}" "provider" : "${keycloak.userSessions.provider:infinispan}"
}, },
"realmCache": { "realmCache": {
"provider": "${keycloak.realm.cache.provider:mem}" "provider": "${keycloak.realm.cache.provider:infinispan}"
}, },
"userCache": { "userCache": {
"provider": "${keycloak.user.cache.provider:mem}", "provider": "${keycloak.user.cache.provider:infinispan}",
"mem": { "mem": {
"maxSize": 20000 "maxSize": 20000
} }