|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.service.jini.lookup.AbstractCachingServiceClient<S>
S - A class or interface implemented by all services whose proxies
will be discovered and cached by this class.public abstract class AbstractCachingServiceClient<S extends Remote>
Abstract base class for a jini client which uses a LookupCache to
reduce round trips to the discovered ServiceRegistrars for a
specific class of services.
| Field Summary | |
|---|---|
protected long |
cacheMissTimeout
Timeout for remote lookup on cache miss (milliseconds). |
protected net.jini.lookup.ServiceItemFilter |
filter
The filter provided to the ctor. |
protected static org.apache.log4j.Logger |
log
|
protected net.jini.lookup.LookupCache |
lookupCache
A LookupCache that will be populated with all services that match
a filter. |
protected ServiceCache |
serviceCache
Provides direct cached lookup of discovered services matching both the template and the optional filter by their
ServiceID. |
protected net.jini.core.lookup.ServiceTemplate |
template
The template provided to the ctor. |
| Constructor Summary | |
|---|---|
AbstractCachingServiceClient(net.jini.lookup.ServiceDiscoveryManager serviceDiscoveryManager,
net.jini.lookup.ServiceDiscoveryListener serviceDiscoveryListener,
Class serviceIface,
net.jini.core.lookup.ServiceTemplate template,
net.jini.lookup.ServiceItemFilter filter,
long cacheMissTimeout)
Sets up service discovery for the designed class of services. |
|
| Method Summary | |
|---|---|
void |
destroyDiscoveredServices(ExecutorService executorService,
net.jini.lookup.ServiceItemFilter filter)
Destroy all services in the cache which match the filter. |
protected boolean |
destroyService(net.jini.core.lookup.ServiceItem serviceItem)
Sends RemoteDestroyAdmin.destroy() request to the service. |
net.jini.lookup.LookupCache |
getLookupCache()
An object that provides cached lookup of discovered services matching both the template and the optional filter. |
S |
getService()
Return an arbitrary service from the cache -or- null if
there is no such service in the cache and a remote lookup times out. |
S |
getService(net.jini.lookup.ServiceItemFilter filter)
Return the proxy for an arbitrary service from the cache -or- null if there is no such service in the cache and a remote
lookup times out. |
ServiceCache |
getServiceCache()
An object that provides direct cached lookup of discovered services matching both the template and the optional filter by
their ServiceID. |
protected net.jini.lookup.ServiceDiscoveryManager |
getServiceDiscoveryManager()
|
net.jini.core.lookup.ServiceItem |
getServiceItem(net.jini.lookup.ServiceItemFilter filter)
Return an arbitrary ServiceItem from the cache -or-
null if there is no such service in the cache and a remote
lookup times out. |
net.jini.core.lookup.ServiceItem |
getServiceItem(UUID serviceUUID)
Return the ServiceItem associated with the UUID. |
net.jini.core.lookup.ServiceItem[] |
getServiceItems(int maxCount,
net.jini.lookup.ServiceItemFilter filter)
Return an array ServiceItems for up to maxCount
discovered services which satisify the optional filter. |
UUID[] |
getServiceUUIDs(int maxCount,
net.jini.lookup.ServiceItemFilter filter)
Return an array UUIDs for up to maxCount discovered
services which satisify the optional filter. |
void |
shutdownDiscoveredServices(ExecutorService executorService,
net.jini.lookup.ServiceItemFilter filter,
boolean immediateShutdown)
Shutdown all services in the cache which match the filter. |
protected boolean |
shutdownService(net.jini.core.lookup.ServiceItem serviceItem,
boolean immediateShutdown)
Sends a shutdown request to the service. |
void |
terminate()
Terminates asynchronous processing by the LookupCache. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final transient org.apache.log4j.Logger log
protected final net.jini.lookup.LookupCache lookupCache
LookupCache that will be populated with all services that match
a filter. This is used to keep track of all services registered with any
ServiceRegistrar to which the client is listening.
protected final net.jini.core.lookup.ServiceTemplate template
protected final net.jini.lookup.ServiceItemFilter filter
protected final long cacheMissTimeout
protected final ServiceCache serviceCache
template and the optional filter by their
ServiceID.
| Constructor Detail |
|---|
public AbstractCachingServiceClient(net.jini.lookup.ServiceDiscoveryManager serviceDiscoveryManager,
net.jini.lookup.ServiceDiscoveryListener serviceDiscoveryListener,
Class serviceIface,
net.jini.core.lookup.ServiceTemplate template,
net.jini.lookup.ServiceItemFilter filter,
long cacheMissTimeout)
throws RemoteException
serviceDiscoveryManager - Used to discovery services matching the template and filter.serviceDiscoveryListener - Service discovery notices are delivered to this class.serviceIface - The most interesting interface on the service (this is used
for log messages).template - A template used to restrict the services which are discovered
and cached by this class (required).filter - A filter used to further restrict the services which are
discovered and cached by this class (optional).cacheMissTimeout - The timeout in milliseconds that the client will await the
discovery of a service if there is a cache miss.
RemoteException - if we could not setup the LookupCache| Method Detail |
|---|
protected net.jini.lookup.ServiceDiscoveryManager getServiceDiscoveryManager()
public final ServiceCache getServiceCache()
template and the optional filter by
their ServiceID.
public final net.jini.lookup.LookupCache getLookupCache()
template and the optional filter.
public final void terminate()
LookupCache.
public final S getService()
null if
there is no such service in the cache and a remote lookup times out.
public final S getService(net.jini.lookup.ServiceItemFilter filter)
null if there is no such service in the cache and a remote
lookup times out.
filter - An optional filter. If given it will be applied in addition to
the optional filter specified to the ctor.public final net.jini.core.lookup.ServiceItem getServiceItem(net.jini.lookup.ServiceItemFilter filter)
ServiceItem from the cache -or-
null if there is no such service in the cache and a remote
lookup times out.
filter - An optional filter. If given it will be applied in addition to
the optional filter specified to the ctor.public final net.jini.core.lookup.ServiceItem getServiceItem(UUID serviceUUID)
ServiceItem associated with the UUID.
serviceUUID - The service UUID.
null otherwise.
public net.jini.core.lookup.ServiceItem[] getServiceItems(int maxCount,
net.jini.lookup.ServiceItemFilter filter)
ServiceItems for up to maxCount
discovered services which satisify the optional filter.
maxCount - The maximum #of data services whose UUID will be
returned. When zero (0) the UUID for all known data
services will be returned.filter - An optional filter. If given it will be applied in addition to
the optional filter specified to the ctor.
ServiceItems for matching discovered
services.
public UUID[] getServiceUUIDs(int maxCount,
net.jini.lookup.ServiceItemFilter filter)
UUIDs for up to maxCount discovered
services which satisify the optional filter.
maxCount - The maximum #of data services whose UUID will be
returned. When zero (0) the UUID for all known data
services will be returned.filter - An optional filter. If given it will be applied in addition to
the optional filter specified to the ctor.
UUIDs for matching discovered
services.
public void destroyDiscoveredServices(ExecutorService executorService,
net.jini.lookup.ServiceItemFilter filter)
throws InterruptedException
RemoteDestroyAdmin.destroy() request.
filter - An optional filter. When null all services in
the cache will be destroyed.
InterruptedException
public void shutdownDiscoveredServices(ExecutorService executorService,
net.jini.lookup.ServiceItemFilter filter,
boolean immediateShutdown)
throws InterruptedException
RemoteDestroyAdmin.shutdown() or
RemoteDestroyAdmin.shutdownNow() request.
filter - An optional filter. When null all services in
the cache will be shutdown.immediateShutdown - if shutdownNow() should be used.
InterruptedException
protected boolean destroyService(net.jini.core.lookup.ServiceItem serviceItem)
throws Exception
RemoteDestroyAdmin.destroy() request to the service. Note
that the service may process the request asynchronously.
serviceItem - The service item.
true if we were able to send that message to the
service.
Exception - if anything goes wrong.
protected boolean shutdownService(net.jini.core.lookup.ServiceItem serviceItem,
boolean immediateShutdown)
throws Exception
RemoteDestroyAdmin.shutdown() or
RemoteDestroyAdmin.shutdownNow() as indicated by the parameter.
Note that the service may process the shutdown request asynchronously.
serviceItem - The service item.immediateShutdown - When true uses shutdownNow().
true if we were able to send the request to the
service.
Exception - if anything goes wrong.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||