- All Implemented Interfaces:
- TaskManager.Task, Runnable
- Enclosing class:
- ServiceDiscoveryManager.LookupCacheImpl
private final class ServiceDiscoveryManager.LookupCacheImpl.NewOldServiceTask
extends ServiceDiscoveryManager.ServiceIdTask
Task class used to asynchronously process the service state
("snapshot"), matching this cache's template, that was retrieved
from the given lookup service.
After retrieving the snapshot S, the LookupTask queues an instance
of this task for each service referenced in S. This task determines
if the given service is an already-discovered service (is currently
in this cache's serviceIdMap), or is a new service. This task
handles the service differently, depending on whether the service
is a new or old.
a. if the item is old, then this task will:
- compare the given item from the snapshot to the UN-filtered
item in given itemReg
if(same version but attributes have changed)
send changed event
else if( version has changed )
send removed event followed by added event
else
do nothing
- apply the filter to the given item
if(filter fails)
send removed event
else if(filter passes)
set the filtered item in the itemReg in the map
else if (filter is indefinite)
discard item
send removed event
queue another filter attempt for later
b. if the given item is newly discovered, then this task will:
- create a new ServiceItemReg containing the given item
- place the new itemReg in the serviceIdMap
- apply the filter to the given item
if(filter fails)
remove the item from the map but
send NO removed event
else if(filter passes)
send added event for the FILTERED item
else if (filter is indefinite)
discard item
queue another filter attempt for later but
send NO removed event