-
Notifications
You must be signed in to change notification settings - Fork 40
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-7573 - add parameter for h2vm/infinispan store #268
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,10 @@ | |
|
||
import org.drools.benchmarks.common.AbstractBenchmark; | ||
import org.drools.benchmarks.common.util.RuntimeUtil; | ||
import org.drools.reliability.core.ReliableGlobalResolverFactory; | ||
import org.drools.reliability.core.SimpleReliableObjectStoreFactory; | ||
import org.drools.reliability.core.StorageManagerFactory; | ||
import org.drools.reliability.h2mvstore.H2MVStoreStorageManager; | ||
import org.drools.reliability.infinispan.InfinispanStorageManager; | ||
import org.drools.reliability.infinispan.InfinispanStorageManagerFactory; | ||
import org.drools.util.FileUtils; | ||
|
@@ -41,6 +44,7 @@ | |
import static org.drools.reliability.infinispan.InfinispanStorageManagerFactory.INFINISPAN_STORAGE_ALLOWED_PACKAGES; | ||
import static org.drools.reliability.infinispan.InfinispanStorageManagerFactory.INFINISPAN_STORAGE_MARSHALLER; | ||
import static org.drools.reliability.infinispan.InfinispanStorageManagerFactory.INFINISPAN_STORAGE_MODE; | ||
import static org.drools.util.Config.getConfig; | ||
|
||
public abstract class AbstractReliabilityBenchmark extends AbstractBenchmark { | ||
|
||
|
@@ -62,9 +66,19 @@ public String getInfinispanStorageMode() { | |
} | ||
} | ||
|
||
public enum Module { | ||
INFINISPAN, | ||
H2MVSTORE | ||
} | ||
|
||
public static final String DROOLS_RELIABILITY_MODULE_TEST = "drools.reliability.module.test"; | ||
|
||
@Param({"NONE", "EMBEDDED", "REMOTE", "REMOTEPROTO"}) | ||
protected Mode mode; | ||
|
||
@Param({"INFINISPAN", "H2MVSTORE"}) | ||
protected Module module; | ||
|
||
@Param({"true", "false"}) | ||
protected boolean useSafepoints; | ||
|
||
|
@@ -74,25 +88,33 @@ public String getInfinispanStorageMode() { | |
public void setupEnvironment() { | ||
FileUtils.deleteDirectory(Path.of(GLOBAL_STATE_DIR)); | ||
|
||
if (mode != NONE) { | ||
System.setProperty(INFINISPAN_STORAGE_MODE, mode.getInfinispanStorageMode()); | ||
} | ||
if (module == Module.H2MVSTORE){ | ||
H2MVStoreStorageManager.cleanUpDatabase(); | ||
System.setProperty(DROOLS_RELIABILITY_MODULE_TEST, "H2MVSTORE"); | ||
configureServicePriorities(); | ||
}else { // assuming infinispan is the default module | ||
System.setProperty(DROOLS_RELIABILITY_MODULE_TEST, "INFINISPAN"); | ||
configureServicePriorities(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please move this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, done. |
||
if (mode != NONE) { | ||
System.setProperty(INFINISPAN_STORAGE_MODE, mode.getInfinispanStorageMode()); | ||
} | ||
|
||
if (mode == EMBEDDED || mode == REMOTE) { | ||
System.setProperty(INFINISPAN_STORAGE_ALLOWED_PACKAGES, "org.drools.benchmarks.common.model"); | ||
} | ||
if (mode == EMBEDDED || mode == REMOTE) { | ||
System.setProperty(INFINISPAN_STORAGE_ALLOWED_PACKAGES, "org.drools.benchmarks.common.model"); | ||
} | ||
|
||
if (mode == REMOTEPROTO) { | ||
System.setProperty(INFINISPAN_STORAGE_MARSHALLER, "PROTOSTREAM"); | ||
setupSerializationContext(); | ||
} | ||
if (mode == REMOTEPROTO) { | ||
System.setProperty(INFINISPAN_STORAGE_MARSHALLER, "PROTOSTREAM"); | ||
setupSerializationContext(); | ||
} | ||
|
||
if (mode == REMOTE || mode == REMOTEPROTO) { | ||
container = new InfinispanContainer(); | ||
container.start(); | ||
InfinispanStorageManager storageManager = (InfinispanStorageManager) StorageManagerFactory.get().getStorageManager(); | ||
RemoteCacheManager remoteCacheManager = container.getRemoteCacheManager(storageManager.provideAdditionalRemoteConfigurationBuilder()); | ||
storageManager.setRemoteCacheManager(remoteCacheManager); | ||
if (mode == REMOTE || mode == REMOTEPROTO) { | ||
container = new InfinispanContainer(); | ||
container.start(); | ||
InfinispanStorageManager storageManager = (InfinispanStorageManager) StorageManagerFactory.get().getStorageManager(); | ||
RemoteCacheManager remoteCacheManager = container.getRemoteCacheManager(storageManager.provideAdditionalRemoteConfigurationBuilder()); | ||
storageManager.setRemoteCacheManager(remoteCacheManager); | ||
} | ||
} | ||
} | ||
|
||
|
@@ -127,4 +149,28 @@ public void setup() { | |
} | ||
|
||
protected abstract void populateKieSessionPerIteration(); | ||
|
||
|
||
public static void configureServicePriorities() { | ||
Module module = Module.valueOf(getConfig(DROOLS_RELIABILITY_MODULE_TEST, Module.INFINISPAN.name())); | ||
if (module == Module.INFINISPAN) { | ||
prioritizeInfinispanServices(); | ||
} else if (module == Module.H2MVSTORE) { | ||
prioritizeH2MVStoreServices(); | ||
} else { | ||
throw new IllegalStateException("Unknown module: " + module); | ||
} | ||
} | ||
|
||
private static void prioritizeInfinispanServices() { | ||
ReliableGlobalResolverFactory.get("infinispan"); | ||
SimpleReliableObjectStoreFactory.get("infinispan"); | ||
StorageManagerFactory.get("infinispan"); | ||
} | ||
|
||
private static void prioritizeH2MVStoreServices() { | ||
ReliableGlobalResolverFactory.get("core"); | ||
SimpleReliableObjectStoreFactory.get("core"); | ||
StorageManagerFactory.get("h2mvstore"); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first, I thought that
Module
is a good idea. But then we have to deal with unexpected combinations like "H2MVSTORE" + "REMOTE", or "H2MVSTORE" + "REMOTEPROTO".If you run
You will hit a failure with such a combination.
Probably it's better to use only
Mode
as a benchmark parameter. You may still useModule
for internal code writing convenience (for example,Mode
can haveModule
). So add "H2MVSTORE" to Mode. Maybe also it's better to rename like "EMBEDDED" to "INFINISPAN_EMBEDDED" and so on (butinfinispanStorageMode
values shouldn't be changed , because it's used for INFINISPAN_STORAGE_MODE)Let me know if it's not clear for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I understand. I will make the changes needed.