Imagine you have a number of service endpoints, and wish to invoke them concurrently to
obtain results. Each endpoint accepts a number of optional parameters and returns a list of
values. A Java interface for the service endpoint is on the next page.
Goal: Write a service manager that invokes a collection of service endpoints using a set of
parameters (a Map<String, Object>). The service manager should return an aggregate of the
results from the invoked endpoints.
The service manager may accept any map of parameters, but an endpoint should only be
invoked if it supports all of the given map’s parameters. An endpoint may be invoked with any
subset of its supported parameters. For example, an endpoint that supports “location” and
“category” would be invoked if the manager is given a map with just one parameter name
“location,” but it would be skipped if the manager were invoked with a map with three
parameters, “location,” “category,” and “price.” An empty parameter map would invoke all
service endpoints.
Design and implement a thread-safe API for the service manager which can concurrently invoke
the applicable services while respecting the concurrency limits of each endpoint.
Notes:
• Please write your solution in Java. Use any Java version and libraries you think are
helpful. (We typically use Java 8 and Guava and edit with IntelliJ.)
• Design the API however you think is best. Enhancements (such as returning details of
failures, or omitted endpoints) are welcome, but prioritize correctness and clarity. Feel
free to include ideas for improving your solution that you have not implemented.
• We’ll evaluate responses for correctness, clean design, and coding style.
• Incorporate the ServiceEndpoint interface (below) into your own code.
• Include any tests, stubs, or harnesses you write.
Java code for the ServiceEndpoint interface:
import java.util.List;
import java.util.Map;
import java.util.Set;
/**