The main purpose of our open-source DivConq Framework is to let Java developers quickly harness the power of MUMPS-compatible “NoSQL” databases. The real power of MUMPS comes not just from its flexible data structures, but in a large part from its stored procedures. To that end, DivConq Framework provides a reasonably easy and intuitive approach to utilize MUMPS stored procedures.
In the MUMPS world the stored procedures are call MUMPS routines, but for those coming from a SQL background just think “rich language for stored procedure coding”. MUMPS (M) has a rich ability for working with data structures not often found in SQL or NoSQL solutions. To learn more about coding MUMPS routines look to our Introduction to MUMPS series on this site.
This post will guide you through setting up your M and Java environments and testing connectivity.
Get the DivConq Framework here.
First we need to get M setup. If you have not already followed the instructions in Part one, Introduction to Mumps then do so now. Follow the instructions all the way up to leaving the M prompt when running from the ./gtmcon shell script.
Now establish an SFTP session from your desktop to the gtmuser. Upload all of the Mumps files from the DivConq download ( ./m/r/* ) to the gtmuser’s routine directory ( ~/.fis-gtm/r ). Also upload ./m/.bash_login to gtmuser’s home ( ~ ). Remove .bash_profile from gtmuser’s home, if present.
Once again return to the M prompt using ./gtmcon. A minimal install is required on the database before proceeding. You be asked to provide a hub id, use 5 digits, zero padded.
GTM>d ^dcInstall All data will be lost Are you sure you want to install? yes Hub Id: 00100 Audit level (1-4): 1 OK GTM>
Next we need to configure the project. From the command line enter the “template” folder. Run configure. Answer yes to the packages. When prompted for the database settings provide your own, this is just an example:
D:\dev\divconq\template>.\bin\run.bat configure Command configure Starting Hub ----------------------------------------------- DivConq Configure Menu ----------------------------------------------- 0) Exit 1) Install Project 2) Configure Database 3) Encrypt Setting 4) Hash Value 1 Adding packages, type 'yes' for packages you wish to include: Found: dcCore [yes/no]: yes Found: dcTest [yes/no]: yes Found: dctTemplate [yes/no]: yes Found: etlCore [yes/no]: yes Enter database connection settings. Host: mumps Port [enter for 22]: User: gtmuser Name of ssh key file [leave blank if not using client ssh key]: Password: A1s2d3f4 ----------------------------------------------- DivConq Configure Menu ----------------------------------------------- 0) Exit 1) Install Project 2) Configure Database 3) Encrypt Setting 4) Hash Value 0 D:\dev\divconq\template>
The database connection should now be tested. The easiest way to do that is use the testdb command. Note that results from the database may show intermixed with UI output, this is because results are processed async and as such may return at unpredictable times. Try this:
D:\dev\divconq\template>.\bin\run.bat testdb
Command testdb
Starting Hub
2011-12-12T20:29:43.616Z 00101_20111212T202943567Z_000000000000002 M03 Loading hub resources in developer mode.
2011-12-12T20:29:43.750Z 00101_20111212T202943567Z_000000000000002 M03 Hub resources loaded
2011-12-12T20:29:43.776Z 00101_20111212T202943567Z_000000000000002 B |Origin|hub:|Op|Start|
2011-12-12T20:29:43.779Z 00101_20111212T202943567Z_000000000000002 M03 Using hub id: 00101
2011-12-12T20:29:43.781Z 00101_20111212T202943567Z_000000000000002 M03 Starting Clock
2011-12-12T20:29:43.786Z 00101_20111212T202943567Z_000000000000002 M03 Starting Work Pool
2011-12-12T20:29:43.793Z 00101_20111212T202943567Z_000000000000002 M03 Initializing scheduler
2011-12-12T20:29:43.796Z 00101_20111212T202943567Z_000000000000002 M03 Initializing Databases
2011-12-12T20:29:43.799Z 00101_20111212T202943567Z_000000000000002 M03 Allocating Database Manager using id: default
2011-12-12T20:29:51.160Z 00101_20111212T202943567Z_000000000000002 M03 Starting scheduler
2011-12-12T20:29:51.162Z 00101_20111212T202943567Z_000000000000002 M03 Hub started
2011-12-12T20:29:51.164Z 00101_20111212T202943567Z_000000000000002 B |Origin|hub:|Op|Run|
-----------------------------------------------
Test dcDb Connector Menu
-----------------------------------------------
0) Exit
1) Ping
2) Echo with user input
3) Echo with hardcoded international chars
4) Load stored proc results (testProc1)
5) Check validity of toy list (testProc2)
6) Check validity of toy list (testProc3)
7) Switch Locale
8) Toy Database Example
1
-----------------------------------------------
Test dcDb Connector Menu
-----------------------------------------------
0) Exit
1) Ping
2) Echo with user input
3) Echo with hardcoded international chars
4) Load stored proc results (testProc1)
5) Check validity of toy list (testProc2)
dcPing Response:
6) Check validity of toy list (testProc3)
7) Switch Locale
8) Toy Database Example
{
"Text": "PONG"
}
3
-----------------------------------------------
Test dcDb Connector Menu
-----------------------------------------------
0) Exit
1) Ping
2) Echo with user input
3) Echo with hardcoded international chars
4) Load stored proc results (testProc1)
5) Check validity of toy list (testProc2)
dcEcho Response:
6) Check validity of toy list (testProc3)
7) Switch Locale
{ 8) Toy Database Example
"Text": "Hello there! - ?ñá?ÑÇ ßë? ?îå ?¿¼"
}
0
2011-12-12T20:30:07.948Z 00101_20111212T202943567Z_000000000000002 B |Origin|hub:|Op|Stop|
2011-12-12T20:30:07.950Z 00101_20111212T202943567Z_000000000000002 M03 Stopping hub
2011-12-12T20:30:07.952Z 00101_20111212T202943567Z_000000000000002 M03 Stopping scheduler
2011-12-12T20:30:07.955Z 00101_20111212T202943567Z_000000000000002 M03 Stopping logger
2011-12-12T20:30:07.958Z 00101_20111212T202943567Z_000000000000002 M03 Stopping work pool
2011-12-12T20:30:07.962Z 00101_20111212T202943567Z_000000000000002 M03 Stopping database
2011-12-12T20:30:08.028Z 00101_20111212T202943567Z_000000000000002 M03 Stopping clock
2011-12-12T20:30:08.033Z 00101_20111212T202943567Z_000000000000002 M03 Hub stopped
D:\dev\divconq\template>
Assuming that options 1 and 3 both returned the correct output for you then you have the connection settings correct. Do not try options 4-8 yet, they depend on a package that has not yet been fully installed. When you ran the Configure command you selected the “dcTest” package. That package now needs to be installed on M, do so with the synchronize utility.
D:\dev\divconq\template>.\bin\run.bat sync Command sync Starting Hub ----------------------------------------------- DivConq Repository Sync Menu ----------------------------------------------- 0) Exit 1) Sync M Routines 2) Sync M Globals 3) Translate en to pig-latin and rtl-en 1 M Routines updated ----------------------------------------------- DivConq Repository Sync Menu ----------------------------------------------- 0) Exit 1) Sync M Routines 2) Sync M Globals 3) Translate en to pig-latin and rtl-en 2 M Globals updated ----------------------------------------------- DivConq Repository Sync Menu ----------------------------------------------- 0) Exit 1) Sync M Routines 2) Sync M Globals 3) Translate en to pig-latin and rtl-en 0 D:\dev\divconq\template>
Wait for the reply “M Globals updated” before exiting. It may take a little time for the Hub to start, it depends on the time it takes to complete the SSH connection.
Now you can go back and run the testdb command. Try option 6:
D:\dev\divconq\template>.\bin\run.bat testdb
...
6
Enter toys, one per line. Empty to finish.
hammer
yoyo
...
2011-12-12T20:43:25.769Z 00101_20111212T204159976Z_000000000000003 M02 |Code|90002| Toy may not be safe: hammer
...
testProc3 Response:
[
"HAMMER",
"YOYO"
]
Note the warning message about hammer. Change locales:
7 Enter new locale: x-pig-latin
And option 6 again:
6
Enter toys, one per line. Empty to finish.
hammer
yoyo
...
2011-12-12T20:43:52.333Z 00101_20111212T204159976Z_000000000000003 M02 |Code|90002| Oytay aymay otay ebay afesay: hammer
...
testProc3 Response:
[
"HAMMER",
"YOYO"
]
Now the warning comes in pig latin. All the test calls should be working, meaning that the dcTest package is installed. We’ll review all the test code in the next post.
Published on Tuesday December 13, 2011 at 08:27am