Deletions are marked like this. | Additions are marked like this. |
Line 37: | Line 37: |
== Databases and Configuration== | == Databases and Configuration == |
Dual System DeawMGT Design and Implementation Notes
Contents
Data Transfer
Theory of Operation
Connection to narvi closed.
- The internal system actively contacts the shared system using a REST request:
- Polls for updates on shared system, stored in the staging area on the shared system
- Sends updates to the shared system
- The tables that are transferred are defined as site settings in the site settings file (See below)
- The list of tables to transfer is different for each system
- Database selects, inserts, updates and deletes cause triggers to:
- (do what)
- Anything else?
Overview Example Record Transver
Internal System to Shared System
- Shared system insert (or updates) a Comments record in the local database linthal114dev1
- An insert trigger named ? is activated, which ?
- ...
Shared System to Internal System
- to be completed
Databases and Staging Area
Databases and Configuration
Each system has two databases:
{site}{ver}{world}{subSiteId} - linthal114dev1 - Application database
{site}{ver}{world}{subSiteId}stg - linthal114dev1stg - Staging are database
The list of tables that are transfered are defined in the SiteSettings:
- cfg/{site}/site/condig/SubSiteSettings1.php
- cfg/{site}/site/condig/SubSiteSettings2.php
$_CFG['DbMirroring']['Tables'] = array( ..list of table names.. );
- is there other configuration information?
Database Triggers
Explain
- naming conventions for triggers, table names
- arethere triggers in the staging areas database. Using which names?
- genMeta -b generates trigger code?
Staging Database
The staging area has a single table MirrorRecords:
+--------------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +--------------------+---------------------+------+-----+---------+----------------+ | id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | createTimestamp | datetime | NO | | NULL | | | processStatus | int(11) | NO | MUL | NULL | | | statusTimestamp | datetime | NO | | NULL | | | tableName | varchar(64) | NO | | NULL | | | operation | char(1) | NO | | NULL | | | keyWhere | varchar(255) | NO | | NULL | | | phpSerializeRecord | text | YES | | NULL | | +--------------------+---------------------+------+-----+---------+----------------+
- explain the main fields
- explain processStatus
- explain use of phpSerializeRecord
Main Classes
Set the debug flag in these classes to see what is happening:
app/config/RestMap.php -- look for the mirror transactions. See below
app/event/handlers/MirrorInEH.php -- does what?
app/event/handlers/MirrorOutEH.php
lib/venture/util/Mirroring.php
Rest Requests
Mirroring Transactions
The following is a list of the REST URLs and what they are used for:
mirror/getnext - Mirroring::restGetNextRecord - does what?
mirror/{?}/setproc - Mirroring::restSetProcessed - What is the ? parameter for setproc?
mirror/procmirr - Mirroring::restSetProcessed
Authorization of Restransactions
to be completed (Tibor leave empty this for now)
- Plan to use an asymetric key
Configuration Issues
Software Packaged
The following packages are required (in addition to normal DrawMGT)?
- pecl_http
- Anything else?
Settings
Set URL of partner system:
- cfg/linthal/instance/narvi.softxs.ch-dev1/config/InstanceSettings.php
- cfg/linthal/instance/narvi.softxs.ch-dev2/config/InstanceSettings.php
$_CFG['SubSiteSettings']['RemoteBaseURL'] = 'http://narvi.softxs.ch/dev/linthal114dev2/';
Testing Issues
- how to inspect the staging area: what DB, table field to set to what value?
- how to reset status flags when errors occur
- any other tips?
- any special thing to look for in the log?
Show Next Record PHP Script
For displaying the next record to be processed. Calls the getnext REST transaction.
Run on the internal(?) system (can you run it on the shared system?)
Sets a read status flag (fieldname?) in the staging database, but this doesn' matter (causes a warning?)?
<?php function splitMirrorRecord() { } $r = new HttpRequest('http://narvi.softxs.ch/dev/linthal114dev2/mirror/getnext', HttpRequest::METH_GET); // $r->addQueryData(array('category' => 3)); try { $r->send(); if ($r->getResponseCode() == 200) { $content = $r->getResponseBody(); print "content:$content\n"; $record = unserialize($content); var_export( $record ); $dbrecord = unserialize($record['phpSerializeRecord']); var_export( $dbrecord ); } else { print( "response code: " . $r->getResponseCode() . "\n" ); } } catch (HttpException $ex) { echo $ex; } ?>