Changes between Initial Version and Version 1 of Obsolete/Development/Code/PerlNamespaces


Ignore:
Timestamp:
Mar 20, 2010, 10:28:53 PM (16 years ago)
Author:
loomis
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Obsolete/Development/Code/PerlNamespaces

    v1 v1  
     1[[TracNav]]
     2
     3== Current State ==
     4
     5As of early 2009, the various Quattor tools use the following PERL namespaces for modules:
     6
     7''EDG::WP4::CCM::'' The namespace used for accessing the locally installed configuration profile (whether it's for the local node, or downloaded in order to discover configuration of a foreign node).
     8
     9''NCM::'' Utility libraries used by dispatcher components, and by the dispatcher itself. Under this namespace is a subnamespace "Components" - all quattor ncm components are accessed via this namespace. For example, NCM::Component::filecopy is the namespace used by the "filecopy" component.
     10
     11''NCD::'' For the Node Configuration Dispatcher. Only used by the dispatcher itself.
     12
     13''SPM::'' For SPMA. Note that the perl namespace is only "SPM" and not "SPMA".
     14
     15''CAF::'' The Common Application Framework
     16
     17''LC::'' Lionel Cons' utilities for interacting with the system with extra caution. Used/wrapped extensively by the CAF toolset.
     18
     19== Proposal ==
     20
     21# All quattor specific modules should move to a new Quattor:: namespace.
     22# The "CCM" acronym can be renamed as "Profile".
     23# The NCM and NCD namespaces could be merged.
     24# The CAF namespace should be merged into the Quattor toplevel namespace. In other words, "perl-CAF" package should become "perl-Quattor", since it provides the base libraries for driving Quattor.
     25# The LC package should be included within CAF/perl-Quattor. An explicit fork of the LC codebase.
     26
     27This would give the following mapping:
     28
     29{|
     30!From
     31!To
     32!Examples
     33|-
     34|EDG::WP4::CCM::
     35|Quattor::Profile::
     36|Quattor::Profile::Element, Quattor::Profile::CacheManager
     37|-
     38|NCM::
     39|Quattor::Config::
     40|Quattor::Config::Component::filecopy, Quattor::Config::Check::File
     41|-
     42|NCD::
     43|Quattor::Config::
     44|Quattor::Config::ComponentProxy
     45|-
     46|SPM::
     47|Quattor::SPMA::
     48|Quattor::SPMA::Package
     49|-
     50|CAF::
     51|Quattor::
     52|Quattor::Lock, Quattor::Log, Quattor::Process, Quattor::Reporter, etc.
     53|-
     54|LC::
     55|Quattor::
     56|Quattor::Check, Quattor::File, Quattor::Stat
     57|}
     58
     59== Implementation Plan ==
     60
     61This involves changing almost every bit of perl there is.
     62
     63=== SPMA ===
     64
     65This can be changed at any time. The library is purely used by the "spma" tool itself.
     66
     67=== EDG::WP4::CCM, a.k.a. the 'ccm' tools ===
     68
     69The EDG::WP4::CCM:: namespace is defined by the "ccm" package and consumed by "ncm-query", "ncm-ncd", "aii" and some of the components, therefore care must be taken in changing this namespace. Possibly the trampoline mechanism described below could be used.
     70
     71=== Components ===
     72
     73Significantly, every component places itself into the namespace with a header that says something along the lines of "package NCM::Component::@COMP@". Therefore, the dispatcher (ncm-ncd) needs to support *both* namespaces (with a priority ordering biased towards the new name). Since the namespace is only used within ncm-ncd, this means that ncm-ncd has to be changed first before any components. From that point on, components can change at whatever pace they want.
     74
     75== Namespace Compatibility Mechanism ==
     76
     77You can make a compatability later by playing tricks like the following:
     78
     79 package EDG::WP4::CCM::Element;
     80 use base 'Quattor::Legacy::Factory';
     81
     82Where the legacy factory looks like:
     83 package Quattor::Legacy::Factory;
     84 use Carp;
     85 our $mapping = {
     86     "EDG::WP4::CCM" => "Quattor::Profile",
     87 };
     88 sub new {
     89     my ($class) = shift;
     90     if (ref $class) {
     91         return $class->SUPER::new(@_);
     92     }
     93     # find the best match in the mapping
     94     my $best  = ""
     95     foreach my $maybe (%$mapping) {
     96         if ($class =~ /^$maybe/ && length($class) > $best) {
     97             $best = $maybe;
     98         }
     99     }
     100     if (!$best) {
     101         Carp::confess("legacy support requested for $class, which is unsupported");
     102     }
     103     my $final = $mapping->{$best};
     104     if ($class =~ /${best}::(.*)/)) {
     105         $final .= "::$1";
     106     }
     107     print STDERR "WARNING: Quattor legacy code causing conversion of $class to $final\n";
     108     eval "require $final";
     109     if ($@) {
     110         Carp::confess("legacy support of $class failed: $@");
     111     }
     112     $final->new(@_);
     113 }
     114
     115
     116=== Concerns ===
     117
     118Any code that uses the "isa()" method will need to be modified. The exception handling code within ncm-ncd might also need to change.
     119