diff --git a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.0.xml b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.0.xml index b50a4f465f..5b0a0da893 100644 --- a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.0.xml +++ b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.0.xml @@ -31,7 +31,7 @@ - + @@ -47,14 +47,14 @@ - + - - + + \ No newline at end of file diff --git a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.1.xml b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.1.xml new file mode 100644 index 0000000000..4e0129eee7 --- /dev/null +++ b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-1.6.1.xml @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-master.xml b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-master.xml index 6cd96c626c..3010118039 100755 --- a/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-master.xml +++ b/connections/jpa-liquibase/src/main/resources/META-INF/jpa-changelog-master.xml @@ -9,5 +9,5 @@ - + diff --git a/connections/jpa/src/main/java/org/keycloak/connections/jpa/updater/JpaUpdaterProvider.java b/connections/jpa/src/main/java/org/keycloak/connections/jpa/updater/JpaUpdaterProvider.java index 60b063513e..401cf74b2d 100755 --- a/connections/jpa/src/main/java/org/keycloak/connections/jpa/updater/JpaUpdaterProvider.java +++ b/connections/jpa/src/main/java/org/keycloak/connections/jpa/updater/JpaUpdaterProvider.java @@ -12,7 +12,7 @@ public interface JpaUpdaterProvider extends Provider { public String FIRST_VERSION = "1.0.0.Final"; - public String LAST_VERSION = "1.6.0"; + public String LAST_VERSION = "1.6.1"; public String getCurrentVersionSql(String defaultSchema); diff --git a/model/api/src/main/java/org/keycloak/models/utils/PostMigrationEvent.java b/model/api/src/main/java/org/keycloak/models/utils/PostMigrationEvent.java new file mode 100644 index 0000000000..513836f3ba --- /dev/null +++ b/model/api/src/main/java/org/keycloak/models/utils/PostMigrationEvent.java @@ -0,0 +1,11 @@ +package org.keycloak.models.utils; + +import org.keycloak.provider.ProviderEvent; + +/** + * Executed at startup after model migration is finished + * + * @author Marek Posolda + */ +public class PostMigrationEvent implements ProviderEvent { +} diff --git a/model/sessions-infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProviderFactory.java b/model/sessions-infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProviderFactory.java index 1d7c279542..382d01f630 100755 --- a/model/sessions-infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProviderFactory.java +++ b/model/sessions-infinispan/src/main/java/org/keycloak/models/sessions/infinispan/InfinispanUserSessionProviderFactory.java @@ -5,9 +5,11 @@ import org.infinispan.Version; import org.jboss.logging.Logger; import org.keycloak.Config; import org.keycloak.connections.infinispan.InfinispanConnectionProvider; +import org.keycloak.models.ClientModel; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.KeycloakSessionTask; +import org.keycloak.models.RealmModel; import org.keycloak.models.UserSessionProvider; import org.keycloak.models.UserSessionProviderFactory; import org.keycloak.models.session.UserSessionPersisterProvider; @@ -19,6 +21,9 @@ import org.keycloak.models.sessions.infinispan.entities.SessionEntity; import org.keycloak.models.sessions.infinispan.initializer.InfinispanUserSessionInitializer; import org.keycloak.models.sessions.infinispan.initializer.OfflineUserSessionLoader; import org.keycloak.models.utils.KeycloakModelUtils; +import org.keycloak.models.utils.PostMigrationEvent; +import org.keycloak.provider.ProviderEvent; +import org.keycloak.provider.ProviderEventListener; /** * Uses Infinispan to store user sessions. On EAP 6.4 (Infinispan 5.2) map reduce is not supported for local caches as a work around @@ -68,13 +73,20 @@ public class InfinispanUserSessionProviderFactory implements UserSessionProvider }); // Max count of worker errors. Initialization will end with exception when this number is reached - int maxErrors = config.getInt("maxErrors", 20); + final int maxErrors = config.getInt("maxErrors", 20); // Count of sessions to be computed in each segment - int sessionsPerSegment = config.getInt("sessionsPerSegment", 100); + final int sessionsPerSegment = config.getInt("sessionsPerSegment", 100); - // TODO: Possibility to run this asynchronously to not block start time - loadPersistentSessions(factory, maxErrors, sessionsPerSegment); + factory.register(new ProviderEventListener() { + + @Override + public void onEvent(ProviderEvent event) { + if (event instanceof PostMigrationEvent) { + loadPersistentSessions(factory, maxErrors, sessionsPerSegment); + } + } + }); } diff --git a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java index 83b8d6e68e..a07999d6c1 100755 --- a/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java +++ b/services/src/main/java/org/keycloak/services/resources/KeycloakApplication.java @@ -11,6 +11,7 @@ import org.keycloak.migration.MigrationModelManager; import org.keycloak.models.KeycloakSession; import org.keycloak.models.KeycloakSessionFactory; import org.keycloak.models.RealmModel; +import org.keycloak.models.utils.PostMigrationEvent; import org.keycloak.offlineconfig.AdminRecovery; import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.services.DefaultKeycloakSessionFactory; @@ -83,6 +84,8 @@ public class KeycloakApplication extends Application { setupDefaultRealm(context.getContextPath()); migrateModel(); + sessionFactory.publish(new PostMigrationEvent()); + new ExportImportManager().checkExportImport(this.sessionFactory, context.getContextPath()); importRealms(context);