Pegasus Enhancement Proposal (PEP)

PEP#: 363

PEP Type: Functional

Title: Latest ICU Version Support for Open Pegasus

Status:  draft 

 Version History:

Version Date Author Change Description
0.1 11 Aug 2011
Ajay.N.Rao
Initial Submission
0.2 10 Nov 2011
Ajay.N.Rao
 Updated with the draft implementation details for the Latest ICU Support.




 


Abstract: Add Support of Latest ICU Version for Open Pegasus.


Definition of the Problem

The Pegasus Currently uses 3.2 version of the ICU. According to the newer versions of the ICU Old Style of the data packing is deprecated.This PEP tries to address the following problems:
- Pegasus Code does not support New Style of data packing used in the later versions above 3.6.
- ICU Currently uses the resource bundle approach which is not very efficient.
- Resource bundle approach uses config properties , Environment variables and User Defined paths (PEG_MSG_HOME, messageDir etc...)to locate ICU Bundles. This causes  several issues w.r.t Installation and Configuration of the pegasus with ICU.

Proposed Solution

This PEP proposes following line items to solve these problems:
- Pegasus Code should support New Style of data packing as well as the old one(provide back ward compatibility).
- Making Use of the Shared library model of data packaging in order to remove the  issues with respect to Environment and configuration.
- Provide CMPI Interface support for the Messageloader to remove compatibility concerns for Shared Library model.

Support for all ICU Versions:

The ICU uses icu-config command to get the version details as follows:
icu-config --version

This Command gives the information about the version number in the format X.Y.Z . where X is the major version number Y is minor version number.
eg:
ICUVERSION:=$(shell icu-config --version)
ICUVERSION:=$(subst ., $(ICUVERSION))
ICUVERSIONMAJOR:=$(word 1,$(ICUVERSION))
ICUVERSIONMINOR:=$(word 2,$(ICUVERSION))

Using this information the Pegasus environment obtains the version number of ICU and provides the latest ICU Support for the version >=3.6 and backward compatibility for the versions <3.6.Pegasus will package data with the shared library model for ICU versions higher than 3.6. For the ICU Version below the 3.6 the older resource bundle approach for data packing will be used.


Variable ICUSHAREDOBJVERSIONSUPPORT is set to true if the version of the ICU is greater than or equal to the 3.6.Pegasus uses the variable set by this command to bifurcate the flow for the Latest ICU and the old ICU with the package options.A new environment variable PEGASUS_ICUSHAREDOBJ_SUPPORT is introduced to user to set the bundling approach to shared object or resource bundle model.if variable is set to true then shared object model is used, else the resource bundle approach is used.Shared object support is rightly validated against the old ICU versions as only resource bundle approach is supported by them.

eg:

#if PEGASUS_ICUSHAREDOBJ_SUPPORT == true

....
icu data handled by Shared Object Approach

....
#else
....
icu data handled by Resource Bundle Approach
....
#endif


ifneq ($(ICUSHAREDOBJVERSIONSUPPORT),true)

     ifeq ($(PEGASUS_SHAREDOBJ_SUPPORT),true)
        $(error PEGASUS_SHAREDOBJ_SUPPORT ($(PEGASUS_SHAREDOBJ_SUPPORT)) \   
              is not valid for ICU versions less than 3.6)
    endif
endif

Support for Resource Bundle Model with the Latest ICU:

The genrb command which is used to compile the resource text file into a bundle has deprecated use of the option -p.This option specified the package name of the resource bundle output file. Hence the resource txt files are built without this option producing the resource bundle file of the specific locale.

eg:
$(MSG_DIR)/%.res: %.txt $(ERROR)
    $(MKDIRHIER) $(MSG_DIR)
    $(MSG_COMPILE) -d $(MSG_DIR) $(MSG_FLAGS) $*.txt
    @ $(ECHO)

Since in the newer versions of ICU the resource bundle has to be of the format <locale>.res the target directory of the resource bundle is modified to separate for each module in a hierarchical format.
eg:

The default target directory for the module pegasus/pegasusCLI is $(PEGASUS_HOME)/msg/pegasus/pegasusCLI_en.res
This would be changed to   $(PEGASUS_HOME)/msg/pegasus/pegasusCLI/en.res

The complete msg_src_path is used for the message bundle target directory hierarchy.

Resource Management :
The directory from which the resource bundle files have to be loaded can be set from the u_setDataDirectory(char *path) API which accepts the path of the resource bundle directory. The resource bundle files can be found in these directory and opened by ures_open API . This function returns U_ZERO_ERROR status on success, U_USING_FALLBACK_WARNING or U_USING_DEFAULT_WARNING status when a more general resource bundle is returned if no exact match is found.

UResourceBundle* ures_open(const char* package, const char* locale, UErrorCode* status)

ures_openDirect API also used to open message but will fail if the exact match of the locale is not returned.

UResourceBundle* ures_openDirect(const char* package, const char* locale, UErrorCode* status)
  

Shared Library Model:

The Pegasus install scripts have to be modified to compile the ICU data into Shared Libraries. The Pkgdata tool is used to achieve the same. The LD_LIBRARY_PATH would be updated with the path related information of the Pegasus library path to which resource data shared libraries are built.

eg:

$(ICU_INSTALL)/bin/pkgdata -r $(ICUVERSIONMAJOR)$(ICUVERSIONMINOR) -d $(LIB_DIR) -s $(MSG_DIR) --name        $(MSG_PACKAGE) --libname \
    $(MSG_PACKAGE)Msg --mode dll $(MSG_DIR)/list.txt
    $(RM) $(LIB_DIR)/$(MSG_PACKAGE).dat $(LIB_DIR)/$(MSG_PACKAGE)_dat.o \
    $(LIB_DIR)/$(MSG_PACKAGE)_dll.lst $(LIB_DIR)/$(MSG_PACKAGE)_dll.mak

The library generated by the pkgdata tool is then loaded to the memory by using the Dynamic Library interface, which provides the handle of the package data in the library.This is used to load the resource data of the given package which is achieved in pegasus by using ICU API udata_setAppData. udata_setAppData function loads the resource data specific to the package passed as argument.
void udata_setAppData (const char *packageName, const void *data, UErrorCode *err);

The required package specific data is opened by using ures_open API.


CMPI Compatibility:

The CMPI Interface accepts the message source path as argument for loading the messages, which is not used by shared object model to extract the ICU Message,but it instead uses the package Id. Pegasus internal implementation of CMPI obtains the package id from the message source path which comes in as an argument in CMPI Interface. The Message Source path consists of the path or relative path of the resource file with the package id, the packageid is parsed from it removing the string after the last path delimiter.

Update to BuildAndReleaseOptions.html

PEGASUS_ICUSHAREDOBJ_SUPPORT

Description: Builds the Pegasus with the Shared Object support for the ICU data for the Pegasus messages. If this option is set, the value can be one of the either true or false.
Default Value: Not set
Recommended Value (Development Build): Not set
Recommended Value (Release Build): Not set
Required: No
Considerations: This Build options has no effect without the PEGASUS_HAS_ICU option enabled. If this option is set true then the Pegasus Messages are bundled as shared objects else if set to false it is bundled as Resource Bundles.

Rationale


Schedule

Available with 2.12.0 OpenPegasus.

Discussion




Copyright IBM, 2011

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Template last modified: February 17th 2009 by Martin Kirk
Template version: 1.15