Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)
Upcoming SlideShare
Loading in...5
×
 

Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat)

on

  • 1,461 views

 

Statistics

Views

Total Views
1,461
Views on SlideShare
1,461
Embed Views
0

Actions

Likes
0
Downloads
5
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat) Byteman and The Jokre, Sanne Grinovero (JBoss by RedHat) Presentation Transcript

  • OpenBlend LjubljanaSeptember 15th, 2011 Introduction to Byteman and The Jokre Sanne Grinovero Software Engineer at Red Hat 1
  • Byteman• Its a scriptable java agent• Lets you change behavior at runtime – Without changing any sources – Simulating unexpected behaviour – Setting up specific scenarios
  • 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? View slide
  • Byteman can crash your disk View slide
  • Byteman can cut your LAN cable
  • Byteman can generate an OutOfMemory exception right where you want it
  • Or it can do simple things too
  • Code deep dive: disk fullProper error handling for IO exceptions aretested by:org.hibernate.search.test.errorhandling.ConcurrentMergeErrorHandledTest
  • 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
  • Byte(code) man(ipulation)Available right now in a JVM near you– transform code/class structure at load– retransform code only after load– java.lang.instrument
  • Byte(code) man(ipulation)• Byteman makes it easy – inject Java code direct into Java code• Byteman makes it cheap – low transformation cost – tightly scoped changes• Byteman produces reversible changes – no structural changes
  • Byteman built-in methodsTracing• traceOpen, traceClose, traceln, traceStack, ...Managing Shared Rule State• flag, clear, countDown, incrementCounter,Timing• createTimer, getElapsedTime, resetTimer,
  • Helper ClassesBuilt-ins are POJO public methods• take a look org.jboss.byteman.rule.Helper• You can use any POJO you likeclass DBHelper {public void trace(String msg,Record rec);
  • Timing issues• org.hibernate.search.test.query.timeout. JPATimeoutTest – Verifies a timeout is thrown if the query is too slow
  • 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 JDKs /lib/tools.jar on classpath• See website and our projects for details
  • The Jokre• https://github.com/infinispan/jokre• A proof of concept of an advanced optimization technique• Requires some knowledge of Infinispan
  • Infinispan API: mandates a return valuemap.put( “user-34”, userInstance );V put(K key, V value);
  • A return value forces an RPCAssuming a DIST_ASYNC Infinispan cache:map.put( “k-1”, userInstance );1) ask the node storing “k-1” what thecurrent value is2) return that.. to nobody3) eventually perform the putasynchronously
  • 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!” );
  • 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, thats not the Map API anymore!
  • 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: lets see some magic in action
  • Jokr demo
  • 2011-09-15 10:43:15,794 WARN [Skynet] (main) JKR-00012 Problem XYZ detectedwithin your code. No worries, we just fixed it for you.
  • Just use Map, we fix it• This is a new concept: an “illegal” optimization is performed.• Its a proof of concept – feel free to suggest more use cases.
  • Questions?Project Page http://www.jboss.org/byteman– downloads– documentation– user & developer forums– code repositoryhttps://github.com/bytemanprojecthttps://github.com/infinispan