Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DROOLS-7485] StoresOnly Strategy - multiple kieSession from the same… #5387

Merged
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 @@ -161,10 +161,10 @@ void insertAdvanceFireFailoverExpire_shouldExpireAfterFailover(PersistedSessionO
}

@ParameterizedTest
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepoints")
void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy) {
KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepointsAndKieBaseCache")
void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy, boolean useKieBaseCache) {
KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
Comment on lines +164 to +167
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now we have useKieBaseCache parameter. If yes, ksessions are created from the same kbase. If no, ksessions are created from different kbases.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the change, it looks great!


SessionPseudoClock clock1 = getSessionClock(session1);
SessionPseudoClock clock2 = getSessionClock(session2);
Expand All @@ -180,9 +180,9 @@ void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailov
//-- Assume JVM down here. Fail-over to other JVM or rebooted JVM
//-- ksession and kbase are lost. CacheManager is recreated. Client knows only "id"
failover();
session1=restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session1=restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock1 = getSessionClock(session1);
session2=restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session2=restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock2 = getSessionClock(session2);

assertThat(fireAllRules(session1)).isEqualTo(1);
Expand All @@ -200,9 +200,9 @@ void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailov
insert(session2, new StockTick("ACME"));

failover();
session1=restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session1=restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock1 = getSessionClock(session1);
session2=restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session2=restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock2 = getSessionClock(session2);

assertThat(fireAllRules(session1)).isEqualTo(0);
Expand All @@ -216,11 +216,11 @@ void multipleKieSessions_insertAdvanceInsertFailoverFire_shouldRecoverFromFailov
}

@ParameterizedTest
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepoints")
void multipleKieSessions_insertAdvanceFailoverExpireFire_shouldExpireAfterFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy) {
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepointsAndKieBaseCache")
void multipleKieSessions_insertAdvanceFailoverExpireFire_shouldExpireAfterFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy, boolean useKieBaseCache) {

KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);

SessionPseudoClock clock1 = getSessionClock(session1);
SessionPseudoClock clock2 = getSessionClock(session2);
Expand All @@ -234,9 +234,9 @@ void multipleKieSessions_insertAdvanceFailoverExpireFire_shouldExpireAfterFailov
insert(session2, new StockTick("ACME"));

failover();
session1 = restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session1 = restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock1 = getSessionClock(session1);
session2 = restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session2 = restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock2 = getSessionClock(session2);

clock1.advanceTime(58, TimeUnit.SECONDS);
Expand All @@ -252,12 +252,12 @@ void multipleKieSessions_insertAdvanceFailoverExpireFire_shouldExpireAfterFailov
}

@ParameterizedTest
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepoints")
void multipleKieSessions_insertAdvanceFireFailoverExpire_shouldExpireAfterFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy) {
@MethodSource("strategyProviderStoresOnlyWithExplicitSafepointsAndKieBaseCache")
void multipleKieSessions_insertAdvanceFireFailoverExpire_shouldExpireAfterFailover(PersistedSessionOption.PersistenceStrategy persistenceStrategy, PersistedSessionOption.SafepointStrategy safepointStrategy, boolean useKieBaseCache) {

KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session1 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
SessionPseudoClock clock1 = getSessionClock(session1);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
KieSession session2 = createSession(CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
SessionPseudoClock clock2 = getSessionClock(session2);

insert(session1, new StockTick("DROO"));
Expand All @@ -272,9 +272,9 @@ void multipleKieSessions_insertAdvanceFireFailoverExpire_shouldExpireAfterFailov
assertThat(fireAllRules(session2)).isEqualTo(0);

failover();
session1 = restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session1 = restoreSession(session1.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock1 = getSessionClock(session1);
session2 = restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
session2 = restoreSession(session2.getIdentifier(), CEP_RULE, persistenceStrategy, safepointStrategy, useKieBaseCache, EventProcessingOption.STREAM, ClockTypeOption.PSEUDO);
clock2 = getSessionClock(session2);

clock1.advanceTime(58, TimeUnit.SECONDS);
Expand Down
Loading