✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.
Consider a scenario with large scale Java-based web application with large number of users and whose interactions with the application result in the invocation of vast number of functions.
In general, the application owners want to trace potential bottlenecks or inefficiencies with significant impact on the customer base.
Specifically, the application owners want to know:
- how many distinct users have a significant number of invocations to a function (i.e., more than 50 invocations) that, while successfully completed (HTTPStatusCode within the 200s range), are taking too long to complete (more than 10 seconds).
The input consists of a text file where each line stores the relevant data to maintain about each individual request/invocation:
- <requestID> <timestamp>, <className>, <methodName>, <userID>, <HTTPStatusCode>, <responseTimeMs>
Assume the standard signature for the mapper: List<k2,v2> map(int, string) and reducer: List<k3, v3> reduce(k2, List<v2>) functions, where map has the default MapReduce input (cursor/line number and text line content) and k2, v2, k3 and v3 can all be replaced with types of your choice.
Write the pseudocode for a MapReduce application, with a single map and a single reduce method.
The final output of the reduce function should produce, when adequate, a single record identifying each application function that may be causing a potential bottleneck, as described, and the number of users that may be affected, if any.
(if you need, you can briefly state any assumptions at the end of the answer after the pseudocode.)
(No penalty for wrong answer.)
Note: MapReduce is not natural language. Pseudocode needs not be Java but it must include clear operating steps well identified, it should not be a paragraph or set of paragraphs rephrasing the question. But do express your reasoning, nonetheless.