|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jxtaimpl.Nest
This class implements the Nest interface and the AntListener interface as well. A GateServiceServer will notify its Nest instance upon receiving a new message containing an Ant via the method deliver(AntDescriptor).
Field Summary |
Fields inherited from interface anthill.nest.Nest |
NAME |
Constructor Summary | |
Nest(Factory fact)
Default constructor which instantiates a RequestSet and a Trail |
Method Summary | |
void |
addAntNeighbour(NestId id)
Add a new nest (peer) to the set of neighbours on behalf of an Ant client. |
void |
addClientNeighbour(NestId id)
Add a new nest (peer) to the set of neighbours on behalf of a Nest client. |
void |
addResource(Resource resource,
String species)
Add a resource to the Nest. |
void |
clear()
Restores the Nest instance to its initial state |
ResourceManager |
createResourceManager(String name,
String species)
Returns a reference to the Storage instance associated with the invoking ant's species. |
void |
deliver(AntDescriptor aDesc)
Passes an AntDescriptor to the Manager instance |
void |
downloadResource(AnthillResource res)
Method for downloading a resource from its originating nest. |
void |
finalize()
Method for cleaning up before being garbage collected |
Resource[] |
getAllResources()
This method will return all the resources locally stored in every storage. |
InputStream |
getInputStreamForResource(byte[] resID,
byte[] spec)
Returns the InputStream for reading the resource locally stored
and identified by the given resource ID resID . |
Manager |
getManager()
Return a reference to the Manager instance |
Neighbour[] |
getNeighbours()
Return an array of known neighbours |
NestId |
getNestId()
Returns the local Nest id |
RequestSet |
getRequestSet()
Return the RequestSet instance |
Resource |
getResource(Object request,
String species)
Return a Resource instance associated with the given key. |
ResourceManager |
getResourceManager(String name,
String species)
Returns a reference to the Storage instance associated with the invoking ant's species. |
Resource[] |
getResources(Object request,
String species)
Return the set of resources which satisfy the request, shaped as a Resource[]. |
void |
insert(Resource res,
String species)
Add a new resource to this Nest. |
void |
insRequest(RequestId rid,
String keywords)
Method to be used by higher level applications for spreading the knowledge about the local insertion of a new request. |
void |
leave()
Method present in the Interface declaration, but not need and so not implemented in the jxtaimpl implementation. |
protected void |
move(NestId id,
Ant ant,
int ttl)
Method invoked in order to send an Ant to another Nest. |
void |
removeNeighbour(NestId id)
Remove the entry associated with the provided NestId from the set of known neighbours |
void |
request(RequestId rid,
Object req,
ResponseListener lstn)
With this method a new request is passed to the Nest. |
protected void |
setAntFactory(AntFactory aFactory)
Set the AntFactory instance to use |
protected void |
setAnthillGroup(AnthillGroup grp)
Set the AnthillGroup instance. |
protected void |
setDownloadServicePipeAdv(PipeAdvertisement pipeAdv)
Stores all the information useful for locating this nest's input pipe waiting for resource downloading requests. |
protected void |
setGateServiceID(ModuleClassID id)
Method invoked by the AnthillPeerWS for setting the appropriate GateServiceID value which is needed in order to lookup the service itself. |
protected void |
setId(NestId nestId)
Set the nest id |
protected void |
setManager(Manager manager)
Set the Manager instance to use |
protected void |
setNeighbourManager(NeighbourManager mng)
Set the NeighbourManager |
protected void |
setPeerFinder(PeerFinder finder)
Set the PeerFinder instance |
protected void |
setTTL(int ttl)
Method invoked by the AnthillPeerWS for setting the appropriate TTL value which is read directly from the xml configuration file |
void |
shareResource(byte[] file,
String name,
String type,
String description,
String species)
This method has to be used by higher level application in order to share a resource in the Anthill network. |
void |
shareResource(File file,
String name,
String type,
String description,
String species)
This method has to be used by higher level application in order to share a resource in the Anthill network. |
void |
unShare(Resource res)
This method has to be invoked in order to unshare a resource locally stored. |
void |
updatePheromone(String antSpecies,
Object ph)
Updates the local pheromone object and stores it to disck in order to be able to recover from crashes. |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Nest(Factory fact)
fact
- The Factory
instace useful for reading in configuration parametersMethod Detail |
public void leave()
jxtaimpl
implementation.
public void clear()
clear
in interface Clearable
protected void setDownloadServicePipeAdv(PipeAdvertisement pipeAdv)
protected void setTTL(int ttl)
protected void setGateServiceID(ModuleClassID id)
public NestId getNestId()
getNestId
in interface Nest
public ResourceManager getResourceManager(String name, String species) throws StorageNotFoundException
null
would be returned.
Name is used for specifieing the storage type (i.e. Storage.DOC_STORAGE,
Storage.PHR_STORAGE, Storage.URL_STORAGE). At the moment
Storage.DOC_STORAGE, Trail.NAME, Storage.PHR_STORAGE are supported.
getResourceManager
in interface Nest
name
- The type of Storage
species
- The ant species
null
if no such resource manager is found.
StorageNotFoundException
public ResourceManager createResourceManager(String name, String species) throws ResourceManagerException
createResourceManager
in interface Nest
name
- The type of Storage
species
- The ant species
null
if no such resource manager is found.
ResourceManagerException
public void request(RequestId rid, Object req, ResponseListener lstn)
Object req
argument has to be a jxtaimpl.CmsStorage.Query
instance. If the request could be satisfied locally no Ants would be generated, otherwise
a set of ants will be sent across the network in order to satisfy
the request. The response will be passed to the specified listener.
request
in interface Nest
rid
- The ID identifieing the requestreq
- The request object. It has to be a jxtaimpl.storage.Query
instancelstn
- The listener to be notified when receiving repliespublic void insRequest(RequestId rid, String keywords) throws IOException
rid
- a valid request identifierkeywords
- a String of possible keywords for the resource
IOException
public void insert(Resource res, String species) throws CapacityException
res
- The jxtaimpl.storage.AnthillResource
instance describing the
resource to storespecies
- The ant species of the ant invoking this method
CapacityException
public void shareResource(File file, String name, String type, String description, String species) throws SpeciesNotFoundException, ResourceAlreadyStoredException, CapacityException
file
- The file containing the resource to sharename
- The resource logical nametype
- The resource typedescription
- A logical description of the reaourcespecies
- The species of the invoking ant
SpeciesNotFoundException
ResourceAlreadyStoredException
CapacityException
public void shareResource(byte[] file, String name, String type, String description, String species) throws SpeciesNotFoundException, ResourceAlreadyStoredException, CapacityException
file
- The byte
array containing the resource to sharename
- The resource logical nametype
- The resource typedescription
- A logical description of the reaourcespecies
- The species of the invoking ant
SpeciesNotFoundException
ResourceAlreadyStoredException
CapacityException
public Resource[] getAllResources()
null
will be returned.
public void addClientNeighbour(NestId id)
addClientNeighbour
in interface Nest
id
- the identifier of the neighbour to be addedpublic void addAntNeighbour(NestId id)
addAntNeighbour
in interface Nest
id
- the identifier of the neighbour to be addedpublic void removeNeighbour(NestId id)
removeNeighbour
in interface Nest
id
- the identifier of the neighbour to be removedpublic Neighbour[] getNeighbours()
getNeighbours
in interface Nest
public void deliver(AntDescriptor aDesc) throws RemoteException
deliver
in interface AntListener
aDesc
- the ant descriptor of the received ant
RemoteException
- added to the throw clause to respect
the conventions for remote interfaces.protected void setAnthillGroup(AnthillGroup grp)
protected void setId(NestId nestId)
protected void setPeerFinder(PeerFinder finder)
protected void setAntFactory(AntFactory aFactory)
protected void setManager(Manager manager)
public Manager getManager()
protected void setNeighbourManager(NeighbourManager mng)
public void updatePheromone(String antSpecies, Object ph)
Object ph
parameter.
antSpecies
- The species of the invoking antph
- The pheromone objectpublic Resource[] getResources(Object request, String species) throws StorageNotFoundException
Object request
has to be an instance of the class
jxtaimpl.CmsStorage.Query
.
The system will look for a Storage instance associated with the "species"
parameter. If such a Storage didn't exist a StorageNotFoundException would be thrown.
request
- The jxtaimpl.CmsStorage.Query
instancespecies
- The ant species
StorageNotFoundException
public Resource getResource(Object request, String species)
Object key
has to be an instance of the class
jxtaimpl.CmsStorage.Query
.
The system will look for a Storage instance associated with the "species"
parameter. If such a Storage didn't exist a StorageNotFoundException would be thrown.
request
- The jxtaimpl.CmsStorage.Query
instancespecies
- The ant speciespublic InputStream getInputStreamForResource(byte[] resID, byte[] spec) throws StorageNotFoundException
InputStream
for reading the resource locally stored
and identified by the given resource ID resID
. The spec
parameter refers to the ant species the Storage
is associated to.
resID
- The byte array identifieing the resource whose InputStream
will be returnedspec
- The byte array representing the ant species
StorageNotFoundException
public RequestSet getRequestSet()
public void unShare(Resource res) throws StorageNotFoundException
res
- The jxtaimpl.storage.AnthillResource
representing the
resource we want to unshare
StorageNotFoundException
public void addResource(Resource resource, String species) throws CapacityException
resource
- The AnthillResource
to addspecies
- The ant species
CapacityException
protected void move(NestId id, Ant ant, int ttl) throws IOException
id
- The jxtaimpl.ids.NestId
ID of the destination nestant
- the ant to be sent
IOException
public void finalize()
finalize
in class Object
public void downloadResource(AnthillResource res) throws CapacityException, StorageNotFoundException
res
- The jxtaimpl.storage.AnthillResource describing the resource
to be downloaded
CapacityException
StorageNotFoundException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |