Service Registry (Registrar) Application Programming Interfaces (APIs)
The Registrar API uses the base Mobius API as its foundation. The ServiceRegistry interface provides accessors that allow the execution of operations on Grid service registries. The ServiceRegistry interface is an extension of the GridService interface (contained in the base API), and thus provides base grid service operations as well as ServiceRegistry related operations.
Handles to Service Registry services can be created using the grid service resolver as follows.
GridServiceResolver resolver = GridServiceResolver.getInstance();
GridService gs = resolver.getGridService("REGISTRAR://localhost");
ServiceRegistry reg = (ServiceRegistry)gs;
The current incarnation of the registrar is as a Mobius service for keeping track of Mobius services running in the Grid. The Registrar is a registry for Mobius services. Services and users can contact the Registrar to discover services of a particular type or to find out what ports and protocols services communicate on. Currently the registrar can only list services that can be described with a valid Mobius Network Service Descriptor. In future versions there are plans for supporting more generalized descriptors.
The remainder of this page is devoted to code examples of the Registrar API.
The following example illustrates how a service can be registered with the Registrar.
Port port = new Port("TCP",3940);
NetworkServiceDescriptor nsd = new
NetworkServiceDescriptor("MAKO://localhost","MAKO","localhost",port);
GridServiceResolver resolver = GridServiceResolver.getInstance();
GridService gs = resolver.getGridService("REGISTRAR://localhost");
ServiceRegistry reg = (ServiceRegistry)gs;
reg.registerService(nsd);
The next example shows how to request that the Registrar remove a service entry.
GridServiceResolver resolver = GridServiceResolver.getInstance();
GridService gs = resolver.getGridService("REGISTRAR://localhost");
ServiceRegistry reg = (ServiceRegistry)gs;
reg.removeService("MAKO://localhost");
The following code example illustrates how to look up a service by serviceId.
GridServiceResolver resolver = GridServiceResolver.getInstance();
GridService gs = resolver.getGridService("REGISTRAR://localhost");
ServiceRegistry reg = (ServiceRegistry)gs;
NetworkServiceDescriptor des = reg.lookupService("MAKO://localhost");
The following code example illustrates how to look up a service by service type.
ServiceRegistry handle =
(ServiceRegistry)GridServiceResolver.getInstance().getGridService("REGISTRAR://localhost");
List services = handle.lookupServices("MAKO");
for (int i=0; i<services.size(); i++) {
NetworkServiceDescriptor nsd = (NetworkServiceDescriptor) services.get(i);
System.out.println(nsd.toString());
}