June 2018
Intermediate to advanced
280 pages
7h 46m
English
We will demonstrate the usage of the MapReduce pattern by parsing and aggregating logs from multiple web services based on a given Sleuth span and calculating the overall duration for each hit endpoint. The logs are taken from https://cloud.spring.io/spring-cloud-sleuth/spring-cloud-sleuth.html and split into the corresponding service log file. The following code reads in parallel all the logs, maps, sorts, and filters the relevant log entries, collects and reduces (aggregates) the result. If there is a result, it gets printed to the console. The imported date/time classes are used for the ordering comparison. The flatMap code needs to handle Exception, as shown in this code:
jshell> import java.time.*jshell> import java.time.format.* ...
Read now
Unlock full access