Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


A Mobilink Primer
What is it?

A session-based synchronization technology designed to synchronize UltraLite and Adaptive Server Anywhere databases with many industry-standard SQL database management systems from Sybase and other vendors.

We use it to synchronize data from one or more bookstores to a consolidated database running at their warehouse. This lets them run reports that aggregate data from many stores, transfer stock between stores, centralize purchasing, and do stock look-ups and one-time data entry,

How Does It Work?
Data synchronization is initiated by the client using dbmlsync. This creates a socket connection to dbmlsrv9, which is running on the consolidated server. It uses port 2439.

Mobilink Commands
Here are example commands for the server and client respectively. Note that they assume that you have a database called blconsolidated.db in your root directory and DSN entries called BLConsolidated and BlRemote for your server and client respectively.

C:\>dbsrv9 -n BLConsolidated blconsolidated.db
C:\>dbmlsrv9 -c "DSN=BLConsolidated" -v+ -dl -o ml.txt -vcrs -o debug.txt -zu+
C:\>dbmlsync -c "DSN=BLRemote" -v+ -dl -e Verbose='on' -o rem.txt

The first command starts the consolidated database server. The second starts the Mobilink synchronization server. The last is the command issued by the client to start the synchronization process.

How Do We Tell It What To Sync?
By its publication. What's that? A database object that identifies replicated data. In MobiLink publications exist only on the clients. A publication consists of articles. Periodically, the changes made to each publication are replicated to all subscribers to that publication. MobiLink users can synchronize a publication by creating a synchronization subscription to it.

If you look in Sybase Central you can see the definition of our multi-site publication. It's listed under publications and is called Booklog.

You must specify which tables and columns you want to replicate. A wildcard publication is specified by the '*' and indicates all columns. These are bad though because as you'll see on the server we must define what columns are going to be received from the client. The ordering of these two must match. If they don't the scripts won't work. So consider the addition of a column to a table without modificating the server-side scripts, if you have a wildcard publication, well, you just broke synchronization for that table.

What Are the Server-Side Scripts and What Do They Do?
There are many, look in the help, but there are three we usually code for:

  • download_cursor - What data should be pushed from the server to the client
  • upload_insert - Called after detecting an insert has occurred on the client
  • upload_update - Called after detecting a modification has occurred on the client
The server-side scripts are stored on consolidated. You can see them by connecting to the Mobilink synchronization service in Sybase Central then look under synchronized tables. For each synchronized table, you'll see their respective server-side scripts.

How Does Mobilink Know What Changes Have Occurred on the Client?
Through the transaction log. That's why you must never delete it.

Let's look at the relationship between a Mobilink publication and server-side scripts for the color_tb. First the client publication, (remember this is stored on the remote db), it has two columns published as part of its article. They are co_code and co_desc. Again you can look at it if you connect to the remote database using Sybase Central and look under the publication tab.

Now, the server-side scripts (remember this is stored on the consolidated db), it has the three scripts we discussed earlier. Once again, you can look at them if you connect to the Mobilink synchronization service and look under the synchronized table tab for the color_tb.

Next we 'll look at how columns are added to articles in the publication and how server-side scripts are added to consolidated in code. This work is done in the upgrade scripts for client and server programs respectively.

How to Modify the Server-Side Scripts in the Upgrade Object for the color_tb
There are three cases:

  • if exec_sql("call ml_add_table_script('default', 'color_tb', 'download_cursor', 'SELECT co_code, co_desc, new_col FROM color_tb WHERE last_updt_time >= ?');") < 0 then return -1
  • if exec_sql("call ml_add_table_script('default', 'color_tb', 'upload_insert', 'call GROUP1.AddColor(?,?,?)');") < 0 then return -1
  • if exec_sql("call ml_add_table_script('default', 'color_tb', 'upload_update', 'UPDATE color_tb SET co_desc = ?, new_col = ? WHERE co_code = ?');") < 0 then return -1
Mobilink is time-based synchronization. That's why we have a last_updt_time in the download_cursor. This prevents data from being re-downloaded.

The question mark is a placeholder for the data that's sent to consolidated. It will be sent in the order in which it's defined in the table. That's why the order of your scripts must match what's defined by the remote table definition.

For the upload_update event you'll specify the primary key as part of the where clause.

For the upload_insert event, we call a stored procedure to do the insert, but we didn't have to. It's just one technique for making the insertion into consolidated. An INSERT statement could have been used instead.

Now for a closer look at the stored procedure used to add server-side scripts, ml_add_table_script(....)

Function
Use this stored procedure to add or delete SQL table scripts in the consolidated database:

ml_add_table_script(version VARCHAR(128), table_name VARCHAR(128), event VARCHAR(128), script TEXT)

Description
When you add a script, the script is inserted into the ml_script table and the appropriate references are defined to associate the script with the table, event, and script version you specify. If the version name is new, it's automatically inserted into the ml_version table.

To delete a table script, set the script parameter to NULL.

What Does That Modified Stored Procedure for the update_insert Event Look Like?

ALTER PROCEDURE "GROUP1"."AddColor"
   (
    IN code char(5),
    IN description char(30),
    IN parm3 char(30)
   )
BEGIN
    IF NOT EXISTS ( SELECT 1 FROM color_tb WHERE co_code = code ) THEN
       INSERT INTO color_tb
       (co_code, co_desc, new_col) VALUES (code, description, parm3 );
    ELSE

    END IF
;
END

Resources

  • MobiLink Synchronization User's Guide (part of the online help)
  • www.ianywhere.com
  • www.risingroad.com
  • www.google.com
  • www.sybase.com/developer/newsgroups
  • Breck Carter. SQL Anywhere Studio 9 Developer's Guide. Wordware Publishing, Inc. 2004. ISBN 1-55622-506-7
  • About Deanne M. Chance
    Ms. Chance graduated in 1996 with a degree in computer science from the University of Illinois. She has been a frequent contributor to the PowerBuilder Developer's Journal and gave a key presentation at Sybase TechWave 2005 entitled "A Real-Time Physical Inventory Solution Using PocketBuilder ASA and a WiFi Connection." She has held several engineering positions, starting a career at Motorola where she focused on mobile I.P. by doing real-time embedded programming for the base radio controller group as part of the iDEN/Nextel project.

    In order to post a comment you need to be registered and logged in.

    Register | Sign-in

    Reader Feedback: Page 1 of 1

    A session-based synchronization technology designed to synchronize UltraLite and Adaptive Server Anywhere databases with many industry-standard SQL database management systems from Sybase and other vendors. We use it to synchronize data from one or more bookstores to a consolidated database running at their warehouse. This lets them run reports that aggregate data from many stores, transfer stock between stores, centralize purchasing, and do stock look-ups and one-time data entry,


    Your Feedback
    PBDJ News Desk wrote: A session-based synchronization technology designed to synchronize UltraLite and Adaptive Server Anywhere databases with many industry-standard SQL database management systems from Sybase and other vendors. We use it to synchronize data from one or more bookstores to a consolidated database running at their warehouse. This lets them run reports that aggregate data from many stores, transfer stock between stores, centralize purchasing, and do stock look-ups and one-time data entry,
    Enterprise Open Source Magazine Latest Stories . . .
    Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP). The...
    With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference... We have technical and st...
    AMD said late Tuesday that its chief sales officer Emilio Ghilardi had left the company and that CEO and president Rory Read is going to do his job while a replacement is sought. AMD didn’t say why Ghilardi left but it’s assumed Read wants his own people. Read is relatively new to th...
    During the lifespan of M3 (Monitis Monitor Manager) there has always been something lacking – timers. M3 execution procedure was outlined in this previous article. The execution mentioned in the latter was a one-time-execution, whereas server monitoring requires periodic invocati...
    Red Hat is putting its bought-in Gluster scale-out NAS storage technology, acquired in October, on the Amazon cloud. It’s styled Red Hat Virtual Storage Appliance for Amazon Web Services and other clouds are supposed to follow in short order.
    A new episode of the screencast series is now available at the OpenNebula YouTube Channel. This screencast demonstrates the new easily-customizable self-service portal for cloud consumers. Its aim is to offer a simplified access to shared infrastructure for non-IT end users. The scree...
    Subscribe to the World's Most Powerful Newsletters
    Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
    Click to Add our RSS Feeds to the Service of Your Choice:
    Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
    myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
    Publish Your Article! Please send it to editorial(at)sys-con.com!

    Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


    SYS-CON Featured Whitepapers
    ADS BY GOOGLE