This document provides an introduction to Byteman and The Jokre. Byteman is a scriptable Java agent that allows testing code behavior at runtime without changing sources by simulating unexpected events. The Jokre is an optimization technique that modifies the Infinispan API to avoid unnecessary remote procedure calls. A demonstration shows using standard map operations while The Jokre fixes performance issues transparently. Questions are welcomed about these projects.
2. Byteman
• It's a scriptable java agent
• Lets you change behavior at runtime
– Without changing any sources
– Simulating unexpected behaviour
– Setting up specific scenarios
3. How are you going to test for...
• How is your flush operation going to
behave when the disk crashes ?
• Is your code good enough to not corrupt
in-flight processed data when an OOM
excepion happens?
• What if the TCP connection is terminated
during that?
8. Code deep dive: disk full
Proper error handling for IO exceptions are
tested by:
org.hibernate.search.test.errorhandling.Co
ncurrentMergeErrorHandledTest
9. Event-driven scripts
• You can avoid mocks, conditional
builds, and have the code change when
chosen conditions trigger.
– Cleaner code
• Can attach dynamically after the
running code was written
– Used for “debug” and hot-patching of
running production applications
13. Helper Classes
Built-ins are POJO public methods
• take a look
org.jboss.byteman.rule.Helper
• You can use any POJO you like
class DBHelper {
public void trace(String msg,
Record rec);
15. How to enable it
• As an explicit agent
-javaagent:/path/to/agent.jar=agentoptions
Auto-loading the agent
– As with the BMunit examples
– Works with JUnit and TestNG
– Requires the JDK's /lib/tools.jar on
classpath
• See website and our projects for details
17. Infinispan API:
mandates a return value
map.put( “user-34”, userInstance );
V put(K key, V value);
18. A return value forces an RPC
Assuming a DIST_ASYNC Infinispan cache:
map.put( “k-1”, userInstance );
1) ask the node storing “k-1” what the
current value is
2) return that.. to nobody
3) eventually perform the put
asynchronously
19. A return value forces an RPC
• So even async caches often perform as
sync caches, unless flags are used:
cache.withFlags(
Flag.SKIP_REMOTE_LOOKUP,
Flag.SKIP_CACHE_LOAD
).put( “k-1”, “hi!” );
20. A return value forces an RPC
• So even async caches often perform as
sync caches, unless flags are used:
cache.withFlags(
Flag.SKIP_REMOTE_LOOKUP,
Flag.SKIP_CACHE_LOAD
).put( “k-1”, “hi!” );
Hey, that's not the Map API anymore!
21. Tradeoff: use proprietary or
standard API?
• We all prefer well known APIs
– JPA/Hibernate ?
– Interface and standardization often lags
behind: there is a performance hit you pay.
• It seems in some cases you can have
both: let's see some magic in action
23. 2011-09-15 10:43:15,794 WARN [Skynet]
(main) JKR-00012 Problem XYZ detected
within your code. No worries, we just fixed
it for you.
24. Just use Map, we fix it
• This is a new concept: an “illegal”
optimization is performed.
• It's a proof of concept
– feel free to suggest more use cases.