Posts Tagged ‘UniData’

Update to Installing UniVerse on CentOS post

I’ve been asked a few times on how to get the U2 DBTools products, like XAdmin to connect to their VirtualBox machine. I obviously left something out in the article, so I’ve went back and updated the post for how to configure your firewall. You can follow these same steps for UniData as well.

Just to make sure you don’t miss it, I decided I should also duplicate it here…

Configure firewall

If you want to access UniVerse (say using XAdmin from the U2 DBTools package), you will need to modify your iptables configuration.

First, in my case I have the VirtualBox network adapter set to ‘Bridged’. Now, in a shell window update iptables ‘sudo vi /etc/sysconfig/iptables’

In vi, before any LOG or REJECT lines, add ‘-A INPUT -m state –state NEW -m tcp -p tcp –dport 31438 -j ACCEPT’.

Once that is done, you simple run ‘service iptables restart’ to pick up the changes.

The updated iptables file

The updated iptables file

XAdmin once connected

XAdmin once connected

Statement Code Coverage Testing – Part 2

November 26, 2011 1 comment

Back in November 2009 I posted the “UniBasic Code Coverage” project as an open-source project. Back then it was stripped version based on one I set up for my then employer. The version for my employer used an in-house pre-processor that greatly simplified the work I needed to do for it work with our source files.

I have now released the v0.2 (update: v0.8) development version which has fixed several bugs, added the ability to specific a customer pre-process for those don’t use string UniBasic and provided improved the documentation on installing, using and contributing.

As you will already be aware, the source code for this is hosting on the UniBasic Code Coverage Project at SourceForge in a Subversion repository. If you have Subversion installed, you can checkout the code with the following command:

svn co ucov

If you are running UniData or UniVerse on Windows, I highly recommend you install Tortoise SVN as it greatly simplifies working with Subversion.

On the SourceForge site you will not only find the Subversion repository for all the code, but also ‘Tracker’ which will allow you to submit Feature and Bug tickets. If you need help with anything, you can submit a Support Request as well.

If you wish to contribute to the code or documentation, you can introduce yourself on the Developer Forum. The best way to submit code or doc is by generating a Diff of the changes, as well as what the behaviour was before the change and what it was after the change.

When you have used UBC, be sure to fill out a Review. All constructive input is welcome and appreciated!

Replacing Legacy Reporting with U2 DataVu

November 5, 2011 2 comments

International Spectrum has published the first article I have ever written for a magazine.

The title of the article is “Replacing Legacy Reporting with U2 DataVu” and you can find it here on page 12.

Here is a quick tease:

We all know what they look like: hard-to-read reports with mono-spaced fonts and — aside from the columns of text and the occasional company header — completely barren. More often than not, customers must log into a terminal session in order to generate, print, or view the reports. These reports are almost never available in easily consumable or distributable formats such as PDF.

Let me know what you think!

Application Level Caching

August 26, 2011 Leave a comment

Everyone here probably knows the various levels of caching that exist on a modern computer: From multiple CPU caches through to disk cache and even caching in the database engine itself. If you want to quickly touch up on some caching concepts/terminology, check out this short slide deck from Serhiy Oplakanets on Caching Basics

What I’m going to do shortly is outline some other methods of gaining significant performance improvements on your UniData and UniVerse systems.

There really isn’t anything special outside of U2 that you will need to do to get benefits from this, although a few extra tricks that do require either additional hardware or OS work can give quite a boost

First, just to make sure everyone is on the same page: Since UniData and UniVerse support hash-tables as their file (table) structure, you can simply use a file as a gloried key-value store. Key-value stores are ideal for caching.

I’ve dividing this post into 4 sections:

  1. Session Level Caching
  2. Account Level Caching
  3. Improving the above (SSD and RAM Disk)
  4. In Summary

Let me know what you think.


Session Level Caching


COMMON provides a method of keeping a small in-memory cache for the entire duration of a session. Simply declare an array in a named common block and away you go.

A real world example, I’ve seen this used for when a dictionary item made a SUBR call to a subroutine that in turn would read a multitude of control items to process the original record. This dictionary item was called nightly by an external reporting tool on a large number of records.

The original solution had an unacceptable run-time and after some profiling, it was determined that the READs of the control items were the main culprit. Since it was known that the control items would not change (and should not) during the processing, it was determined that caching the control items in-memory after they were read would reduce the run-time.

The solution involved: An array of ‘x’ elements. When a control item needed to be read in, it checked this array via a simple look-up and if it existed, it used it. If not, it would read it from disk and store it in the array.

The result: 10+ hour run-time was now less than 1 hour.


Account Caching


Alright, so you have a system that needs to handle some messages (perhaps via some form of SOAP/REST web service) The majority are read requests with a few write requests for good measure.

One of these messages is to ‘Get Products’. This message returns a list of products (ID, name and latest available version) that a customer currently has.

In your system, there are 2 files used by this request. ‘CUSTOMERS’ and ‘PRODUCTS’. CUSTOMERS<30> is a multivalued list of record ids for ‘PRODUCTS’. PRODUCTS<1> is the name of the product and PRODUCTS<11> is the latest available version.

Traditionally for each ‘Get Products’ request your system would read in the appropriate record then read in all the linked records from PRODUCTS to compile the response to the query. Assuming an average customer has 10 products, the average disk reads for this query is 11

Now this query is being called a lot, all these extra disk reads and processing are beginning to cause performance impacts. Thankfully, because your database supports key-value storage, you can quickly implement a cache to sit in between the receipt of the message and the processing.

All that is needed is a new file called ‘CACHE.GETPRODUCTS’. @ID is the CUSTOMERS id requested in the query, <1> is the date requested, <2> is the time requested and <3> is the response generated

Now, when ‘Get Products’ query is received, it will first do a read of the cache file and if it exists, simply return <3>. If the entry doesn’t exist, it will hand the request/response off to the usual processing routine. The subsequent request will then be stored in the cache before being returned.

Assuming the average declared above, a cache hit will result in 1 disk read and a cache miss will result in 12 disk reads and 1 write. If – for ease of math – we treat a write equal to a read, you only need a 16.7% Cache hit rate for it to perform better. That isn’t even taking in to considering CPU usage reduction, better disk cache performance, etc.

How you handle cache invalidation is dependent on your situation. It could be as simple as clearing it every ‘x’ period, as straight forward ignoring the cache record if it is older than ‘y’ time or as complex as individually invalidating records based on when the appropriate records in CUSTOMERS or PRODUCTS change.

What has been implemented here is a cache that is available not only in the current session, but to any program running or that will be run in the account(s) that have access to this cache file.


Improving the above


Okay, so you have a more intensive system than the above and you have determined caching can help you out. The problem is, even with the caching it still doesn’t meet your requirements and disk has been determined to be the biggest bottleneck.

You have 2 next steps that can be implemented easily.

The Disk Approach

Simple drop in a shiny new SSD drive or a WD Raptor and move the cache files over there. No need to back them up, mirror them or anything else as caching files are temporary data. As long as your system is setup to recreate them if missing on start-up and treat it as a cache miss if unavailable during operation, you are all set.

The benefit here is faster disk access as well as moving the activity off on to another device/bus.

The RAM approach

Instead of adding new hardware, perhaps you’d prefer to spare 64MB of RAM to the cause. In this case, you would simply create a RAM Drive and move the cache files there. You have now essentially created a RAM based key-value store to use as your heart desires.

For an example of what type of improvements this can have, I took the DOSAC test I previously created and ran it twice. Once with the file on traditional disk and once with the file on RAM Disk. The system stats are identical to last time I ran the test, except it was on Fedora (it comes with multiple 16MB RAM disks pre-configured).



That’s right: Massive improvements, as expected (excuse the display text bug).


In Summary


So, keep this in mind. U2 Databases give you some great flexibility in how you implement your software. Knowing the options available is crucial to being able to get the best results.

As the saying goes, measure twice, cut once. Work out what your performance bottlenecks are then determine the best solution. Some times it is better hardware, sometimes it is code clean up. Sometimes… it might just call for caching.

Making Life Easier

Every developer worth their salt has little snippets of code that they use to make their life easier.

So today, I thought I’d share a little utility that I use all the time.

Readers, meet RL. RL, meet readers. RL (Run Line) allows you to run a single line of code to see what it does. Typically, I use this as a quick way to check out an OCONV express I haven’t used in a while or as a calc replacement if I don’t feel like tabbing out of the terminal. All you need to do is compile and catalog to enjoy its simpleness. RL supports 1 option, ‘-H’. This option allows you hide the compiler output if you wish.

To use RL, you can either enter the code as part of the command line arguments, or you can enter it as an input. Here is a screenshot of RL in action:

RL Utility

RL Utility


Disclaimer: I strongly recommend against implementing this on a production machine as it will allow arbitrary code execution. This code has only been tested on UniData 7.2.x. Feel free to use this code however you want. If you somehow turn this in to something profitable share the love and either buy me a beer or make a donation to an open source project.

Okay, so enough with the spiel. Here’s the code :
(Updated 2011-06-02 due to ‘<-1>’ being stripped)


EQU TempDir TO "_PH_"

OPEN TempDir TO FH.TempDir ELSE STOP "ERROR: Unable to open {":TempDir:"}"

* Determine if we should hide compiler output
* Also determine the start of any command line 'code'

   HideFlag = @TRUE
   CodeStart = COL2() + 1
   CodeStart = COL1()
   IF CodeStart = 0 THEN
      CodeStart = LEN(@SENTENCE) + 1 ;* Force it to the end
      CodeStart += 1 ;* Skip the Space

   HideFlag = @FALSE

* Get the code from the command line arguments, or
* Get the code from stdin

   Code = @SENTENCE[CodeStart, LEN(@SENTENCE) - CodeStart + 1]
   Code = TRIM(Code, " ", "B")
   PROMPT ''
   CRT "Enter Code: ":
   INPUT Code

* Compile, catalog and run the program
* We only catalog it so that @SENTENCE behaves as you would expect

WRITEU Code TO FH.TempDir, TempProg ON ERROR STOP "ERROR: Unable to write {":TempProg:"}"

Statement = "BASIC ":TempDir:" ":TempProg
Statement<-1> = "CATALOG ":TempDir:" ":TempProg:" FORCE"

IF HideFlag THEN
   EXECUTE Statement


* Clean up time

DecatStatement = "DELETE.CATALOG ":TempProg

DELETE FH.TempDir, "_"TempProg
DELETE FH.TempDir, TempProg


Installing UniData on Fedora 14

May 30, 2011 5 comments

For some future upcoming posts, I needed to install UniData on a Linux Machine.

Since I’m already going through the effort of freshly installing both Fedora and UniData, I thought I would share required steps so anyone else who wanted to create a similar test system can do so just as easily. It turns out to be quite simple and straight forward, with only minor set up tasks along the way.

Firstly, I suggest you do this in a Virtual Machine so that you can create as many dedicated test systems as your heart desires (or storage limits). For this I’ve used Sun’s Oracle’s Virtual Box which is available for free. To make it easier, I’ve also got instructions for the few extra preparation steps you will need to do the Fedora installation in Virtual Box


Okay, so to start, let’s make sure we have everything we need to do this:

  1. Suggested: Dual Core CPU or better (particularly if running as a VM)
  2. Suggested: 1GB RAM or better (particularly if running as a VM)
  3. Virtual Box software
  4. Fedora 14 ISO
  5. UniData Personal Edition for Linux

Preparing the VM

After you have installed Virtual Box and have it running, we will need to create a new image to run Fedora. Doing this is as simple as clicking the ‘New’ button and follow the prompts. Most questions can be left as is, except for the operating system. For the operating system, set it to ‘Linux’ with version ‘Fedora’.

The default 8GB Dynamic disk is just fine. You can always create and add more disks later.

Now that you have your machine image ready, select the image and click on the settings button. In this screen click on the storage option and select the DVD drive from the IDE Controller. On the right-side there is a small CD/DVD image you can click on. This will let you select the Fedora 14 ISO you downloaded so that it will boot from it.

While in the settings screen, you should also add a shared folder and click on the read-only and auto-mount checkbox options.

Installing Fedora

Fedora 14 VM for UniData

Fedora 14 VM for UniData

If you are not installing this as a virtual machine, you can burn the ISO image to CD/DVD and start the machine with the CD/DVD in the drive. Only do this is you know what you are doing or are intending to have the Fedora as the sole operating system.

If you are installing this as a virtual machine, select the VM image and click on the start button.

Fedora should auto-boot from the Fedora image. Once it has loaded and is sitting at the desktop, there is an ‘Install to Hard-Disk option’. Click on this and simply follow the installation instructions Fedora provides

Installing UniData

Before you can install UniData on Fedora 14, you must first install the library. You can download and install the RPM for here

Apart from the above missing dependency, it is as simple as following the installation manual provided by Rocket Software.

The only other point of note from the initial installation is that not all the escape characters in udtinstall are processed correctly, so expect to see a few lines like “\tWould you like to continue?”

Now you will need to set up the environment variables you will need. To do this, ensure you are in a shell as root or that you run these commands as root. Change to the /etc/profile.d directory. In here we are going to create a file that will contain all the environment variables UniData requires.

Just type in ‘gedit &’ to bring up a text editor (or just use vi/emacs) to paste the following into:

   UDTHOME=/usr/ud72 ; export UDTHOME
   UDTBIN=$UDTHOME/bin ; export UDTBIN

Restart the machine or run the new script as root and you should be able to run ‘startud’ as root. If UniData boots up correctly, open a non-root shell and type in ‘cd $UDTHOME/demo’ then ‘udt’ and you should successfully jump into ECL.

There you have it, a working UniData server running in a Virtual Machine

Disclaimer: This does not create a UniData server that will be appropriate to run as a production server.

Categories: Database Tags: , , ,

New Developer Zone – U2 PHP PDO Driver

March 2, 2011 1 comment

Rocket U2 Developer Zone


I spent last week at the U2 University in Sydney and had a great time. During the opening keynote speech, Rocket announced the new U2 Developer Zone.

Great news! Finally a public site for developers that links all the resources you would expect. White papers, podcasts, demos, links to manuals, personal editions of the database servers. Not just a public site, but a public site for developers from Rocket itself. That’s what we needed, strong, visible vendor support of the development community.

It is still a bit rough with a fair amount of content missing, but it has enough in there to make it worth signing up (free) to check it out.

It breaks the site down into 4 key areas.

  • Ignite
  • Launch
  • Accelerate
  • Dock

Ignite is aimed at new players and features explanations of what Multi-Value Databases are, some information about U2 as well as summaries of the Developer & Admin tools available for download.

Launch works on getting a developer up and running as quickly as possible with instructions and links for downloading and installing both the UniVerse/UniData servers, as well as their 4GL tool – SB/XA. A bonus is some professional looking video tutorials for getting them up and running.

Accelerate is focused more on in-depth content of the system with various articles and tutorials that have been produced by Rocket as well as some community figures as well.

Dock appears to be aimed at the forming a community/developer collaboration. It has links to U2UG as well as Rocket U2 on Facebook and Twitter (even though the twitter link is missing on the site at the moment). It also has a message board, but this appears to be one of those unfinished features for the time being.

One point of disappointment at the moment is ‘The Wall’ it throws up to get any content. It requires you to sign-up and log in before you can actually access the content. While I can appreciate their probable reasonings for this and appreciate it is still free, I believe this is one of those things that will prevent those who stop by from search results/ideal curiosity from actually getting involved.

By throwing up a wall, instead of openly allowing read-only access, it has a 2 fold effect. First, google (and other search engines) will not be able to correctly index the content. In an age where > 90% of website traffic generally comes from search engines, this is definitely not ideal. The other negative effect is that the bounce rate of people not currently involved will surely be higher.

Hopefully they will review this decision and decided upon a more open and effective path.


U2 PHP PDO Driver


So, my title indicated something about a U2 PHP PDO Driver and you were not mislead. While at the U2U Conference I had the pleasure of, among others, speaking with Jackie from Rocket Software. At one point the conversation turned towards dynamic languages and in particular, PHP. I was told that some tutorials had actually been written on getting PHP to natively connect to U2 and should be able to be found on the new developer site. Bingo!

After some quick searching on the site, I present you 2 links so you can build your own native connector between PHP and U2:

Hopefully you find this useful!

%d bloggers like this: