Chapter 2. Usage and Management

Table of Contents

2.1. Directory Configuration
2.2. Configuration
2.2.1. TDL Configuration
2.2.2. Tmax Configuration
2.3. System Management Tools
2.3.1. tdlinit
2.3.2. tdlclean
2.3.3. tdlnm
2.3.4. tdlrm
2.3.5. tdlshm
2.3.6. tdlsync
2.3.7. tdlupdate

To use TDL, the TDL environment must be set. To use the implicit version protection function, the TMAX environment must be set. This chapter describes how to set each environment and use its tools.

2.1. Directory Configuration

The TDL directory consists of the config directory for environment files, the mod directory for soon-to-be-updated libraries, and the run directory for updated libraries.

DirectoryDescription
configDirectory for TDL environment files (tdl.cfg). For the basic location of RACFILE parameter, the config directory is also used.
modDirectory for soon-to-be-updated libraries. After copying shared libraries(*.so or *.sl) into the mod directory, execute tdlupdate.
runDirectory for updated libraries after executing tdlupdate. A user must not remove any file arbitrarily since files that are used internally by the system also exist.

Note

If the $TDLDIR is not specified as the TDL root path, the path configured in the $TMAXDIR environment variable must be used. If a user wants to specify a different path, the $TDLDIR environment variable must be configured. Also, TDL needs to be used in the local client, $TDLDIR must be configured.

The TDL 2.x version does not have config but tdl.cfg in the $TDLDIR.

2.2. Configuration

To use TDL, the TDL configuration file and the environment related to TDL must be set at Tmax.

The basic grammar of configuration is "parameter = value" and spaces are not allowed within the line. If the first character of the line is '#', the line will be annotated.

2.2.1. TDL Configuration

The TDL configuration file is $TMAXDIR/config/tdl.cfg and the following describes examples and items of the TDL environment file.

# shared memory version (1|2|3|4)
VERSION=2
# shared memory key
SHMKEY=0x90000
# shared memory and file creation permission
IPCPERM=0750
# number of dynamic loadable modules, rouded up to powers of 2
MAXMODULES=256
# shared memory backup
BACKUP=log/dlog/tdl.bak
# path of a command file for searching export functions
#COMMAND=tdlcmd
# path of a log directory
LOGDIR=log/dlog
# running mode (single|master|slave)
MODE=single
# mornitoring statistics
MONITOR=Y
# language of tdl application [C | COBOL | IBMCOBOL | PL1 | MIXED]
LANG=C
# path of a file including addresses for accessing remote tdl nodes 
#RACFILE=tdl.rac
# tdl domain ID
DOMAINID=1
# multiple run, mod dir
DIRMAPPINGLIST=(mod:run),(mod2:run2),(mod2:run2)
# HASHFUNC=[ LOOKUP2 | LOOKUP3 | SUPERFASTHASH | TDLHASH | MURMURHASH ]
# HASHFUNC=MURMURHASH

ItemDescription
VERSION

Configures a version to run TDL. Select one among 1, 2, 3, and 4. (The default: 1)

For more information, refer to "VERSION Item".

SHMKEYConfigures a shared memory key value used for running TDL.
IPCPERMConfigures the permission of the dynamic module and shared memory of the run directory.
MAXMODULESThe maximum number of dynamic modules. Used by being rounded off to 2^n. Can change without relocation of the modules. For more information, refer to "Chapter 4. Example".
BACKUPSpecifies the shared memory backup file. During tdlinit and tdlupdate, the shared memory is automatically backed up to the specified file. If a relative path, the path begins at $TDLDIR or $TMAXDIR. $TDLDIR of the path information takes precedence.
COMMANDSpecifies the location of the script file to automatically extract a function to export from the library. If a relative path, the path begins at $TDLDIR/config or $TMAXDIR/config. $TDLDIR of the path information takes precedence.
LOGDIRSpecifies the error and information message logging directory. The log file name is "tdllog.mmddyyyy" format. If a relative path, the path begins at $TDLDIR or $TMAXDIR. $TDLDIR of the path information takes precedence.
MODE

Configures one of a master, slave, and single in the multi nodes or domains.

(The default: single)

MONITOR

Option to collect TDL statistics information(Y|N). (The default: N)

If set to 'Y', AVG/MIN/MAX and CPU AVG/MIN/MAX, performing time by module are collected. Can be queried through the 'tdlshm –S' option.

LANG

Selects one from C, COBOL, IBMCOBOL, PL1, and MIXED for TDL applications using a language.

If not selected, it is set to C. The extension of the module is determined by the OS.

RACFILE

Specifies a file with the racd address of all the nodes in the multi nodes or domains. If a relative path, the path begins at $TDLDIR/config or $TMAXDIR/config. $TDLDIR of the path information takes precedence.

For an example of RACFILE, refer to "RACFILE Example".

DOMAINIDID for a TDL domain and must be configured differently per domain. (The default: 0)
DIRMAPPINGLIST

Configures if two run directories or more are used.

Pairs of the mod directories and run directories are separated by parenthesis and a colon(:) and can be set up to 10 pairs. Applied from Tmax v5.0 sp1 fix#2.

HASHFUNCConfigures by selecting a type of HASH internally used in TDL(Index configuration for each module). Applied from Tmax v5.0 sp2.

VERSION Item

TDL can operate the system in the form of four VERSIONs. VERSION values can be configured through VERSION parameters of the TDL environment file(tdl.cfg).

  • VERSION 1

    The VERSION is set to 1 and has only one function per library. The function name must match the library name. (The function name must be unique as a whole.)

  • VERSION 2

    The VERSION is set to 2 and the library can have multiple functions. But functions to be exported are supported by the following. (The function name must be unique as a whole.)

    • Specification of Export Files

      A user specifies a function to export from the library by including an export file ("library name.exp") in the mod directory. This method is recommended as the automatic extraction may export functions that are not supposed to be exported.

      A export file specifies one function per line. If the first character of the line is '#', the line will be annotated.

      The following is an example.

      # mylibrary
      myfunction1
      myfunction2
      myfunction3
    • Automatic Extraction of Export Function

      Automatically extracts functions to be exported. If the export file is not specified, the function is automatically extracted. Internally, nm is used and a user can redefine the nm script. The script must be written in one line. If the first character of the line is '#', the line will be annotated. If the last character of the line is '\', the line will lead up to the following line. "$(LIB)" is a macro variable that indicates the library name.

      The following is an example.

      # for HP32
      nm $(LIB) | awk -F"|" '{if ($3 == "extern" && $4 == "code   ")
       {print $1}}' | grep -ve "^_"
      
      # for HP64
      nm $(LIB) | awk -F"|" '{if ($4 == "FUNC " && $7 == "   .text") 
      {print $8}}' | grep -ve "^_"
      
      # for IBM32
      nm $(LIB) | awk '{if ($2 == "D") {print $1}}'
      
      # for IBM64
      nm -X64 $(LIB) | awk '{if ($2 == "D") {print $1}}'
      
      # for SUN
      nm $(LIB) | awk -F"|" '{if ($4 == "FUNC ") {print $8}}' | grep -v "^_"
      
      # for linux
      nm $(LIB) | awk '{if ($2 == "T") {print $3}}' | grep -v "^_"
      
      (*But, the above script is noly an example and the modification is needed depending on the actual platform.)

      The above script can be used by using the COMMAND parameter of the TDL environment file(tdl.cfg) or the –x option from the management tool. Also, functions that are automatically extracted from the system can be identified in advance through tdlnm.

  • VERSION 3

    The VERSION is set to 3. The library name and function name are used for a key. Therefore, unlike VERSION 1 and 2, it is acceptable for the function name to be unique only within the library. But the VERSION 3 requires tdlcall2(), tdlcall2v(), and tdlcall2s() to be used.

  • VERSION 4

    The VERSION is set to 4. The library name, class name, and name space are used. This is used in C++ and does not use tdlcall but a separate interface. For more information, refer to "Chapter 4. Example".

RACFILE Example

Save the configured file with ".rac" extension as follows. Configure the file name for the RACFILE item.

hostname1 192.168.1.1 3333
hostname2 192.168.1.2 3333
hostname3 192.168.1.3 3333

2.2.2. Tmax Configuration

To use the implicit version protection, TDL must be configured at DOMAIN or NODE clause.

*DOMAIN
tmax ...,
         TDL = Y

*NODE
tmax1 ...,
         TDL = Y
  • DOMAIN Clause

    ItemDescription
    TDLOption to use the TDL implicit version protection(Y|N). (The default: N)
  • NODE Clause

    itemDescription
    TDLOption to use the TDL implicit version protection(Y|N). If not configured, the TDL value of the DOMAIN clause will be used.

2.3. System Management Tools

The following are the management tools that TDL provides. They are located in the following path.

$TMAXDIR/bin

CommandDescription
tdlinitPerforms initialization of TDL shared memories and dynamic modules.
tdlcleanCleans up the run directory's older version of the library files or unnecessary files.
tdlnmQueries the list of functions to be automatically exported for the specified library.
tdlrmManagement tool to completely remove shared memories when TDL is no longer used.
tdlshmQueries information about TDL shared memories or configures whether to activate statistics monitoring and modules.
tdlsyncPerforms synchronization of TDL shared memories and backup files.
tdlupdateUpdates the specified dynamic module.

2.3.1. tdlinit

The tdlinit command initializes a TDL shared memory and dynamic modules. This command is executed only once when Tmax is installed and before Tmax starts. This command can be executed only in a master node in a multi-node environment.

  • Usage

    $ tdlinit [-p TDL root directory path] [-x export function extraction script file path] 
              [-f] [-b] [-B backup file path] [-i] [-v | -V] [-h]
    OptionDescription
    [ -p TDL root directory path ]A TDL root directory. Default value: $TDLDIR or $TMAXDIR.
    [ -x export function extraction script file path ]The path of a script file that extracts an export function.
    [ -f ]Initializes already existing shared memory by force.
    [ -b ]Restores shared memory from a backup file.
    [ -B backup file path ]Restores shared memory from a specified backup file.
    [ -i ]Checks a run directory after a backup. Used with [-b] or [-B] options.
    [ -v | -V ]Shows version information.
    [ -h ]Shows command Help.
  • Examples

    • The following initializes shared memory and modules using a TDL configuration file <tdl.cfg>:

      $ tdlinit
    • The following backs up shared memory from a backup file in the event of a system failure or restart:

      $ tdlinit -b

  • Note

    A script file that extracts an export function is required when a VERSION is set to 4.

    /* Example of exp file */
    /* dlib.exp */
    
    #! dlib.so
    TmaxSoft::Airplain
    Car

2.3.2. tdlclean

The tdlclean command removes outdated library files and unnecessary files in a run directory. To remove a dynamic module from shared memory, use [-m] or [-M] options.

  • Usage

    $ tdlclean [-p TDL root directory path] [-m library name] [-M function name] [-b] 
               [-d yyyymmddhhmi] [-D "n hour|day"] [-N number] [-v | -V] [-h]
    OptionDescription
    [ -p TDL root directory path ]A TDL root directory. Default value: $TDLDIR or $TMAXDIR.
    [ -m library name ]Removes a specified library from a TDL shared memory and relevant files from a run directory.
    [ -M function name ]Removes a specified function from shared memory. Relevant files in a run directory are not removed. If VERSION is set to 1, the result of this option will be the same as a [-m] option.
    [ -b ]

    A shared memory file is not backed up even if a BACKUP parameter is specified in a TDL configuration file <tdl.cfg>.

    Cannot be used with [-m] or [-M] options.

    [ -d yyyymmddhhmi ]

    Removes all outdated library files created before a specified date and time (yyyymmddhhmi).

    Cannot be used with [-m] or [-M] options.

    [ -D "n hour|day" ]

    Removes all outdated library files created before a specified hour or day.

    Cannot be used with [-m] or [-M] options.

    [ -N number ]

    Removes outdated library files except for a specified number of outdated libraries.

    Cannot be used with [-m] or [-M] options.

    [ -v | -V ]Shows version information.
    [ -h ]Shows command Help.
  • Examples

    • The following removes outdated library files:

      $ tdlclean
    • The following removes library files that were created before 00:00 on February 1st, 2009:

      $ tdlclean –d 200902010000
    • The following removes library files older than five days:

      $ tdlclean -D "5 day"
    • The following removes mylibrary from a TDL shared memory and outdated files:

      $ tdlclean -m mylibrary

2.3.3. tdlnm

The tdlnm command retrieves a list of functions that are automatically exported to a specified library when a VERSION is set to 2 or higher.

  • Usage

    $ tdlnm [-p TDL root directory path] [-x export function extraction script file path]
            [-m library name] [-v | -V] [-h]
    OptionDescription
    [ -p TDL root directory path]A TDL root directory. Default value: $TDLDIR or $TMAXDIR.
    [ -x export function extraction script file path ]The path of script file that extracts an export function.
    [ -m library name ]A library that retrieves a list of automatic export functions.
    [ -v | -V ]Shows version information.
    [ -h ]Shows command Help.
  • Example

    The following retrieves a list of export functions of a mylibrary file:

    $ tdlnm -m mylibrary

2.3.4. tdlrm

The tdlrm command removes shared memory when a TDL is no longer used. tdlcall() cannot be called after this command is executed.

  • Usage

    $ tdlrm [-p TDL root directory path] [-v | -V] [-h]
    OptionDescription
    [ -p TDL root directory path ]A TDL root directory. Default value: $TDLDIR or $TMAXDIR.
    [ -v | -V ]Shows version information.
    [ -h ]Shows command Help.
  • Example

    The following removes a TDL shared memory:

    $ tdlrm

2.3.5. tdlshm

The tdlshm command retrieves information about a TDL shared memory and enables/disables statistics monitoring and modules.

  • Usage

    $ tdlshm [-p TDL root directory path] [-r] [-S] [-n node name] [-m function name] 
             [-M library name] [-C] [-c start_index end_index] [-s e|d|r] 
             [-u e|d] [-I mincol] [-v | -V] [-h]
    OptionDescription
    [ -p TDL root directory path ]A TDL root directory. Default value: $TDLDIR or $TMAXDIR.
    [ -r ]Retrieves information about modules that are currently synchronizing updates in a multi-node environment.
    [ -S ]Retrieves information about dynamic module statistics. Statistics include runtime AVG/MIN/MAX and CPU AVG/MIN/MAX for each module.
    [ -n node name ]A node to be retrieved in the multi-node environment.
    [ -m function name ]A function to be retrieved.
    [ -M library name ]A library to be retrieved.
    [ -C ]Executes a dlopen and dlsym for all modules.
    [ -c start_index end_index ]Executes a dlopen and dlsym for modules within a specified index range.
    [ -s e|d|r ]

    Dynamic module statistics monitoring.

    • e: Enable

    • d: Disable

    • r: Initialize

    [ -u e|d ]

    A Dynamic module.

    • e: Enable

    • d: Disable

    This option must be used with [-m] or [-M] options because only a single module can be set at one time.

    • A [-m] option must be specified when a VERSION is set to 1 or 2 because a module name must be unique for all libraries. A function name used as an argument of the [-m] option must be unique.

    • [-m] and [-M] options must be specified when a VERSION is set to 3 because function names can be the same if their libraries differ. The [-M] option must be used with the [-m] option.

    [ -I minimum collision count ]

    Displays a comparison count when buckets are searched due to hash collisions for each module. Information about modules with a collision count greater than or equal to a value is displayed. This option can be used with [-p], [-m], [-M], and [-r] options. The value must be 0 or greater.

    [ -I mincol ]

    Displays a comparison count, in a "Collision=n" format, when a hash collision occurs in a module. If n is 0, only one comparison was found.

    mincol is a minimum comparison count. The value must be greater than 0. When displaying each module, only information about modules with a comparison count greater than a specified value are displayed. Set mincol to a large value to quickly find a function with a high comparison count.

    This option can be used with [-p], [-m], [-M], and [-r] options.

    [ -v | -V ]Shows version information.
    [ -h ]Shows command Help.
  • Examples

    • The following is the basic usage of tdlshm:

      $ tdlshm TDLDIR = /home/jeffry/tmax LOGDIR = /home/jeffry/tmax/log/dlog 
      - BACKUP = /home/jeffry/tmax/log/dlog/tdl.bak VERSION = 2, SHMKEY = 0x90000, 
      - IPCPERM = 0750 MAXMODULES = 256, CURMODULES = 3, Global SEQNO = 45e27d28, 
      - MONITOR = Y MODE = SINGLE, DOMAINID = 1 Index = 125, Funcname = myfunction1, 
      - Libname = myfunction1, Seqno = 45e27d28, Active = Y Index = 126, 
      - Funcname = myfunction2, Libname = myfunction2, Seqno = 45e27d28, Active = Y, 
      - Index = 127, Funcname = myfunction3, Libname = myfunction3, Seqno = 45e27d28, 
       Active = Y 
    • The following retrieves information about TDL statistics:

      $ tdlshm -S TDLDIR = /home/jeffry/tmax LOGDIR = /home/jeffry/tmax/log/dlog 
      - BACKUP = /home/jeffry/tmax/log/dlog/tdl.bak VERSION = 2, SHMKEY = 0x90000, 
      - IPCPERM = 0750 MAXMODULES = 256, CURMODULES = 3, Global SEQNO = 45e27d28, 
      - MONITOR = Y MODE = SINGLE, DOMAINID = 1 Index = 125, Funcname = myfunction1, 
      - Libname = myfunction1, Seqno = 45e27d28, Active = Y Count = 0 SVC: Avg = 0.000, 
      - MinTime = 0.000, Maxtime = 0.000 CPU: Avg = 0.000, MinTime = 0.000, 
      - Maxtime = 0.000 Index = 126, Funcname = myfunction2, Libname = myfunction2, 
      - Seqno = 45e27d28, Active = Y Count = 0 SVC: Avg = 0.000, MinTime = 0.000, 
      - Maxtime = 0.000 CPU: Avg = 0.000, MinTime = 0.000, Maxtime = 0.000 Index = 127, 
      - Funcname = myfunction3, Libname = myfunction3, Seqno = 45e27d28, Active = Y 
      - Count = 0 SVC: Avg = 0.000, MinTime = 0.000, Maxtime = 0.000 CPU: Avg = 0.000, 
      - MinTime = 0.000, Maxtime = 0.000 
    • The following is the result when [-s] or [-u] options are used:

      $ tdlshm -s r
      $ tdlshm -s e -m myfunction
      $ tdlshm -s d -m myfunction
      $ tdlshm -u e -m myfunction
      $ tdlshm -u d -m myfunction
    • The following is the result when [-C] or [-c] options are used:

      $ tdlshm -C
      $ tdlshm -c 0 1024
      $ tdlshm -c 1024

2.3.6. tdlsync

The tdlsync command synchronizes a backup file with a TDL shared memory. This command is necessary when automatic backup is disabled.

  • Usage

    $ tdlsync [-p TDL root directory path] [-B backup file path] [-v | -V] [-h]
    OptionDescription
    [ -p TDL root directory path ]A TDL root directory. Default value: $TDLDIR or $TMAXDIR.
    [ -B backup file path ]A backup file path.
    [ -v | -V ]Shows version information.
    [ -h ]Shows command Help.
  • Example

    The following example backs up shared memory with a file specified as a BACKUP in a TDL configuration file <tdl.cfg>:

    $ tdlsync

2.3.7. tdlupdate

The tdlupdate command updates a specified dynamic module. A library name must be specified with a [-m] option. If a specified library is already registered, the library will be updated. If the library is not registered, it will be added. This command can be executed only in a master node in a multi-node environment.

  • Usage

    $ tdlupdate [-p TDL root directory path] [-x export export function extraction script file path] [-f] 
                [-m library name] [-b] [-c] [-l file name] [-v | -V] [-h]
    OptionDescription
    [ -p TDL root directory path ]A TDL root directory. Default value: $TDLDIR or $TMAXDIR.
    [ -x export function extraction script file path ]The path of a script file that extracts an export function.
    [ -f ]Updates a function by force even if a function with the same name exists in another library when a VERSION is set to 2.
    [ -m library name ]A library to be updated.
    [ -b ]Does not backup a shared memory file even if a BACKUP is specified in a TDL configuration file.
    [ -c ]Executes version synchronization between nodes in a multi-node environment.
    [ -l file name ]Creates a file that contains a list of modules to be updated, and then updates the modules. The module delimiter is a comma (,) or a newline.
    [ -v | -V ]Shows version information.
    [ -h ]Shows command Help.
  • Examples

    • The following updates a <mylibrary.so> file:

      $ tdlupdate -m mylibrary
    • The following updates multiple modules. The delimiter is a comma (,), and spaces are not allowed. There is no limit to the number of modules, but the maximum number is 1024 in a multi-node environment.

      $ tdlupdate -m mylibrary,mylibrary2,mylibrary3
    • The following creates a file that contains a list of modules to be updated, and then updates the modules. There is no limit to the number of modules in the file, but the maximum number is 1024 in a multi-node environment.

      $ tdlupdate -l update.list
    • The following is an <update.list> file. A comma (,) and newline can be used as a delimiter:

      mylibrary,mylibrary2
      mylibrary3
    • The following synchronizes nodes when there is an inconsistency in shared memory in a multi-node environment:

      $ tdlupdate -c

  • Note

    A script file that extracts an export function is required when a VERSION is set to 4:

    /* Example of exp file */
    /* dlib.exp */
    
    #! dlib.so
    TmaxSoft::Airplain
    Car