...
Code Block |
---|
public class AnalyticsApp extends AbstractApplication {
@Override
public void configure() {
setName("AnalyticsApp");
setDescription("Application for generating mobile analytics");
addStream(new Stream("event"));
addFlow(new EventProcessingFlow());
...
addService(new IPGeoLookupService());
addService(new UserLookupService());
...
}
} |
...
The service can then be discovered in a MapReduce, Spark, Worker, or another service using the appropriate program context. You may also access a service in a different application by specifying the application name in the getServiceURL
call.
For example, in flowsWorkers:
Code Block |
---|
public class GeoFlowletGeoWorker extends AbstractFlowletAbstractWorker { // URL for IPGeoLookupService private URL serviceURL; // URL for SecurityService in SecurityApplication private URL securityURL; @ProcessInput public void processrun(String ip) { // Get URL for service in same application serviceURL = getContext().getServiceURL("IPGeoLookupService"); // Get URL for service in a different application securityURL = getContext().getServiceURL("SecurityApplication", "SecurityService"); // Access the IPGeoLookupService using its URL if (serviceURL != null) { URLConnection connection = new URL(serviceURL, String.format("lookup/%s", ip)).openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); } ... // Access the SecurityService using its URL if (securityURL != null) { ... } } } |
...