Anda di halaman 1dari 14

INTRODUCTION TO jBase

Objectives

 To understand the working of the jBase database and the directory structure of jBase.
 To understand the environmental variables that control the jBase database
 To understand the daemons that control the working of jBase
 To understand the different types of files in jBase and the mechanism to create them.
 To understand the jBase file resizing commands.

1.1 Introduction To DBMS

In a relational database you can link data from several different tables. Tables
are made up of records (tuples), which are further divided into fields. With a relational database,
you can normalize data. So for example if you have Customers and Orders you can establish a 1
to many relationships. One Customer can have many Orders and you can read the two files
together, linking them with a key. As such you only have 1 customer record, for all the orders with
that customer. This saves on inputting and maintenance time and on storage space. In a
relational database, fields are of a fixed length and each field can contain only 1 value.

2.1 Introduction To jBase

jBase is an application development and database management system that


enhances and extends the UNIX Operating System. Most of the Unix commands can be
executed from within jBase. It allows existing applications to be easily migrated from other
DBMS’s, including PICK and REALITY. JBase uses the ‘C’ compiler to compile programs.

3.1 File And Directory Organization

jBase has a directory structure similar to that of Unix. Following are some of the
directories that get installed when jBase is installed.

jbase

bin config jspooler lib tmp dev

Figure 1.1 Directory Structure Of jBase

bin Contains all the binary executables that make up the jBase system including the
compilers.
config contains various configuration files relating to the jPML daemon(discussed later
in this session), the configuration file for the creation of library files(Discussed in
the session ‘Infobasic Programming ‘) and other configuration files.
lib Contains the library files that are required for the working of jBase. This directory
contains all the libraries required for linking executing jBC compiled programs.
Shared or Dynamic libraries are also stored here.
tmp This is a general purpose temporary directory for runtime use.
jspooler This is the spool directory of jBase. It contains all the files that are required for
spooling to work in jBase

Temenos Training Publications


24
4.1 The jBase Daemons

jBase uses background daemon processes to handle specific tasks or


features. The following are the various jBase daemons.

4.1.1 jBTP jBase Background Task Processor

The jBTP daemon is responsible for managing and controlling jBase


background processes. The jBTP daemon can be used to allocate/deal locate, start/stop and
suspend/resume background processes.

4.1.2 jPML jBase Process Manager and Licensing

The jPML daemon is responsible for managing and licensing jBase processes
and ports. It registers and licenses jBase processes and allocates static or dynamic port
numbers. The jPML daemon also retains certain environment details. which can then be parsed
between related processes. The jPML daemon reads the configuration file, Config_jPML, from the
$JBCGLOBALDIR/config directory at startup time. This configuration file contains the ranges of
port numbers that the jPML daemon will allocate for processes running jBase background tasks,
and also for any jBase processes that it cannot allocate a relative port number. The configuration
file may also contain hard coded ttyname/port number entries. These entries will override any
other port number allocation scheme.

When the jPML daemon is initiated, as mentioned above it reads the


configuration file Config_jPML and loads the port numbers onto the memory. Whenever a user
wishes to connect to the server, a free port number is obtained from the range of port numbers
loaded onto the memory and assigned to the user.

The following examples describe the different jPML entries.

port_background = 1000 1099 - defines range for 100 background ports


port_foreground = 1100 1199 - defines range for 100 foreground ports
port_def = /dev/tty01s 33 - defines port 33 for process of ttyname
/dev/tty01s

The configuration file also contains the text of the jBASE disconnect message and logon prompt

4.1.3 jRLA jBASE Record Lock Arbiter

The lock arbiter is responsible for resolving all record locking conflicts for jBASE
processes. It runs in the background on your system and is commonly referred to as the lock
daemon1. If jRLA is not loaded, jBASE will use the normal UNIX system locks. This is acceptable
for small user populations, but the UNIX locking mechanism has limits on the number of locks
available, and on performance. Only enable the jRLA locking daemon when no other users are
executing jBASE programs, otherwise some applications will use UNIX system locks and others
will use the jRLA locking daemon. In most situations a process will take and release locks
autonomously and disregard both the lock daemon and other processes. However in certain
situations it must inform the daemon of events or ask the daemon for permission. These
situations only occur when there are clashes in locking such as when a process finds that a
record is already locked or that another process requires the same lock.

Temenos Training Publications


25
The above-mentioned 3 phantoms need to be started in the following order and
stopped in the reverse order.

jRLA -ib
jPML –ib
jBTP –ib

To stop the phantoms

jBTP –k
jPML –k
jRLA -k

5.1 Important jBase Environmental Variables

jBase is controlled by a number of environmental variables. These variables


control the working of jBase. All these variables will get set in the .profile of the user thus enabling
the user to work in a jBase environment.

5.1.1 JBCRELEASEDIR

It contains the path where jBase is installed. When jBase is installed, a link is
created for the directory where jBase has been installed to a file named jbc under the usr
directory. Therefore we can refer to /usr/jbc as the directory where jBase has been installed.

JBCRELEASEDIR = /usr/jbc
Example 1

ln –s /jbase /usr/jbc

/jbase is the directory where jBase has been installed


/usr/jbc jbc is the name of the file under the /usr directory where to which the link has been
established

A link is usually created to the directory where jBase has been installed in order to facilitate
smooth and convenient migration of users from one jBase environment to another. When users
who are currently working on one environment need to start working on another jBase
environment on the same server, then instead of changing the value of the environment variables
to point to the path of the other jBase environment, we could just remove the old link and make
the link point to the directory where other jBase environment resides. It is a convention to create
the link to /usr/jbc.

5.1.2 JBCGLOBALDIR

It contains the path of the Config directory (Discussed earlier in this section) of
jBase. jBase refers this variable when it needs to refer/read configuration files. Usually it points to
the same path as that of JBCRELEASEDIR as the config directory is present there.

JBCGLOBALDIR = /usr/jbc

Temenos Training Publications


26
5.1.3 PATH

It is a Unix variable used in jBase. In Unix, it contains the search path of Unix
executables. Here apart from containing the search path of Unix executables, it will also contain
the search path of jBase executables. As you would be aware, the bin directory under the
directory where jBase has been installed contains all the jBase executables. Therefore, this
variable would point to that bin directory.

PATH=$PATH:/usr/jbc/bin

Note that the search path of jBase executables has been appended to the
existing contents of the PATH variable.

5.1.4 LIBPATH

It contains the path of the jBase library files. As you would be aware by now, the
jBase library files are stored under the lib directory, which is under the directory where jBase has
been installed. Therefore this variable would point to that lib directory.

LIBPATH = /usr/jbc/lib

Note that the variable LIBPATH needs to be used only for AIX machines. Use
SHLIB_PATH for HP and LD_LIBRARAY_PATH for all other types of machines to store the path
of jBase executables.

5.1.5 JBCSPOOLERDIR

It contains the path of the spool files of jBase. As discussed earlier, the jspooler
directory under the directory where jBase has been installed holds all the spool files of jBase.
Therefore this variable would point to the jspooler directory.

It is the decision of the system administrator whether to keep the jspooler


directory under the directory where jBase has been installed or move it to a common location
like /usr. In the first case, the jspooler directory becomes jBase release specific. All users working
in that specific release of jBase would be using that jspooler directory. In the second case,
irrespective of the release of jBase, which the user is using, all of them will use a common tmp
directory. In the below mentioned example the jspooler directory has been moved to a common
location, has been given the correct permissions as every jBase user needs to access it.

JBCSPOOLERDIR=/usr/jspooler

5.1.6 JBCBASETMP

It contains the path of the jBase tmp directory. Every operating system and
database has its own tmp directory to store any temporary information. As mentioned earlier the
directory named ‘tmp’ that gets installed when jBase is installed is jBase’s tmp directory. It is the
decision of the system administrator whether to keep the tmp directory under the directory where
jBase has been installed or more it to a common location like /usr. In the first case, the tmp
directory becomes jBase release specific. All users working in that specific release of jBase would
be using that tmp directory. In the second case, irrespective of the release of jBase, which the
user is using, all of them will use a common tmp directory. In the below mentioned example, the
tmp directory has not been moved anywhere.

JBCBASETMP=/usr/jbc/tmp

Temenos Training Publications


27
5.1.7 JEDIFILENAME_MD

Each jBase account has a vocabulary file called the VOC file. The VOC file
contains entries that identify every verb; sentence, paragraph, file, keyword, and menu that you
can use while you are in a jBase account. The command processor uses the VOC file to decide
what action to take when you enter a command.

The Voc (Vocabulary) file can also be called the MD, Master Directory
JEDIFILENAME_MD=$HOME/VOC

Sample Commands Pertaining To VOC

CT VOC CT CT = Copy to Terminal. Display on screen the entry


for the command ‘CT’ in the Voc directory
LIST VOC This will list all the entries in the Voc file
Q Quit process
Types Of VOC Entries

There are several types of entries in the VOC File:

D Data Field Definition


F File definition
K Keyword
M Menu Record
PA Paragraph
PQ Proc
Q Remote file pointer (Q Pointer)
R Remote
S Sentence
V Verbs (commands)
X User Record

> LIST VOC WITH TYPE = “V” To see all the Verb Voc entries. You can also list the
Voc entries for the other entry types
For each VOC entry type run this command to list all
entries of that type, then use CT to look at them

Temenos Training Publications


28
Below is a guide to the most commonly used entry types:

Sentence A sentence is a complete command line, including


the verb. For example LISTME:

S Sentence entry type


STATUS ME Sentence text

Paragraph A paragraph is a series of sentences stored together


under 1 name. For example LOGIN:
PA Paragraph entry type
HUSH ON Sentence 1
UMASK 077 Sentence 2
CLR Sentence 3
BLOCK.TERM TRAIN Sentence 4
UMASK 0 Sentence 5

File Pointers A file pointer is used to point to files For example


CUSTOMER:

CT VOC FBNK.CUSTOMER
FBNK.CUSTOMER Type of VOC entry. Denotes a file.
001 F Path of the data file with the actual truncated name
002 ../mbdemo.data/st/FBNK.CUST000
003 ../mbdemo.dict/F.CUSTOMER]D Path of the dict file with the actual truncated name

Q Pointers This is a pointer, not to a physical file, but the


account where it lives. The advantage of this is
that you can then move the physical file and you
don’t need to change all the file pointers. Q
pointers will update automatically. For example
VAN:

Q Q pointer entry type


DEV Account
BP Filename

5.1.8 JBCLISTFILE

This is the environmental variable that contains the path of the &SAVEDLISTS&
directory. When a SELECT statement is issued from the database prompt, the output of the
SELECT statement can be saved using the SAVE.LIST command followed by the name of a file
that is to store the selected ids. This file created by SAVE.LIST will get stored under the
&SAVEDLISTS& directory and can be retrieved any time using the GET.LIST followed by the file
name.

Temenos Training Publications


29
JBCLISTFILE=$HOME/&SAVEDLISTS&

Example:

jsh geneva ~ -->SELECT FBNK.CUSTOMER


501 Records selected

>SAVE.LIST TEMENOS
501 record(s) saved to list 'TEMENOS'

jsh geneva ~ -->GET.LIST TEMENOS


501 Records selected

>JED FBNK.CUSTOMER
The above JED command will open all the customer records that were selected using the SELECT

6.1 Creating Files In jBase

In an RDBMS, a table would look like

EMPLOYEE TABLE

EMP.ID NAME ADDRESS PHONE DOB


1 TOM XXX XXX XXX
2 YYY YYY YYY YYY
3 ZZZ ZZZ ZZZ ZZZ
4 XYZ XYZ XYZ XYZ
Figure 2.1 Employee Table

In jBase, tables are referred to as files. Every file in jBase has two portions. The
DATA portion and the DICTionary portion. Unlike other databases, jBase stores
the data and the file structure separately. The actual data of a file (records) is stored in the DATA
portion of the file and the file structure(the fields and their definitions) are stored in the DICT
portion of the file. These two portions of the file may exist in the same physical location or could
exist in different physical locations.

For instance the CUSTOMER file in Globus would internally have 2 files. The
DATA file will have the name CUSTOMER and the DICT file would have the name
CUSTOMER.]D.

1 xxx yyy S.NO -- properties


2 xxx yyy NAME -- properties
3 xxx yyy ADDRESS -- properties

DATA Portion Of A File DICT Portion Of A File


Figure 3.1 Structure Of A jBase File

Temenos Training Publications


30
Following are the 2 different types of files supported by uniVerse.

I. Non-hashed files
II. Hashed files

I. Non-hashed files

These files are nothing but UNIX directories. They are used store files /
programs. The file type for a non-hashed file is ‘UD’

II. Hashed files

Hashed files in jBase are used to store data files. All Globus data files are
hashed. Hashed files use Hashing algorithms to read and write data onto data files. Hashing
algorithms enable dynamic access (read and write) to data there by reducing the read and write
time. There are 2 types of hashed files namely, J3 and J4. The data portion of all hashed files are
divided into groups called ‘Modulos’. The default size of one modulo if it is a J3 type hashed file is
1024 bytes and if it is a J4 type hashed file it is 4096 bytes. All Globus hashed files are of type
J4.The size of the modulo is determined by ‘Separation’. Both modulo and separation are
specified for the DATA and the DICT portion of a file.

For instance, while creating a hashed file, if we specify the modulo as 4 and the
separation as 4 for both the DATA and the DICT portion of the file then the following will be the
layout of the file

4*1024 4*1024 4*1024 4*1024 4*1024 4*1024 4*1024


4*1024
4096 4096 4096 4096 4096 4096 4096
4096
Bytes Bytes Bytes Bytes Bytes Bytes Bytes
Bytes Modulo 1 Modulo 2 Modulo 3 Modulo 4
Modulo 1 Modulo 2 Modulo 3 Modulo 4

Data Portion Of A Hashed File Dict Portion Of A Hashed File


Figure 4.1 Structure Of A Hashed File Type J3

4*4096 4*4096 4*4096 4*4096 4*4096 4*4096 4*4096 4*4096


16384 16384 16384 16384 16384 16384 16384 16384
Bytes Bytes Bytes Bytes Bytes Bytes Bytes Bytes
Modulo 2 Modulo 3 Modulo 4 Modulo 1 Modulo 2 Modulo 3 Modulo 4
Modulo 1

Data Portion Of A Hashed File Dict Portion Of A Hashed File


Figure 5.1 Structure Of A Hashed File Type J3

Temenos Training Publications


31
Note:
When a hashed file is created in jBase, the facility to define the secondary
buffer size is available. The default size of the secondary buffer size is twice the size of one
modulo. If a specific value is specified for the secondary buffer size then the size of the
secondary buffer size is the ‘specified value * size of one modulo. J4 is the default type of file
created in jBase when no specific type is mentioned.

Example 1

Create a hashed file TEMENOS of type J4 with the following values

Dict Modulo : 3
Dict Separation : 2
Dict Secondary Buffer Size : 3
Data Modulo : 4
Data Separation : 3
Data Secondary Buffer Size : Default

Solution 1

CREATE.FILE TEMENOS TYPE=J4 3,2,3 4,3

Dict Parameters Data Parameters

Note :
When no value is supplied for the secondary buffer size like above then the default
value of 2 is taken.

Output

CREATE.FILE TEMENOS TYPE=J4 3,2,3 4,3


File TEMENOS12]D created , type = J4
File TEMENOS12 created , type = J4

Example 2

Create a non-hashed file named TEMENOS1.

Solution 2

CREATE.FILE TEMENOS1 TYPE=UD

Output

CREATE.FILE TEMENOS1 TYPE=UD


File TEMENOS11]D created , type = UD
File TEMENOS11 created , type = UD

Temenos Training Publications


32
7.1 File Maintenance In jBase

As you would be aware, a badly sized file will result in low performance of the
system. Therefore it is absolutely necessary to resize files periodically.

7.1.1 jstat

jstat is the command in jBase that is used to determine the statistics of a hashed file.

Example 1

jstat FBNK.ACCOUNT

Output

File ../mbdemo.data/ac/FBNK.ACCOUNT
Type=J4 , Hash method = 4
Groups = 9,Frame size = 4096 bytes ,Secondary Record Size = 8192 bytes
Record Count = 2001 , Record Bytes = 775029
Bytes/Record = 387 , Bytes/Group = 86114
Primary file space: Total Frames = 196 , Total Bytes = 775029
Secondary file space: Total Frames = 0 , Total Bytes = 0

Analysis

Find below the line by line analysis if the above output of jstat.

Line 1 : Displays the relative path of the file with the actual name of the file. Files could have
truncated names because of file name length restriction imposed by Unix.

Line 2 : Displays the type of the file (J3/J4). The default hash method for all jBase hashed files is
4, which is what is specified in ‘Hash Method’.

Line 3 :
Groups : Represents the modulo of the file when it was created
Frame Size : Represents the size of 1 modulo. Here the size of 1 modulo is 4096bytes
therefore the separation would have been 1 when the file was created, as it is a J4 file.
Secondary buffer size : Represents the size of the secondary buffer size. The value is
8192Bytes which is twice the size of 1 modulo. Therefore when the file was created the
secondary buffer size specified would have been 2.

When the file was created it was created as a J4 file with modulo 9, separation 1 and
secondary buffer size as 2.

Line 4 :

Record Count : Specifies the total number of records in the file at present
Record Bytes : Specifies the total number of bytes occupied by the file at present

Line 5 :

Bytes/Record : Specifies the average size of 1 record


Bytes/Group : Specifies the average size of 1 modulo at present

Temenos Training Publications


33
Line 6 :

Total Frames : If this contains a value greater than the original modulo of the file then it
denotes that the file is badly sized and needs resizing. In this example, when the file was
created, it was created with a modulo of and ‘Total Frames’ now shows a value of 196.
This file needs to be resized. In the above example a value of 196 in ‘Total Frames’ does
not mean that the number of modulos have increased automatically. Any extra space
occupied by the file to hold its data is converted in terms of modulos and specified here.
Total Bytes : Specifies the total space occupied by the file in terms of bytes.

7.1.2 Options With jstat

Following are the options that can be used along with jstat.

f - free space display


r - record display
s - short summary display
v - verbose
w - do not wait on locked records

Example 2

jstat –r FBNK.ACCOUNT

Shows modulo wise data split of data. In this example, though the size of 1
modulo is only 4096 Bytes, each modulo seems to occupy more than 8000 Bytes of data. This
denotes a sure overflow of data and denotes the fact the file needs resizing.

Output

File ../mbdemo.data/ac/FBNK.ACCOUNT
Type=J4 , Hash method = 4
Groups = 9 , Frame size = 4096 bytes , Secondary Record Size = 8192 bytes

Frame Allocated Used


-------- -------- --------
0 86016 83526
**************************************************************************************
****************
**************************************************************************************
****************************
1 94208 90011
**************************************************************************************
****************
**************************************************************************************
********************************************
2 90112 86446
**************************************************************************************
****************
**************************************************************************************
************************************
3 86016 81775
**************************************************************************************
****************

Temenos Training Publications


34
**************************************************************************************
**********************
4 86016 84119
**************************************************************************************
****************
**************************************************************************************
****************************
5 90112 87100
**************************************************************************************
****************
**************************************************************************************
*************************************
6 94208 91570
**************************************************************************************
****************
**************************************************************************************
**********************************************
****
7 90112 87622
**************************************************************************************
****************
**************************************************************************************
**************************************
8 86016 82860
**************************************************************************************
****************
**************************************************************************************
**************************

Record Count = 2001 , Record Bytes = 775029


Bytes/Record = 387 , Bytes/Group = 86114
Primary file space: Total Frames = 196 , Total Bytes = 775029
Secondary file space: Total Frames = 0 , Total Bytes = 0

7.1.3
jrf

jrf is the command in jBase that is used to resize hashed files.

Example 1

Resize the FBNK.ACCOUNT file (discussed in the above examples) to avoid any
overflow of data.

Analysis

In order to resize a file we need to calculate the new modulo. The


FBNK.ACCOUNT file is now 775029 Bytes big. The amount of data 1 modulo can hold is only
4096 Bytes as the separation was specified as 1 when the file was created. In order for the
FBNK.ACCOUNT file to hold 775029 Bytes of data we would require

775029/4096 = 190 modulos (Approximately).

When deciding the modulo, the number of records that might get into the file on
an average need to be kept in mind and then calculated. In this case we could assume that this

Temenos Training Publications


35
file could have about 10 new records every week. Every record would occupy approximately
about 387 Bytes. Therefore the file would grow in size by (387 * 10 = 3870 Bytes) every week,
which would occupy approximately 1 modulo. Therefore we could specify the modulo as 195 so
that the file would require resizing only after a week. Files, depending on the number of records
that get into them every day, need to be resized weekly, monthly, quarterly etc.

Note :
A large separation could result in low performance as the hashing algorithms that are
used to store and retrieve data would only specify the modulo in which the record that is
requested (during a read) is present. Inside the modulo it is always a sequential search.
Therefore a huge separation will result in low performance. To determine the separation, the
average size of a record should be kept in mind.

Solution 1

jrf –S195 ../mbdemo.data/ac/FBNK.ACCOUNT

The –S option with jrf is used to specify the new modulo for the file. Please note
that to resize the file the actual name of the file with the relative path (relative to the home
directory) of the file needs to be given. The relative path of the file and the actual name of the file
can be obtained from the output (1st line) of the jstat command.

7.1.4 Options With jrf

Following are the options that can be used with the jrf command.

H# - Changes hash type to # (1-4)


D - Allows downsize
E - Resize empty files
I - Ignore empty files
R - Suggest modulo
V, -V1 - Verbose and very verbose mode
S# - Resize to modulo #

Note :
When using the D and the E option to downsize and resize empty file respectively they
need to be used in conjunction with the S option as follows
jrf –DS# filename
jrf –ES3 filename

Summary

 jBase has a similar directory structure to that of Unix


 The bin directory contains all the jBase executables
 The lib directory contains all the jBase library files
 The config directory contains the configuration files of jBase
 The tmp directory contains the temporary data that the database wishes to store
 The jspooler directory contains the jBase spool files
 JBCRELEASEDIR contains the path where jBase has been installed
 JBCGLOBALDIR contains the path of the jBase config directory
 PATH contains the path of the jBase executables ($JBCRELEASEDIR/bin)

Temenos Training Publications


36
 LIBPATH for AIX SHLIB_PATH for HP and LD_LIBRARAY_PATH are the variables that
will hold the path of the jBase library files($JBCRELEASEDIR/lib)
 JBCSPOOLERDIR contains the path of the jBase spooler files
 JBCBASETMP contains the path of the jBase tmp directory
 J4 files are hashed files and the default size of 1 modulo is 4096 bytes
 J3 file are hashed files and the default size of 1 modulo is 1024 bytes
 UD files are non hashed files
 jstat is the command that is used to determine the statistics of a hashed file in jBase
 jrf is the command that is used to resize hashed files in jBase

Additional Information

VOC Entries

Verb A verb is an executable. For example LIST:

> CT VOC LIST Display the Voc entry for the verb LIST
V Descriptor
LIST Processor. (Name of the programme executed)
Q Dispatch Type. (Type of programme: Q=query)
S Processor Mode (Required setup: S = user select)
Reserved

Keyword A keyword defines an operation or qualifier that


takes place in a sentence or modifies the operation
of a verb. For example COUNT:

K Keyword entry type


378 Operation Number
COUNT.VERB Sentence (Optional for when the keyword is also
used as a verb)
(The most common keywords are =, EQ, >, GREATER, WITH, >= and GT)

Remote A remote will act as a pointer to a command not


in the Voc directory. This is to prevent clogging
up the Voc file with big commands, which can
slow down system performance. For example
LISTO:

R Remote entry type


JBASE.VOCLIB Filename
LISTO Record.ID

Refer the ‘jGlobus’ course material for additional information and information
about installation of jBase, patch installation, printing in jBase, locking in jBase etc.

Temenos Training Publications


37

Anda mungkin juga menyukai