Mark Stephens FollowMark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.
He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

My notes and pictures from Wednesday JavaOne 2017

8.30 Analyzing HotSpot Crashes [CON2494]

All slides on internet so only 1 screenshotUnrecoverable errorWorked through core dumoJcmd gives useful background dataLower j interpreted J crashed in compiled codeWalked through out of memory errors-xx:+crashoutofmemoryerror will give you crash fileJhsdb useful for analysing core fileRemember to add hotspot module if needed in j9

9.30 Make Your CPU Cores Sweat with Parallel Streams [CON3363]

Reminder on streamsStreams about describing what you want not how to do itParallel streams allow you to leverage multi-core easilyenable parallel streams with streams() to parallelstream() or stream().parallel() – position does not matterFork/join framework since jdk7All parallel streams use one common pool (CPUS -1 count). Can be changed with System propertyYou can create a custom pool for Parallel streamsSpliterator – can be used with streamsAlways take into account how well the stream source decomposes – does not always divide evenlyParallel streams work better where order does not matterAvoid shared state as will create race conditions. Fixing by making synvhronized makes parallel pointlessStream is always sequential or parallel

11.45 The Power and Perils of Parallel Streams [CON7321]

Programming concurrency is very hardDivide and conquer versus parallel arrayIf you are source of stream use parallelStream(), if receiver use stream().parallel()You can actually do stream().sequential()Last one wins so xx.parallel()….sequential() will choose sequentialobserving threads – parallel uses main and fork join threadsnot all streams have ordering – impacted by orderOrder can be imposed by forEachOrdered() – still parallel but imposes an orderingreduce() collates results into one. Can run in parallel. Value provided for input is identity not start. In that case add in at endNumber of threads based on cores -1If IO tasks you can have more threads whereas not desirable with lots of computational threads. (polite monks exercising example)Parallel is not always faster if thread count wrongWhen parallel makes no sense

12.45 Designing Functional Programs [CON7318]

imperative + object-orientated => functional + object-orientatedAssignnment-less programmingPurely and hybrid functional languagesFavor immutabilityHigher order functions (functions can use functions)A method is a functionFunction composition and lazy evaluationKey features in FP are function composition and lazy evaluationSome lang have safe defaults (Haskell) and some unsafe defaults (Java)

1.30 Java Flight Recorder in JDK 9/Java Mission Control 6 [HOL3018]

Great sessions with 73 exercises to work through now or later

4.30pm Troubleshooting Memory Problems in Java Applications [CON3825]

Talk by JVM sustaining engineer (customer issues in JVM)Java Heap Memory issuesIf Full GC not able to claim any space in Old gen of heap, could be config issueHeap might be too small – see if larger heap fixes itHeap usage can be tested with tools like jconsole or GC logs-Xmx correct sizing issue and set to same as -XmsDiagnostic data to find issues:- CG logs,Heap dumps Heap histogramsHeap dumps can be collected with jcmd, jmap, JCOnsole JMC, HeapDump -XX:+HeapDumpOnOutMemoryErrorSame tools and jhsdb can grab heap histograms (objects on the heap)In GC logs look for number of GCs,etc – GCHisto tool can analyseYou can see if Explicit GCs called and disable with -XX:+DisableExplicitGCEclipse MAT can analyse heap dumps.PermGen/MetaSpace leaks can also occur. As with heap check if big enough first (-XX:PermSize=m -XXMaxPermSize=nRemGen not in java8 and overCompressed class space part of MetasPaceCompressedClass pointers will save space if usedjmap and icmd can collect diagnostic data for PermGen/MetaSpaceFinalization can also cause memory errors (finalize() method can delay)JCOnsole, jmap an Heap Dumps can show finalise errorsCodeCache will not throw memory error but penalty when full. Can be configured to be bigger sizeNative memory not directly controlled by JVM but can increase room by reducing threads, PermGen/MetaSpace, etc. Trouble-shoot with Native Memory tracker (NMT) (if JVM) or native tools likes pmap, libumem, valgrind, etc or core file

5.30pm Taking Java EE to the Clouds [CON3419]

Reza started saying myth Java EE does not run on cloud. Actually one of the best supported technologiesJava EE on cloud since EE6.Easy to run on IaaS , AWS, AzurePlays well with DockerMany Java EE PaaS options like OpenShift, Oracle, Cloud, BlueMix, Heroku, JelasticRun on base JVM platforms (WildFly Swarm, Payara Micro, etc)Demo of Cargo Tracker – design patterns on GitHub (10K lines of code so non-trivial)

IaaS (infrastructure as a service) – your datacenter on someone else’s machine. Infrastructure as a service (ie AWS, Azure). Vert flexible and low cost but high maintenance. Closest to premise. Nice demo with all code on GitHubAll providers start with a free tier level.

CaaS – Container as a Service.Lots of providers now support Docker and JavaEE excellent fix for Docker. Only deploy changes, not whole Docker image. Every Java platform has prebuilt Docker image. Demo on EC2 Container service.

PaaS (platform as a service)Less config but less flexible and more expensive. Higher risk of lockin and may require changes to application. Demo on Elastic.

Small number of PaaS platforms support TomCat or Jetty and JVM.

7.30pm Concert!

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (Twitter, Facebook and Google+) or the Blog RSS.

Mark Stephens FollowMark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.
He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.