Difference between revisions of "Contexts"

From GCube System
Jump to: navigation, search
(Configuration Management)
(Configuration Management)
Line 78: Line 78:
 
* configuration related to the implementations of core gCF interfaces, e.g. discovery, publishing, and remote notification [[Client_Libraries|interfaces]] (<code>getImplementation()</code>).
 
* configuration related to the implementations of core gCF interfaces, e.g. discovery, publishing, and remote notification [[Client_Libraries|interfaces]] (<code>getImplementation()</code>).
  
The <code>GHNContext</code> is capable of exposing the configuration of the gHN even if the gHN is not running in the client process (or at all).
+
The <code>GHNContext</code> is capable of exposing the configuration of the gHN even if the gHN is not running in the client process or not running at all (i.e. when its status is <code>DOWN</code>, as discussed below).
  
 
===Lifetime Management===
 
===Lifetime Management===

Revision as of 18:23, 23 January 2009

Within the implementation of gCube services, some functionality needs to be accessed by different components and for different purposes.

The most obvious case is functionality that exposes the configuration of the service, its RI, or the gHN on which the RI is deployed; as shown later in the Guide, there is also dynamically acquired information related to scope and security that may need to be shared within service implementations. And beyond information access, there are general-purpose or service-specific utilities and behaviours that may be called upon from multiple and functionally unrelated components.

In gCF, the approach to shared functionality is to centralise it in distinguished components, called contexts, which are easily accessible from any other implementation component. gCF contexts are singleton classes, in that they are designed to be instantiated only once and to expose the single instance to all their clients.

There are different type of contexts in gCF, each of which centralises functionality that is conceptually associated with the service and its RI, the gHN on which the RI is deployed, the port-types of the service, and even the port-types of remote target services. Some of these contexts are fully defined within gCF (e.g. the context of the gHN). Others are only partially implemented and need to be specialised within individual service implementations. Collectively, the context form a inheritance hierarchy contained in the contexts package:

Contexts.jpg

As indicated in the diagram, the entire framework has dependencies on the contexts packages, in line with the definition of contexts as repositories of shared functionality. The high-level roles of the components in the package is summarised below:

  • GCUBEContext: the base implementation for all contexts in gCF.
  • GCUBEGHNContext: a concrete specialisation of GCUBEContext for a gCube Hosting Node.
  • GCUBEServiceContext: a concrete specialisation of GCUBEContext for a gCube Service and its RIs.
  • GCUBEPortTypeContext: a concrete specialisation of GCUBEContext for a port-type of gCube Service.
  • GCUBEStatefulPortTypeContext: a concrete specialisation of GCUBEPortTypeContext for a stateful port-type of a gCube Service.
  • GCUBERemotePortTypeContext: a concrete specialisation of GCUBEContext for a port-type of a target gCube Service.

Before discussing each context class in detail, we refine our the service model to reflect those that are central to the perspective of the service developer:

Model&contexts.jpg

The figures shows that the GHNContext and GCUBERemotePortTypeContext are fully implemented by gCF and live outside the boundary of service implementations. In contrast, service and the port-type contexts fall in the scope of service implementations as specialisations of gCF context classes.

Common Facilities

All gCF contexts offer basic facilities for configuration and local file management.

The primary form of configuration supported by gC contexts is based on named access to arbitrary objects. The underlying configuration mechanism is based on a dedicated implementation of the JNDI interface; in particular, gCF contexts act as a wrappers of standard JNDI contexts and offer a much simplified interface to named access.

The underlying JNDI implementation remains opaque to both clients and implementers of context classes. Developers are only exposed to the configuration files that are then used to populate the JNDI implementation wrapped by the contexts. As we discuss below, the direct subclasses of GCUBEContext are responsible for establishing conventions on the naming and location of such files, for the definition and documentation of pre-defined configuration properties, and for loading all the configuration properties from the files. As most service developers specialise these subclasses, they need only to author the configuration files. The syntax for authoring JNDI configuration is based on XML, and its definition is lifted from technologies that underlies gCF. Conventions on context-specific configuration authoring are discussed below in relation to each type of context.

As to file management, gCF contexts offers facilities to access:

  • files stored in the local file system for reading or writing purposes. Here the main goal is to abstract over the location in which the files are stored and thus to avoid gHN-specific dependencies. While actual location in which files are stored is specific to the type of context, as we discuss below, all contexts offer basic backup facilities: transparently to their clients, they create copies of files that are about to be modified and used backups whenever the original files are corrupted. In the second case, access is read-only
  • files packaged along with the context, or more generally on the classpath, for read-only purposes.

In both cases, the gCF contexts are agnostic to the content of the files. This may be service-specific configuration that lives outside the standard JNDI framework, or any form of state that is deemed suitable for file storage.

The basic operations for configuration and file management are following (see the code documentation for signature details):

  • getProperty(name,mandatory?): resolves a configuration property from its name. An optional flag indicates whether the presence property is deemed mandatory or else is optional (default). The flag is used for error and log management purposes.
  • getResource(path): returns a classpath file resource given its path. A relative path is resolved with respect to the context implementation, while an absolute path is resolved directly against the classpath.
  • getFile(path,mode): returns a java.io.File for read or write access. A write access mode induces backups and a read access (default) relies on backups to recover from failures. In write mode, directories that are specified in the path but do not exist are automatically created, while paths that identify directories are disallowed.

The following refinement of the service model emphasises the configuration and file management role of contexts:

Model&contexts2.jpg

The gHN Context

GHNContext specialises GCUBEContext for gCube Hosting Nodes. This is a concrete component and requires no further specialisation from gCF developers.

Configuration Management

The GHNContext consumes and exposes all the configuration that relates to gHNs, including:

  • configuration related to the infrastructure in which the gHN operates. Described in detail in the Administrator's Guide, this is the primary form of configuration of the gHN. The GHNContext some configuration properties directly (cf. getInfrastructure(), getStartScopes(), getMode(), getType()), particularly those that benefit from some form of post-processing. Other properties can be accessed with the generic facilities inherited from GCUBEContext (cf. getProperty()).
  • configuration and statistics related to the physical property of the gHN inherited from the underlying hardware (cf. getFreeSpace), getUptime(), getMemoryUsage(), getCPUInfo(), getLoadStatistics(), etc.).
  • configuration related to the implementations of core gCF interfaces, e.g. discovery, publishing, and remote notification interfaces (getImplementation()).

The GHNContext is capable of exposing the configuration of the gHN even if the gHN is not running in the client process or not running at all (i.e. when its status is DOWN, as discussed below).

Lifetime Management

Service Contexts

[coming soon]

PortType Contexts

[coming soon]