public class SpaceManagerImpl extends Object implements SpaceEventHandler, SpaceManager, SharedObjectListener
COMUNICATION_TIMEOUT_KEY, COMUNICATION_TIMEOUT_VALUE, DEFAULT_PEER_ROLE, PEER_ID_FILE
Constructor and Description |
---|
SpaceManagerImpl(ModuleContext context) |
Modifier and Type | Method and Description |
---|---|
void |
addSpaceListener(SpaceListener listener)
Add a new Space listener.
|
void |
cleanUpJoinRequest() |
void |
dispose()
Release all the resources
|
Map<String,SpaceDescriptor> |
getManagedSpaces()
This method return a map of Space managed by this MW instance
|
MatchingResult |
getMatchingPeers(Map<String,Serializable> filter)
A method for identifying a possible set of Peer in the space that can
be used for installing a part of the universAAL application.
The matching algorithm returns only the Peer of the space that match the following rules For each key of the Map with null value, an
attribute with any value must be available on the matching Peer
For each key of the Map with a not null value,
an attribute with same value must be available on the matching Peer. |
PeerCard |
getMyPeerCard()
This method returns the PeerCard of the current MW instance
|
Map<String,Serializable> |
getPeerAttributes(List<String> attributes,
PeerCard target) |
Map<String,PeerCard> |
getPeers()
This method return the list of neighborhood peers joined to the current
Space.
NOTE: The list does not contains the invoker |
Boolean |
getPendingSpace() |
ISpace |
getSpaceDefaultConfiguration() |
SpaceDescriptor |
getSpaceDescriptor()
This method returns the SpaceDescriptor of the Space where the MW
belongs to or null if the mw instance does not join to any Space.
|
Set<SpaceCard> |
getSpaces()
This method returns the list of Space discovered
|
SpaceStatus |
getSpaceStatus() |
long |
getWaitAfterJoinRequest() |
boolean |
init()
Initialize the Space Manager
|
void |
initSpace(ISpace spaceDefaultConfiguration)
Private method to manage the creation of a new Space starting from the
default configurations
|
void |
join(SpaceCard spaceCard)
method to join an existing Space according the configuration file: -to
configure the peering channel -to send a join request -to receive the
join response -to get the SpaceDescriptor -to configure the
communication channels
|
void |
joinRequest(SpaceCard spaceCard,
PeerCard peer)
This method allows the SpaceManager to manage a join request from a
remote peer.
|
void |
leaveRequest(SpaceDescriptor spaceDescriptor)
This method forces the peer to leave a Space
|
void |
leaveSpace(SpaceDescriptor spaceDescriptor)
Method used to leave an Space
|
void |
loadConfigurations(Dictionary configurations)
This method sets all the configurations for the SpaceManager
|
void |
mpaInstalled(SpaceDescriptor spaceDescriptor)
Called in order to alert the Space about the installation of a new MPA
|
void |
mpaInstalling(SpaceDescriptor spaceDescriptor)
Called in order to alert the Space about the installation of a new MPA
|
void |
newSpacesFound(Set<SpaceCard> spaceCards)
A new Space has been found
|
void |
peerFound(PeerCard peer)
Method called when a peer joins the Space managed by the
SpaceManager
|
void |
peerLost(PeerCard peer)
This method notifies to the coordinator that a peer wants to leave to the
Space
|
ISpace |
readSpaceDefaultConfigurations() |
void |
removeSpaceListener(SpaceListener listener)
Remove a Space Listener
|
void |
setListOfPeers(Map<String,PeerCard> peers)
This method allows to configure the set of peers that actually join the
Space managed or joined by this SpaceManager
|
void |
sharedObjectAdded(Object sharedObj,
Object removeHook) |
void |
sharedObjectRemoved(Object removeHook) |
void |
spaceEvent(SpaceStatus newStatus) |
void |
spaceJoined(SpaceDescriptor descriptor)
The method is called asynchronously from the bottom layer of the MW after
a previous join(...) request.
|
public SpaceManagerImpl(ModuleContext context)
public Map<String,SpaceDescriptor> getManagedSpaces()
SpaceManager
getManagedSpaces
in interface SpaceManager
public Map<String,PeerCard> getPeers()
SpaceManager
getPeers
in interface SpaceManager
public ISpace getSpaceDefaultConfiguration()
public Boolean getPendingSpace()
public long getWaitAfterJoinRequest()
public SpaceDescriptor getSpaceDescriptor()
SpaceManager
getSpaceDescriptor
in interface SpaceManager
public PeerCard getMyPeerCard()
SpaceManager
getMyPeerCard
in interface SpaceManager
public Set<SpaceCard> getSpaces()
SpaceManager
getSpaces
in interface SpaceManager
public boolean init()
Manager
public void initSpace(ISpace spaceDefaultConfiguration)
spaceDefaultConfiguration
- Default Space configurationspublic void join(SpaceCard spaceCard)
SpaceManager
join
in interface SpaceManager
public void cleanUpJoinRequest()
public void spaceJoined(SpaceDescriptor descriptor)
SpaceEventHandler
spaceJoined
in interface SpaceEventHandler
descriptor
- all the information about the joined Spacepublic ISpace readSpaceDefaultConfigurations()
public void loadConfigurations(Dictionary configurations)
Manager
loadConfigurations
in interface Manager
configurations
- Dictionary of configurationspublic void joinRequest(SpaceCard spaceCard, PeerCard peer)
SpaceEventHandler
joinRequest
in interface SpaceEventHandler
public void newSpacesFound(Set<SpaceCard> spaceCards)
SpaceEventHandler
newSpacesFound
in interface SpaceEventHandler
public void peerFound(PeerCard peer)
SpaceEventHandler
peerFound
in interface SpaceEventHandler
public void peerLost(PeerCard peer)
SpaceEventHandler
peerLost
in interface SpaceEventHandler
public void sharedObjectAdded(Object sharedObj, Object removeHook)
sharedObjectAdded
in interface SharedObjectListener
public void sharedObjectRemoved(Object removeHook)
sharedObjectRemoved
in interface SharedObjectListener
public void leaveRequest(SpaceDescriptor spaceDescriptor)
SpaceEventHandler
leaveRequest
in interface SpaceEventHandler
public void leaveSpace(SpaceDescriptor spaceDescriptor)
SpaceManager
leaveSpace
in interface SpaceManager
public void dispose()
Manager
public void addSpaceListener(SpaceListener listener)
SpaceManager
addSpaceListener
in interface SpaceManager
public void removeSpaceListener(SpaceListener listener)
SpaceManager
removeSpaceListener
in interface SpaceManager
public void setListOfPeers(Map<String,PeerCard> peers)
SpaceEventHandler
setListOfPeers
in interface SpaceEventHandler
peers
- Map of peerspublic SpaceStatus getSpaceStatus()
public void mpaInstalled(SpaceDescriptor spaceDescriptor)
SpaceEventHandler
mpaInstalled
in interface SpaceEventHandler
public void mpaInstalling(SpaceDescriptor spaceDescriptor)
SpaceEventHandler
mpaInstalling
in interface SpaceEventHandler
public void spaceEvent(SpaceStatus newStatus)
spaceEvent
in interface SpaceEventHandler
public MatchingResult getMatchingPeers(Map<String,Serializable> filter)
SpaceManager
Map
with null
value, an
attribute with any value must be available on the matching PeerMap
with a not null
value,
an attribute with same value must be available on the matching Peer. The
#equals(Object)
is used for checking if the value are the
sameMap
filter is set to { container=Karaf, tool=OSGI,
version=null }MatchingResult
will contain the peers C
and E, while the other were discarded because
getMatchingPeers
in interface SpaceManager
filter
- a Map
that contains a pair of String
as Key
and Object
as value which will be used for looking for
matching among the one available on the spaceMatchingResult
representing the filtering resultpublic Map<String,Serializable> getPeerAttributes(List<String> attributes, PeerCard target)
getPeerAttributes
in interface SpaceManager
attributes
- The list of attribute to get value,target
- PeerCard
the peer card that identifies the peer that
we want to read attribute fromMap
with the pair String
, Serializable
representing the attribute requested along with its value.Copyright © 2018 universAAL Consortium. All rights reserved.