Class JSpaceContainerImpl

java.lang.Object
com.j_spaces.core.JSpaceContainerImpl
All Implemented Interfaces:
IJSpaceContainerAdmin, IJSpaceContainer, Remote

public class JSpaceContainerImpl extends Object implements IJSpaceContainer, IJSpaceContainerAdmin
A J-Space Server is a physical process (JVM) that has a J-Space Container instance. A J-Space container manages the life cycle of J-Space instances. Life cycle operations include creation, destruction and even moving a J-Space from one container to another. The J-Space container is a remote object that implements the IJSpaceContainer interface. A J-Space instance is an instance of SpaceInternal, which implements the remote interface ISpaceInternal. Each J-Space in a container has a unique name. This name can be used after creation to receive a reference to the specific J-Space. The container is also responsible for registering its J-Spaces in the lookup services in the environment and maintaining the leases it receives. It is listening to new lookup services entering the environment and makes sure its J-Spaces are registered to these lookup managers too. The container keeps a map between spaces names and spaces attributes. All of the container information is kept in a persistent storage, which is an XML file, under the [J-Spaces-Home]/config directory. The name of the container is determined by a property in the JSpaces.properties file. The default is the name of the machine J-Spaces is installed on. Using shutdown function container terminate LookupManager and close space connection versus Storage adapters. A J-Space container may be launched as a Unicast remote object or as an Activatable remote object.
Version:
1.0
Author:
Igor Goldenberg
  • Field Details

  • Constructor Details

  • Method Details

    • getContainerEntry

      public JSpaceContainerImpl.ContainerEntry getContainerEntry()
    • getStartTime

      public long getStartTime()
    • initSecurity

      public static void initSecurity()
    • getRuntimeConfigReport

      public String getRuntimeConfigReport()
      Description copied from interface: IJSpaceContainerAdmin
      Returns runtime configuration report: dump of the overall system configurations (spaces, container, cluster), system env, sys properties.
      Specified by:
      getRuntimeConfigReport in interface IJSpaceContainerAdmin
      Returns:
      runtime configuration report
    • getContainerProxy

      public IJSpaceContainer getContainerProxy()
    • unregister

      protected void unregister()
      Release any remote objects associated with this IJSpaceContainer.
    • createSpace

      public IJSpace createSpace(String spaceName, JSpaceAttributes spaceAttr) throws CreateException, RemoteException
      Creates JSpace with unique space-name in this container and write the created space to appropriate Storage Adapter. If space already exists in this container CreateException will be throws. The created space will be registered with all discovered Lookup Services in the network. Created space will added to XML file.
      Parameters:
      spaceName - Space name for creating.
      spaceAttr - If spaceAttr.isPrivate == true this space will not register with LookupService and Rmi registry.
      Returns:
      IJSpace Return collocated space if spaceAttr.isPrivate == true. If spaceAttr == null or spaceAttr.isPrivate == false return standard proxy.
      Throws:
      CreateException - If this spaceName already exists in JSpaceContainer, during creating space in Storage Adapter or if spaceName has same name as container Name.
      RemoteException - Rmi remote exception.
    • destroySpace

      public void destroySpace(String spaceName) throws DestroyedFailedException, RemoteException
      Destroying certain space in JSpace container and close connection with Storage Adapters(if opened). This destroyed space will be unregistered with all Lookup Services on which was registered. Destroyed space will removed from XML file.
      Parameters:
      spaceName - JSpace name.
      Throws:
      DestroyedFailedException - During destroying JSpace in JSpace container.
      RemoteException - Rmi remote exception.
    • getSpaceNames

      public String[] getSpaceNames() throws RemoteException
      Returns array of all JSpace names that exists in this JSpace container.
      Specified by:
      getSpaceNames in interface IJSpaceContainer
      Returns:
      String[] All JSpace names that exists in this JSpace container.
      Throws:
      RemoteException - Rmi remote exception.
    • getName

      public String getName()
      Returns name of container.
      Specified by:
      getName in interface IJSpaceContainer
      Specified by:
      getName in interface IJSpaceContainerAdmin
      Returns:
      the name of this container.
    • getSpace

      public IJSpace getSpace(String spaceName) throws NoSuchNameException
      Description copied from interface: IJSpaceContainer
      Returns a proxy of the specified space.
      Specified by:
      getSpace in interface IJSpaceContainer
      Parameters:
      spaceName - the name of the space.
      Returns:
      IJSpace space proxy.
      Throws:
      NoSuchNameException - if the specified space does not exist in this container.
    • getClusteredSpace

      public IJSpace getClusteredSpace(String spaceName) throws NoSuchNameException
      Description copied from interface: IJSpaceContainer
      Returns a clustered proxy of the specified space.
      Specified by:
      getClusteredSpace in interface IJSpaceContainer
      Parameters:
      spaceName - the name of the space.
      Returns:
      IJSpace clustered space proxy.
      Throws:
      NoSuchNameException - if the specified space does not exist in this container.
    • getURL

      public SpaceURL getURL() throws RemoteException
      Returns the SpaceURL object which initialized that specific container instance.
      Note that the SpaceURL object contains importent information on the space and container configuration/setup such as the space url used, the space/container/cluster schema used and other attributes. The IJSpace keeps also its reference of the SpaceURL which loanched the space.
      Specified by:
      getURL in interface IJSpaceContainer
      Returns:
      SpaceURL Returns the SpaceURL object which initialized that specific space instance.
      Throws:
      RemoteException
      See Also:
    • ping

      public void ping()
      Description copied from interface: IJSpaceContainer
      Checks whether the container is alive and accessible.
      
       IJSpaceContainer aContainer = (IJSpaceContainer)SpaceFinder.find("jini://lookup-host/container-name");
       try{
          aContainer.ping();
          System.out.println("Container alive");
       }
       catch (java.rmi.RemoteException re) {
          System.out.println("Container unreachable");
       }
       
      Specified by:
      ping in interface IJSpaceContainer
    • getSpaceAdmin

      public IRemoteJSpaceAdmin getSpaceAdmin(String spaceName) throws NoSuchNameException
      Throws:
      NoSuchNameException
    • shutdown

      public void shutdown() throws RemoteException
      Description copied from interface: IJSpaceContainer
      Shuts down this container. This also involves unregistering all registered spaces from Lookup services and closing connections to storage adapters.
      Specified by:
      shutdown in interface IJSpaceContainer
      Throws:
      RemoteException - if a communication error occurs
    • shutdownInternal

      public void shutdownInternal()
    • getContainerStatus

      public int getContainerStatus()
    • updateContainerXMLTree

      public void updateContainerXMLTree(String spaceName, JSpaceAttributes spaceAttr)
      Building XML space tree inside [container-name].xml file.
      Parameters:
      spaceName - JSpace name.
      spaceAttr - JSpace attributes.
    • getConfig

      public ContainerConfig getConfig() throws RemoteException
      Description copied from interface: IJSpaceContainerAdmin
      Get container configuration.
      Specified by:
      getConfig in interface IJSpaceContainerAdmin
      Returns:
      ContainerConfig The container config structure.
      Throws:
      RemoteException - Failed to retrieve container configuration.
    • setConfig

      public void setConfig(ContainerConfig config) throws RemoteException
      Description copied from interface: IJSpaceContainerAdmin
      Set new container configuration.
      Specified by:
      setConfig in interface IJSpaceContainerAdmin
      Parameters:
      config - The container config structure.
      Throws:
      RemoteException - Failed to set new container configuration.
    • getSchemaName

      public String getSchemaName()
      Returns:
      The requested schema name, to be used as the space/container configuration template.
    • getEmbeddedTransactionManager

      public TransactionManager getEmbeddedTransactionManager()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object