|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectmessageServerP.Cache
public class Cache
Contains the MessageServer to User correspondence cached by the message server.
| Field Summary | |
|---|---|
private static Bootstrap |
bootstrap
The Bootstrap Server (must be set at startup with setBootstrap(Bootstrap bs) ) |
static BSForMSInterface |
BSInterf
The Bootstrap Server interface |
private static java.util.Vector<MessageServer> |
messageServers
The Message Servers. |
private static java.util.Vector<java.util.List<User>> |
nonManagedUsers
The list of users not managed by this MS but cached. |
private static java.util.Vector<SafeMSForMSInterface> |
safeMSInterfs
The Message Servers interfaces. |
| Constructor Summary | |
|---|---|
Cache()
|
|
| Method Summary | |
|---|---|
private static int |
addEmptyMS(MessageServer msToAdd)
Creates an empty message server with no users assigned to. |
private static void |
addToCache(User user,
MessageServer ms)
Updates the cache adding a new corrispondence between a user and the message server the user is located in. |
static void |
forwardMsg(Message msg)
Forwards a message to another Message Server (recipient must not be local). |
static Bootstrap |
getBS()
|
private static MessageServer |
getCachedMessageServer(User user)
Obtains from the cache the Message Server a user is assigned to. |
static MSForMSInterface |
getCachedMessageServerInterface(User user)
Obtains from the cache the Message Server interface used to communicate with a user. |
static int |
getCacheEntries()
Returns the number of user-MS corrispondences contained in the cache. |
static User |
getRemoteContact(User usr)
Retrives informations about a gossip servlet connection (IP address and port) in order to let anyone contact him directely. |
private static boolean |
refreshCache(User user)
Refreshes the cache for a user whose message server is not right (or is not cached), sending a query to the Bootstrap Server. |
static void |
remoteIsFriendOf(ManagedUser local,
User remote)
Checks if a remote user accepts a local user as a friend. |
static MessageServer |
removeFromCache(User user)
If exists, removes the correspondence between a user and the Message Server |
static void |
sendUser(ManagedUser user,
MessageServer ms)
Moves a given user (including its message queue and contact lists) from the local message to another. does not remove the user from the local ms. |
static void |
setBootstrap(Bootstrap bs)
Sets the bootstrap to globally use and creates the interface. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static BSForMSInterface BSInterf
private static Bootstrap bootstrap
private static java.util.Vector<java.util.List<User>> nonManagedUsers
private static java.util.Vector<SafeMSForMSInterface> safeMSInterfs
private static java.util.Vector<MessageServer> messageServers
| Constructor Detail |
|---|
public Cache()
| Method Detail |
|---|
public static void setBootstrap(Bootstrap bs)
throws java.rmi.NotBoundException,
java.rmi.RemoteException
bs - the bootstrap server
java.rmi.NotBoundException
java.rmi.RemoteExceptionpublic static Bootstrap getBS()
public static MSForMSInterface getCachedMessageServerInterface(User user)
user - the user whose Message Server interface must be searched for.
private static MessageServer getCachedMessageServer(User user)
user - the user whose Message Server must be searched for.
public static void forwardMsg(Message msg)
throws GenericErrorException,
java.rmi.RemoteException,
UserNotExistsException,
SystemErrorException,
NotAllowedException
msg - The message to forward.
GenericErrorException - if a communication error occurred.
java.rmi.RemoteException - if the communication with a message server failed.
UserNotExistsException - if the Bootstrap server cannot tell the user MS.
SystemErrorException - if a system error occurred (Bootstrap thinks the user is
assigned to a message server that does not actually manage it).
NotAllowedException - if the recipient does not accept messages from the sender.
public static void remoteIsFriendOf(ManagedUser local,
User remote)
throws GenericErrorException,
UserNotExistsException,
SystemErrorException,
java.rmi.RemoteException
local - the local userremote - the remote user (must not be local!)
java.rmi.RemoteException - if a communication problem with another server occurred.
GenericErrorException
UserNotExistsException
SystemErrorException
public static User getRemoteContact(User usr)
throws java.rmi.RemoteException,
UserNotExistsException,
SystemErrorException,
GenericErrorException
usr - the user to get the contact of.
java.rmi.RemoteException - if a problem occurred while connecting to the bootstrap server.
UserNotExistsException - if the user does not exist in the system.
SystemErrorException - if a system error occurred (Bootstrap thinks the user is
assigned to a message server that does not actually manage it).
GenericErrorException
private static boolean refreshCache(User user)
throws java.rmi.RemoteException,
GenericErrorException
user - the user whose cached message server is not right
java.rmi.RemoteException
GenericErrorException
public static void sendUser(ManagedUser user,
MessageServer ms)
throws GenericErrorException,
java.rmi.RemoteException,
AssignationNotAcceptedException
user - the user to movems - the message server to move the user to
GenericErrorException - if the message server could not be contacted.
java.rmi.RemoteException - if a communication problem occurred.
AssignationNotAcceptedException - if the server refused the user assignation.
private static void addToCache(User user,
MessageServer ms)
throws GenericErrorException
user - the userms - the Message Server
GenericErrorException
private static int addEmptyMS(MessageServer msToAdd)
throws GenericErrorException
msToAdd - the message server to add
GenericErrorException - if the message server could not be reached.public static MessageServer removeFromCache(User user)
user - the user to delete from cache
public static int getCacheEntries()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||