Skip to content

Commit

Permalink
- fix candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas committed Jun 26, 2024
1 parent 50751ea commit 51c81e6
Showing 1 changed file with 17 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.apache.commons.io.IOUtils;
import org.drools.base.definitions.InternalKnowledgePackage;
import org.drools.base.definitions.rule.impl.RuleImpl;
import org.drools.compiler.compiler.io.Folder;
import org.drools.compiler.compiler.io.memory.MemoryFileSystem;
import org.drools.compiler.kie.builder.impl.MemoryKieModule;
Expand All @@ -40,6 +40,7 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.kie.api.KieBase;
import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.Message.Level;
Expand Down Expand Up @@ -259,9 +260,6 @@ private void insertMessageFromTypeDeclaration(KieSession ksession) throws Instan
@Test(timeout = 20000)
public void testIncrementalCompilationSynchronization() {

int MAX_THREAD = 8;
ExecutorService executor = Executors.newFixedThreadPool(MAX_THREAD);

try {
for (int n = 0; n < 1; n++) {
LOG.info("*** run : n = " + n);
Expand All @@ -282,24 +280,16 @@ public void testIncrementalCompilationSynchronization() {
LOG.info(" 1st iteration done");

running = true;
// for (int m = 0; m < MAX_THREAD; m++) {
// executor.execute(new Runnable() {
//
// public void run() {
// long dummy = 0;
// while (running) { // The thread runs until 'running' is set to false
// dummy += 1; // Simple increment to keep the thread busy
// if (dummy < 0) {
// dummy = 0;
// }
// dummy += 1;
// }
// }
// });
// }

Thread t = new Thread(() -> {
for (int i = 1; i < 10; i++) {
while (!previousRuleExists(kieContainer, i)) { // if rule1 exists, we can change it to rule2
try {
Thread.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
ReleaseId releaseId1 = kieServices.newReleaseId("org.kie.test", "sync-scanner-test", "1.0." + i);
LOG.info(" getKieModuleFromDrls: " + releaseId1.toExternalForm());
KieUtil.getKieModuleFromDrls(releaseId1, kieBaseTestConfiguration, createDRL("rule" + i));
Expand Down Expand Up @@ -346,6 +336,13 @@ public void testIncrementalCompilationSynchronization() {
}
}

private static boolean previousRuleExists(KieContainer kieContainer, int i) {
KieBase kieBase = kieContainer.getKieBase();
InternalKnowledgePackage internalKnowledgePackage = (InternalKnowledgePackage)kieBase.getKiePackage("org.kie.test");
RuleImpl rule = internalKnowledgePackage.getRule("rule" + (i - 1));
return rule != null;
}

static class SlownessAgendaEventListener extends org.kie.api.event.rule.DefaultAgendaEventListener {

@Override
Expand Down

0 comments on commit 51c81e6

Please sign in to comment.