Collection Contents 上一页 下一页 PDF

MobiLink 管理指南

同步事件

MobiLink 事件概述


当有同步请求发出且 MobiLink 服务器确定必须建立新连接时,将触发 begin_connection 事件并启动同步。

Flowchart of the MobiLink event model, showing the begin_connection event, a pre-defined process called do synchronizations, and an end_connection event.

随着同步的进行,连接被放入连接池中,MobiLink 再次等待出现对当前脚本版本的同步请求。在一个连接被最终从连接池中删除之前,将触发 end_connection 事件。但是如果接收到另一个对同一脚本版本的同步请求,MobiLink 将在同一连接上处理下一个同步请求。有很多事件会对当前同步产生影响。

同步的主要阶段是上载和下载事务。上载和下载事务中包含的事件将在下面介绍。

上载事务 

上载事务应用从远程数据库上载的更改。

begin_upload 事件标志着上载事务的开始。上载事务是一个由两个部分组成的过程。首先上载所有远程表中的插入和更新操作,然后上载所有远程表中的删除操作。

Flowchart of the MobiLink upload transaction process.

end_upload 事件标志着上载事务的结束。

有关上载过程中所发生事件的详细信息,请参见编写用于上载行的脚本

下载事务 

下载事务从统一数据库中读取行。它开始于 begin_download 事件。

下载事务是一个由两个部分组成的过程。对于每个表,首先下载删除操作,然后下载更新/插入行 (upsert)。end_download 事件结束下载事务。

Flowchart of the MobiLink download transaction process.

有关下载过程中所发生事件的详细信息,请参见编写用于下载行的脚本

下面的伪代码概述了调用各种事件以及随之调用同名脚本的序列。

伪代码事件概述 

下面的伪代码显示了完整的 MobiLink 同步事件模型。此模型假定存在一个没有出现错误的完整同步(而不是仅上载同步或仅下载同步)。

注意 
警告 
在您的同步脚本中或从您的同步脚本调用的过程或触发器中,不应有任何隐式或显式提交。脚本内的 COMMIT 或 ROLLBACK 语句会改变同步步骤的事务性质。如果您使用这两个语句,在出现故障时您将无法保证数据的完整性。
------------------------------------------------------
Synchronization events in pseudocode.

Legend:
- // This is a comment
- <name>
    The pseudo code for <name> is listed separately
    in a later section, under a banner:
        ------------------------
        name
        ------------------------
- VariableName <- value
    Assign the given value to the given variable name.
    Variable names are in mixed case.
- event_name
    If you have defined a script for the given event name,
    it will be invoked.
------------------------------------------------------
CONNECT to consolidated database
begin_connection_autocommit
begin_connection
COMMIT
for each synchronization request with 
     the same script version {
  <synchronize>
}
end_connection
COMMIT
DISCONNECT from consolidated database
------------------------------------------------------
synchronize
------------------------------------------------------

<authenticate>
<begin_synchronization>
<upload>
<prepare_for_download>
<download>
<end_synchronization>
------------------------------------------------------
authenticate
------------------------------------------------------

Status <- 1000
UseDefaultAuthentication <- TRUE
if( authenticate_user script is defined ) {
  UseDefaultAuthentication <- FALSE
  TempStatus <- authenticate_user
  if( TempStatus > Status ) {
    Status <- TempStatus
  }
}
if( authenticate_user_hashed script is defined ) {
  UseDefaultAuthentication <- FALSE
  TempStatus <- authenticate_user_hashed
  if( TempStatus > Status ) {
    Status <- TempStatus
  }
}
if( UseDefaultAuthentication ) {
  if( the user exists in the ml_user table ) {
    if( ml_user.hashed_password column is not NULL ) {
      if( password matches ml_user.hashed_password ) {
        Status <- 1000
      } else {
        Status <- 4000
      }
    } else {
      Status <- 1000
    }
  } else if( -zu+ was on the command line ) {
    Status <- 1000
  } else {
    Status <- 4000
  }
}
if( Status <= 2000 ) {
  if( authenticate_parameters script is defined )
 {
    TempStatus <- authenticate_parameters
    if( TempStatus > Status ) {
      Status <- TempStatus
  }
}
if( Status >= 3000 ) {
  ROLLBACK
  // Abort the synchronization.
} else {
  // UserName defaults to MobiLink user name
  // sent from the remote.
  if( modify_user script is defined ) {
  UserName <- modify_user
  // The new value of UserName is later passed to
  // all scripts that expect the MobiLink user name.
  }
  COMMIT
}
------------------------------------------------------
begin_synchronization
------------------------------------------------------

begin_synchronization   // conection event
for each table being synchronized {
    begin_synchronization    // call the table level script
}
for each publication being synchronized {
  begin_publication
} 
COMMIT
------------------------------------------------------
end_synchronization
------------------------------------------------------

for each publication being synchronized {
  if( begin_publication script was called ) {
    end_publication
  }
}
for each table being synchronized {
  if( begin_synchronization table script was called ) {
    end_synchronization // table event
  }
}
end_synchronization     // connection event

for each table being synchronized {
synchronization_statistics // table event
}
synchronization_statistics // connection event
for each table being synchronized {
time_statistics // table event
}
time_statistics // connection event

COMMIT

有关上载流处理的详细信息,请参见上载过程中的事件

有关下载流处理的详细信息,请参见下载过程中的事件


上载过程中的事件
下载过程中的事件

Collection Contents 上一页 下一页 PDF