JAC project
AOPSYS
CEDRIC & LIP6 labs

org.objectweb.jac.core.dist
Class Topology

java.lang.Object
  |
  +--org.objectweb.jac.core.dist.Topology
All Implemented Interfaces:
Serializable

public class Topology
extends Object
implements Serializable

This class defines a generic topology where nodes are a set of reachable containers.

It is used by the distribution aspect to define distribution, deployment, and replication schemes.

See Also:
RemoteContainer, Serialized Form

Field Summary
 boolean bootstrapFlag
           
 List containers
          Store the containers of the topology.
protected static Topology globalTopology
          Store the gobal topology of the JAC distributed system.
 List nameReps
          Store the remote references on the name repository for optimization matter.
 
Constructor Summary
Topology()
          This constructor builds a topology and set it to global if a global topology does not exist yet.
Topology(RemoteContainer[] someContainers)
          Builds a topology from a set of containers.
Topology(String[] someNames)
          Builds a topology with the given container identifiers.
 
Method Summary
 void addContainer(RemoteContainer container)
          Add a container to the topology if not already present.
 void addContainer(String container)
          Adds a container from its name.
 void addContainers(RemoteContainer[] someContainers)
          Add a set of containers to the topology.
 boolean containsLocal()
          Tells if the current topology contains the local container.
 int countContainers()
          Returns the number of containers in this topology.
 void createNameReps()
          Creates the remote references on the name repositories.
 void dump()
          Dump the containers of the topology.
 boolean exist(String name)
          Says if an object exist on one of the container of the topology (excluding the local one).
protected  void fireTopologyChangeEvent()
          Notifies everybody that the topology changed.
static Topology get()
          This method returns the gobal topology of the JAC distributed middleware.
 RemoteContainer getContainer(int index)
          Returns a given container.
 RemoteContainer getContainer(String name)
          Gets a container from its name.
 int getContainerIndex(RemoteContainer container)
          Get the index of a container.
 int getContainerIndex(String name)
          Get the index of a container from its name.
 int[] getContainerIndexes(RE regexp)
          Get the indexes of some container regarding a regular expression on the name.
 int[] getContainerIndexes(String[] names)
          Get the indexes of some container names.
 RemoteContainer[] getContainers()
          Returns all the containers of the topology.
 RemoteContainer[] getContainers(RE regexp)
          Get some containers regarding a regular expression on the name.
 RemoteContainer[] getDistContainers()
          Returns the container of the topology minus the local one if any.
 RemoteContainer getFirstContainer(String sregexp)
          This method returns the first container that matches the host expression.
static Topology getPartialTopology(RE regexp)
          This method returns a topology with all the containers that match the regular expression within the global topology of org.objectweb.jac.
static Topology getPartialTopology(String regexp)
          This method returns a topology with all the containers that match the regular expression within the global topology of org.objectweb.jac.
 Vector getReplicas(Wrappee localObject)
          Gets a set of remote references on all the remote replicas of a local object for the current topology.
static Topology getTopology(Application application)
          Returns the topology defined for the given application.
 boolean isContainer(RemoteContainer container)
          Check if the current topology contains the given container.
 void launchGUI()
          Start the admin GUI
 void launchGUI(String programName)
          Launches the administration GUI on the local container.
 void reloadAspect(String applicationName, String aspectName)
          Reload the configuration of an aspect
 void removeContainer(RemoteContainer container)
          Remove a container from the topology.
 void replaceContainer(int index, RemoteContainer newContainer)
          Replace a container at a given index.
 void replaceContainer(RemoteContainer oldContainer, RemoteContainer newContainer)
          Replace a container by another container.
static void reset()
          Resets the global topology by re-resolving the different containers.
static void setTopology(Application application, Topology topology)
          Sets the topology for a given application.
 void setTrace(String application, String category, int level)
          Set a trace logging level
 void startSwingGUI(String application, String[] guiNames)
          Start some swing GUIs for an application.
 String toString()
          Get a textual representation of the topology.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

bootstrapFlag

public boolean bootstrapFlag

globalTopology

protected static Topology globalTopology
Store the gobal topology of the JAC distributed system.


containers

public List containers
Store the containers of the topology.


nameReps

public List nameReps
Store the remote references on the name repository for optimization matter.

Constructor Detail

Topology

public Topology()
This constructor builds a topology and set it to global if a global topology does not exist yet.

See Also:
get()

Topology

public Topology(String[] someNames)
Builds a topology with the given container identifiers. The identifier is protocol dependent.

This method transforms the names into remote containers references by calling resolve.

Parameters:
someNames - a set of container names
See Also:
RemoteContainer.resolve(String)

Topology

public Topology(RemoteContainer[] someContainers)
Builds a topology from a set of containers.

Parameters:
someContainers - the container of the new topology
See Also:
getContainers(), getContainer(int), getDistContainers()
Method Detail

getTopology

public static Topology getTopology(Application application)
Returns the topology defined for the given application.

Parameters:
application - the application
Returns:
the corresponding topology

setTopology

public static void setTopology(Application application,
                               Topology topology)
Sets the topology for a given application.

Parameters:
application - the application
topology - the corresponding topology

get

public static Topology get()
This method returns the gobal topology of the JAC distributed middleware.

This instance of topology is set in strong consistency so that all the container of the distributed name/aspect space are notified when a container is added or removed.

Returns:
the global topology

reset

public static void reset()
Resets the global topology by re-resolving the different containers.


getPartialTopology

public static Topology getPartialTopology(RE regexp)
This method returns a topology with all the containers that match the regular expression within the global topology of org.objectweb.jac.

Parameters:
regexp - a regular expression on the container names
Returns:
a partial topology
See Also:
getPartialTopology(String)

getFirstContainer

public RemoteContainer getFirstContainer(String sregexp)
This method returns the first container that matches the host expression.


getPartialTopology

public static Topology getPartialTopology(String regexp)
This method returns a topology with all the containers that match the regular expression within the global topology of org.objectweb.jac.

Parameters:
regexp - a regular expression (as a string) on the container names
Returns:
a partial topology

createNameReps

public void createNameReps()
Creates the remote references on the name repositories.

This method is used for optimization reasons. Indeed, it allows the topology to avoid the dynamic resolution of the containers when accessing them.

See Also:
getContainers(), getContainer(int), getDistContainers()

getContainers

public RemoteContainer[] getContainers()
Returns all the containers of the topology.

Returns:
an array of containers
See Also:
getContainer(int), getDistContainers()

getContainer

public RemoteContainer getContainer(int index)
Returns a given container.

Parameters:
index - a valid index
Returns:
the container that corresponds to the index
See Also:
getContainers(), getDistContainers()

getDistContainers

public RemoteContainer[] getDistContainers()
Returns the container of the topology minus the local one if any.

This method is typically used to deploy objects on a topology (when you do not want the object to be also depoyed on the local container).

Returns:
an array of containers
See Also:
RemoteContainer.isLocal(), getContainers(), getContainer(int)

containsLocal

public boolean containsLocal()
Tells if the current topology contains the local container.

Returns:
true if the local container is included in the topology

getReplicas

public Vector getReplicas(Wrappee localObject)
Gets a set of remote references on all the remote replicas of a local object for the current topology.

Parameters:
localObject - the local object of which the replicas are seeked
Returns:
the replicas references

exist

public boolean exist(String name)
Says if an object exist on one of the container of the topology (excluding the local one).

Parameters:
name - the name of the object to check
Returns:
true if the object has been found on one of the containers of the topology

getContainerIndex

public int getContainerIndex(RemoteContainer container)
Get the index of a container.

Parameters:
container - a container
Returns:
the index of the container, -1 if not part of this topology
See Also:
getContainer(int), getContainerIndex(String)

getContainerIndex

public int getContainerIndex(String name)
Get the index of a container from its name.

Parameters:
name - a container name
Returns:
the index of the container, -1 if not part of this topology
See Also:
getContainer(int), getContainerIndex(RemoteContainer), getContainerIndexes(RE), getContainerIndexes(String[])

getContainerIndexes

public int[] getContainerIndexes(RE regexp)
Get the indexes of some container regarding a regular expression on the name.

Parameters:
regexp - a regular expression
Returns:
a set of matching containers indexes
See Also:
getContainer(int), getContainerIndex(String), getContainerIndexes(String[])

getContainers

public RemoteContainer[] getContainers(RE regexp)
Get some containers regarding a regular expression on the name.

Parameters:
regexp - a regular expression
Returns:
a set of matching containers
See Also:
getContainer(int), getContainerIndex(String), getContainerIndexes(String[]), getContainerIndexes(RE)

getContainerIndexes

public int[] getContainerIndexes(String[] names)
Get the indexes of some container names.

Parameters:
names - an array containing the names
Returns:
the array of the corresponding indexes
See Also:
getContainer(int), getContainerIndex(RemoteContainer), getContainerIndexes(RE)

addContainer

public void addContainer(RemoteContainer container)
Add a container to the topology if not already present.

Parameters:
container - the container to add
See Also:
addContainers(RemoteContainer[])

addContainer

public void addContainer(String container)
Adds a container from its name.

Parameters:
container - the container name

addContainers

public void addContainers(RemoteContainer[] someContainers)
Add a set of containers to the topology.

Parameters:
someContainers - a set of containers to add
See Also:
addContainer(RemoteContainer)

removeContainer

public void removeContainer(RemoteContainer container)
Remove a container from the topology.

Parameters:
container - the container to be removed

isContainer

public boolean isContainer(RemoteContainer container)
Check if the current topology contains the given container.

Parameters:
container - the container to check
Returns:
true if the topology contains this container, false otherwise

replaceContainer

public void replaceContainer(int index,
                             RemoteContainer newContainer)
Replace a container at a given index.

Parameters:
index - the index where the container has to be substituted
newContainer - the container to set
See Also:
replaceContainer(RemoteContainer,RemoteContainer)

replaceContainer

public void replaceContainer(RemoteContainer oldContainer,
                             RemoteContainer newContainer)
Replace a container by another container.

Parameters:
oldContainer - the container to replace (must be in the topology)
newContainer - the replacing container
See Also:
replaceContainer(int,RemoteContainer)

getContainer

public RemoteContainer getContainer(String name)
Gets a container from its name.

Parameters:
name - the name to seek
Returns:
the container, null if not found in the topology

countContainers

public int countContainers()
Returns the number of containers in this topology.

Returns:
the containers count

fireTopologyChangeEvent

protected void fireTopologyChangeEvent()
Notifies everybody that the topology changed.


dump

public void dump()
Dump the containers of the topology.


launchGUI

public void launchGUI(String programName)
Launches the administration GUI on the local container.


launchGUI

public void launchGUI()
Start the admin GUI


startSwingGUI

public void startSwingGUI(String application,
                          String[] guiNames)
Start some swing GUIs for an application.

Parameters:
application - the name of the application for which to start the GUIs
guiNames - the names of the GUI windows to start

reloadAspect

public void reloadAspect(String applicationName,
                         String aspectName)
Reload the configuration of an aspect


setTrace

public void setTrace(String application,
                     String category,
                     int level)
Set a trace logging level

See Also:
Log.trace(String,int,String)

toString

public String toString()
Get a textual representation of the topology.

Overrides:
toString in class Object
Returns:
a string describing the topology

Contact JAC development team:
Renaud Pawlak
Lionel Seinturier
Laurent Martelli