| java.lang.Object org.cougaar.core.service.wp.WhitePagesService
WhitePagesService | abstract public class WhitePagesService implements Service(Code) | | The white pages service provides access to the distributed name
server.
The primary function of the white pages is to allow agents
to register their message transport addresses and lookup the
addresses of other agents. This service is the client-side
resolver and is backed by a cache.
The main method of this class is:
public abstract Response submit(Request req);
This submits an request with an asynchronous response. The
caller can attach callbacks to the response or block until
the response result is set. All the other methods of the
WhitePagesService are based upon the above "submit" method.
The white pages service currently does not support a "listener"
API to watch for changes, primarily due to scalability concerns.
|
Method Summary | |
final public Response | assertSubmit(Request req, long timeout) Submit a request and return the response if it is completed
within the request's timeout and successful, otherwise throw
an exception. | final public void | bind(AddressEntry ae) | final public void | bind(AddressEntry ae, Callback callback) | final public void | bind(AddressEntry ae, long timeout) | final public boolean | flush(String name, long minAge, AddressEntry ae, boolean uncache, boolean prefetch) | final public void | flush(String name, long minAge, AddressEntry ae, boolean uncache, boolean prefetch, Callback callback) | final public boolean | flush(String name, long minAge, AddressEntry ae, boolean uncache, boolean prefetch, long timeout) | final public AddressEntry | get(String name, String type) | final public void | get(String name, String type, Callback callback) | final public AddressEntry | get(String name, String type, long timeout) | final public AddressEntry[] | get(String name) | final public AddressEntry | get(String name, Application app, String scheme) | final public AddressEntry[] | get(String name, long timeout) | final public AddressEntry | get(String name, Application app, String scheme, long timeout) | final public Map | getAll(String name) | final public void | getAll(String name, Callback callback) | final public Map | getAll(String name, long timeout) | final public void | hint(AddressEntry ae) | final public void | hint(AddressEntry ae, Callback callback) | final public void | hint(AddressEntry ae, long timeout) | final public Set | list(String suffix) | final public void | list(String suffix, Callback callback) | final public Set | list(String suffix, long timeout) | final public void | rebind(AddressEntry ae) | final public void | rebind(AddressEntry ae, Callback callback) | final public void | rebind(AddressEntry ae, long timeout) | final public Response | submit(Request req, Callback c) Submit with a callback. | abstract public Response | submit(Request req) Submit a request, get back a "future reply" response. | final public void | unbind(AddressEntry ae) | final public void | unbind(AddressEntry ae, Callback callback) | final public void | unbind(AddressEntry ae, long timeout) | final public void | unhint(AddressEntry ae) | final public void | unhint(AddressEntry ae, Callback callback) | final public void | unhint(AddressEntry ae, long timeout) |
assertSubmit | final public Response assertSubmit(Request req, long timeout) throws Exception(Code) | | Submit a request and return the response if it is completed
within the request's timeout and successful, otherwise throw
an exception.
|
submit | final public Response submit(Request req, Callback c)(Code) | | Submit with a callback.
Equivalent to:
Response res = submit(req);
res.addCallback(c);
return res;
|
submit | abstract public Response submit(Request req)(Code) | | Submit a request, get back a "future reply" response.
An example cache-only non-blocking usage:
try {
Map m = wps.getAll("foo", -1);
System.out.println("cached entries for foo: "+m);
} catch (Exception e) {
System.out.println("failed: "+e);
}
An example asynchronous "callback" usage:
Request req = new Request.GetAll(Request.NONE, "foo");
Response r = wps.submit(req);
Callback callback = new Callback() {
public void execute(Response res) {
// note that (res == r)
if (res.isSuccess()) {
Map m = ((Response.GetAll) res).getAddressEntries();
System.out.println("got all entries for foo: "+m);
} else {
System.out.println("failed: "+res);
}
}
};
// add callback, will execute immediately if
// there is already an answer
r.addCallback(callback);
// keep going
Parameters: req - the non-null request a non-null response |
|
|