cs138.service
Interface ManagerService

All Superinterfaces:
java.rmi.Remote

public interface ManagerService
extends java.rmi.Remote

The ManagerService provides utilities for getting all the registered nodes and information associated with the node state.

Author:
csiden

Nested Class Summary
static interface ManagerService.ManagerListener
           
 
Method Summary
 void addManagerListener(ManagerService.ManagerListener lis)
          Adds a listener for the manager which fires on certain events
 java.util.List<java.lang.String> allGroups(java.lang.Class<?> type)
          Returns the list of all groups that are registered with the manager for the specified type of node.
 java.util.List<java.lang.String> allGroups(java.lang.String type)
          Returns the list of all groups that are registered with the manager for the specified type of node.
<T extends ManageableNode>
java.util.List<java.lang.String>
allIDs(java.lang.Class<T> type, java.lang.String group)
          Returns a list of all the ids of the nodes of a specific type in a specific group.
<T extends ManageableNode>
java.util.List<java.lang.String>
allIDs(java.lang.String type, java.lang.String group)
          Returns a list of all the ids of the nodes of a specific type in a specific group.
<T extends ManageableNode>
java.util.List<NodeManager<T>>
allNodes(java.lang.Class<T> type)
          Returns a list of all NodeManager wrappers for all the nodes based upon the specified class type.
<T extends ManageableNode>
java.util.List<NodeManager<T>>
allNodes(java.lang.Class<T> type, java.lang.String group)
          Returns the list of all the NodeManager wrappers for all the nodes in a specific group of a specific type.
<T extends ManageableNode>
java.util.List<NodeManager<T>>
allNodes(java.lang.String type)
          Returns a list of all NodeManager wrappers for all the nodes based upon the specified class type.
<T extends ManageableNode>
java.util.List<NodeManager<T>>
allNodes(java.lang.String type, java.lang.String group)
          Returns the list of all the NodeManager wrappers for all the nodes in a specific group of a specific type.
 java.util.List<java.lang.String> allTypes()
          Provides a list of all the different types of nodes that are registered with the manager.
 void clear()
          Clears the current set of registered nodes and groups.
 java.lang.String getClient(java.lang.String id, java.lang.Class<?> type)
          Returns the ip address of the host that is running the node specified by id and type
 java.lang.String getClient(java.lang.String id, java.lang.String type)
          Returns the ip address of the host that is running the node specified by id and type
 java.lang.String getGroup(java.lang.String id, java.lang.Class<?> type)
          Return the group that the node is in if the String exists.
 NodeMonitor getProxyMonitor(java.lang.Class<? extends NodeMonitor> interType, java.lang.Class<? extends ManageableNode> type)
          Obtains the node specific monitor interface for the specified node type.
<T extends ManageableNode>
NodeManager<T>
lookupNode(java.lang.String id, java.lang.Class<T> type)
          Provides a facility for looking up and obtaining references to nodes.
<T extends ManageableNode>
NodeManager<T>
lookupNode(java.lang.String id, java.lang.String type)
          Provides a facility for looking up and obtaining references to nodes.
 void ping()
          Pings all nodes to check and see if they are currently reachable.
<T extends ManageableNode>
NodeManager<T>
randomNode(java.lang.Class<T> type)
          Provides a mechanism for getting an arbitrary node of a specific type.
<T extends ManageableNode>
NodeManager<T>
randomNode(java.lang.Class<T> type, java.lang.String group)
          Provides a mechanism for getting an arbitrary node of a specific type.
<T extends ManageableNode>
java.lang.String
register(NodeManager<T> node, java.lang.Class<T> type)
          Registers a new node with the system and assigns the nodes identifier.
<T extends ManageableNode>
java.lang.String
register(NodeManager<T> node, java.lang.Class<T> type, java.lang.String group)
          Registers a new node with the system and assigns the nodes identifier.
<T extends ManageableNode>
void
registerMonitor(NodeMonitor monitor, java.lang.Class<T> type)
          Registers a monitor for the specific type of node to receive callbacks.
 boolean removeManagerListener(ManagerService.ManagerListener lis)
          Removes a ManagerListener from the set that is registered
<T extends ManageableNode>
boolean
unregister(java.lang.String id, java.lang.Class<T> type)
          Unregisters the specified node if it has been registered.
<T extends ManageableNode>
boolean
unregister(java.lang.String id, java.lang.String type)
           
<T extends ManageableNode>
boolean
unregisterMonitor(NodeMonitor monitor, java.lang.Class<T> type)
          Registers a monitor for the specific type of node to receive callbacks.
 

Method Detail

lookupNode

<T extends ManageableNode> NodeManager<T> lookupNode(java.lang.String id,
                                                     java.lang.Class<T> type)
                                                 throws java.rmi.RemoteException
Provides a facility for looking up and obtaining references to nodes. This does not directly return the node in question, but rather the NodeManager wrapper around it.

Type Parameters:
T - The type of node you are looking for
Parameters:
id - The identifier for the node
type - The class type of the node
Returns:
The NodeManager for the node you requested or null if there is no node with that id and type
Throws:
java.rmi.RemoteException

lookupNode

<T extends ManageableNode> NodeManager<T> lookupNode(java.lang.String id,
                                                     java.lang.String type)
                                                 throws java.rmi.RemoteException
Provides a facility for looking up and obtaining references to nodes. This does not directly return the node in question, but rather the NodeManager wrapper around it.

Type Parameters:
T - The type of node you are looking for
Parameters:
id - The identifier for the node
type - The String representation of the fully qualified path.
Returns:
The NodeManager for the node you requested or null if there is no node with that id and type
Throws:
java.rmi.RemoteException

randomNode

<T extends ManageableNode> NodeManager<T> randomNode(java.lang.Class<T> type)
                                                 throws java.rmi.RemoteException
Provides a mechanism for getting an arbitrary node of a specific type. This returns something from the default group. As the lookup methods, it returns the NodeManager wrapper around the node iteslf.

Type Parameters:
T - The type of node you are looking for
Parameters:
type - The class corresponding to the type of node you want
Returns:
The NodeManager for the node you requested or null if there are no nodes of that type
Throws:
java.rmi.RemoteException

randomNode

<T extends ManageableNode> NodeManager<T> randomNode(java.lang.Class<T> type,
                                                     java.lang.String group)
                                                 throws java.rmi.RemoteException
Provides a mechanism for getting an arbitrary node of a specific type. This returns something from the specified group. As the lookup methods, it returns the NodeManager wrapper around the node itself.

Type Parameters:
T - The type of node you are looking for
Parameters:
type - The class corresponding to the type of node you want
group - The group you want a node from
Returns:
The NodeManager for the node you requested or null if there are no nodes in that type with that group.
Throws:
java.rmi.RemoteException

allTypes

java.util.List<java.lang.String> allTypes()
                                          throws java.rmi.RemoteException
Provides a list of all the different types of nodes that are registered with the manager. The list corresponds to the full package names of each node.

Returns:
The List of full package names of each registered node type
Throws:
java.rmi.RemoteException

allGroups

java.util.List<java.lang.String> allGroups(java.lang.Class<?> type)
                                           throws java.rmi.RemoteException
Returns the list of all groups that are registered with the manager for the specified type of node.

Parameters:
type - The class type of node we are looking for groups based upon
Returns:
A String list of all group names for that node type.
Throws:
java.rmi.RemoteException

allGroups

java.util.List<java.lang.String> allGroups(java.lang.String type)
                                           throws java.rmi.RemoteException
Returns the list of all groups that are registered with the manager for the specified type of node.

Parameters:
type - The full package name of the type that we want
Returns:
A String list of all group names for that node type.
Throws:
java.rmi.RemoteException

allNodes

<T extends ManageableNode> java.util.List<NodeManager<T>> allNodes(java.lang.Class<T> type)
                                                               throws java.rmi.RemoteException
Returns a list of all NodeManager wrappers for all the nodes based upon the specified class type.

Type Parameters:
T - The type of node you are looking for
Parameters:
type - The class object for the specified node
Returns:
The list of all nodes of that type.
Throws:
java.rmi.RemoteException

allNodes

<T extends ManageableNode> java.util.List<NodeManager<T>> allNodes(java.lang.String type)
                                                               throws java.rmi.RemoteException
Returns a list of all NodeManager wrappers for all the nodes based upon the specified class type.

Type Parameters:
T - The type of node you are looking for
Parameters:
type - The string fully qualified package name
Returns:
The list of all nodes of that type.
Throws:
java.rmi.RemoteException

allNodes

<T extends ManageableNode> java.util.List<NodeManager<T>> allNodes(java.lang.Class<T> type,
                                                                   java.lang.String group)
                                                               throws java.rmi.RemoteException
Returns the list of all the NodeManager wrappers for all the nodes in a specific group of a specific type.

Type Parameters:
T - The type of node you are looking for
Parameters:
type - The class object for the specified node
group - The group that you are looking for
Returns:
The List of allNodes of the specified type in the specified group
Throws:
java.rmi.RemoteException

allNodes

<T extends ManageableNode> java.util.List<NodeManager<T>> allNodes(java.lang.String type,
                                                                   java.lang.String group)
                                                               throws java.rmi.RemoteException
Returns the list of all the NodeManager wrappers for all the nodes in a specific group of a specific type.

Type Parameters:
T - The type of node you are looking for
Parameters:
type - The class object for the specified node
group - The group that you are looking for
Returns:
The List of allNodes of the specified type in the specified group
Throws:
java.rmi.RemoteException

allIDs

<T extends ManageableNode> java.util.List<java.lang.String> allIDs(java.lang.Class<T> type,
                                                                   java.lang.String group)
                                        throws java.rmi.RemoteException
Returns a list of all the ids of the nodes of a specific type in a specific group.

Type Parameters:
T - The type of node you are looking for
Parameters:
type - The class object for the specified node
group - The group we want nodes from
Returns:
A list of identifiers for every node that is registered of the specified node type in the specified group.
Throws:
java.rmi.RemoteException

allIDs

<T extends ManageableNode> java.util.List<java.lang.String> allIDs(java.lang.String type,
                                                                   java.lang.String group)
                                        throws java.rmi.RemoteException
Returns a list of all the ids of the nodes of a specific type in a specific group.

Type Parameters:
T - The type of node you are looking for
Parameters:
type - The fully qualified package name of the class
group - The group we want nodes from
Returns:
A list of identifiers for every node that is registered of the specified node type in the specified group.
Throws:
java.rmi.RemoteException

register

<T extends ManageableNode> java.lang.String register(NodeManager<T> node,
                                                     java.lang.Class<T> type)
                          throws java.rmi.RemoteException
Registers a new node with the system and assigns the nodes identifier. It assigns the node into the default group for the node type

Type Parameters:
T - The type of node you are registering
Parameters:
node - The NodeManager wrapper around a node that we care about using.
type - The type of the node object that we are using
Returns:
The identifier for the node
Throws:
java.rmi.RemoteException

register

<T extends ManageableNode> java.lang.String register(NodeManager<T> node,
                                                     java.lang.Class<T> type,
                                                     java.lang.String group)
                          throws java.rmi.RemoteException
Registers a new node with the system and assigns the nodes identifier. It assigns the node into the default group for the node type

Type Parameters:
T - The type of node you are registering
Parameters:
node - The NodeManager wrapper around a node that we care about using.
type - The type of the node object that we are using
group - The group to register the node in
Returns:
The identifier for the node
Throws:
java.rmi.RemoteException

unregister

<T extends ManageableNode> boolean unregister(java.lang.String id,
                                              java.lang.Class<T> type)
                   throws java.rmi.RemoteException
Unregisters the specified node if it has been registered.

Type Parameters:
T - The type of node we are going to unregister
Parameters:
id - The identifier of the node
type - The class object of the node we are unregistering
Returns:
True if it succeeded in unregistering it, false otherwise.
Throws:
java.rmi.RemoteException

unregister

<T extends ManageableNode> boolean unregister(java.lang.String id,
                                              java.lang.String type)
                   throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

registerMonitor

<T extends ManageableNode> void registerMonitor(NodeMonitor monitor,
                                                java.lang.Class<T> type)
                     throws java.rmi.RemoteException
Registers a monitor for the specific type of node to receive callbacks.

Type Parameters:
T - The type of node that we are registering for
Parameters:
monitor - The monitor that we are registering
type - The class object we are registering with
Throws:
java.rmi.RemoteException

unregisterMonitor

<T extends ManageableNode> boolean unregisterMonitor(NodeMonitor monitor,
                                                     java.lang.Class<T> type)
                          throws java.rmi.RemoteException
Registers a monitor for the specific type of node to receive callbacks.

Type Parameters:
T - The type of node that we are registering for
Parameters:
monitor - The monitor that we are registering
type - The class object we are registering with
Returns:
True if the unregister succeeded.
Throws:
java.rmi.RemoteException

getGroup

java.lang.String getGroup(java.lang.String id,
                          java.lang.Class<?> type)
                          throws java.rmi.RemoteException
Return the group that the node is in if the String exists.

Parameters:
id - The id of the node in question
type - The class object of the node we are working with
Returns:
The group that the node is in
Throws:
java.rmi.RemoteException

getClient

java.lang.String getClient(java.lang.String id,
                           java.lang.Class<?> type)
                           throws java.rmi.RemoteException
Returns the ip address of the host that is running the node specified by id and type

Parameters:
id - The identifier for the node in question.
type - The class object of the node we are interested in
Returns:
The ip address of the host.
Throws:
java.rmi.RemoteException

getClient

java.lang.String getClient(java.lang.String id,
                           java.lang.String type)
                           throws java.rmi.RemoteException
Returns the ip address of the host that is running the node specified by id and type

Parameters:
id - The identifier for the node in question.
type - The fully qualified package name of the type
Returns:
The ip address of the host.
Throws:
java.rmi.RemoteException

addManagerListener

void addManagerListener(ManagerService.ManagerListener lis)
                        throws java.rmi.RemoteException
Adds a listener for the manager which fires on certain events

Parameters:
lis - The listener to add
Throws:
java.rmi.RemoteException

removeManagerListener

boolean removeManagerListener(ManagerService.ManagerListener lis)
                              throws java.rmi.RemoteException
Removes a ManagerListener from the set that is registered

Parameters:
lis - The ManagerListener to remove
Returns:
True if the removal succeeded, false otherwise.
Throws:
java.rmi.RemoteException

clear

void clear()
           throws java.rmi.RemoteException
Clears the current set of registered nodes and groups.

Throws:
java.rmi.RemoteException

ping

void ping()
          throws java.rmi.RemoteException
Pings all nodes to check and see if they are currently reachable.

Throws:
java.rmi.RemoteException

getProxyMonitor

NodeMonitor getProxyMonitor(java.lang.Class<? extends NodeMonitor> interType,
                            java.lang.Class<? extends ManageableNode> type)
                            throws java.rmi.RemoteException
Obtains the node specific monitor interface for the specified node type.

Parameters:
interType - The class object of the node interface that we want to extend
type - The type of node that we are interacting it.
Returns:
The monitor to install for the specified node type in its initialize
Throws:
java.rmi.RemoteException