Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » MobiLink - 服务器管理 » MobiLink 事件 » 同步事件

 

download_statistics 连接事件

跟踪有关下载操作的同步统计信息。

参数

在下表中,说明部分提供 SQL 数据类型。如果您使用 Java 或 .NET 编写脚本,则应该使用相应的数据类型。请参见SQL-Java 数据类型SQL-.NET 数据类型

在 SQL 脚本中,可以使用名称或问号指定事件参数,但不能在一个脚本中混合使用名称和问号。如果使用问号,则参数必须按照如下所示的顺序并且仅当没有指定任何后继参数时才是可选的(例如,如果您想使用参数 2,则必须使用参数 1)。如果使用命名参数,则可以按照任何顺序指定任意参数子集。

SQL 脚本的参数名称

说明

顺序

s.remote_id VARCHAR(128)。MobiLink 远程 ID。只有在使用命名参数时才能引用远程 ID。 不适用

s.username

VARCHAR(128)。在 SYNCHRONIZATION USER 定义中指定的 MobiLink 用户名。

1

s.warnings

INTEGER。发出的警告的数目。

2

s.errors

INTEGER。发生的错误的数目,包括已处理的错误。

3

s.fetched_rows

INTEGER。download_cursor 脚本读取的行数。

4

s.deleted_rows

INTEGER。download_delete_cursor 脚本读取的行数。

5

s.filtered_rows

INTEGER。从 deleted_rows 参数实际发送到远程数据库的行数。它反映了已上载的值的下载过滤。

6

s.bytes

INTEGER。作为下载发送到远程数据库的字节数。

7

缺省操作

无。

注释

download_statistics 事件可用于为所有用户收集关于下载的统计信息。download_statistics 连接脚本紧接在下载事务结束时执行提交操作之前被调用。

注意

并不是所有警告和错误都被记录下来,是否记录取决于命令行,因此实际警告和错误的数目将大于被记录下来的警告和错误的数目。

另请参见
SQL 示例

以下示例将同步统计插入一个名为 download_audit 的表中。

CALL ml_add_connection_script(
 'ver1', 
 'download_statistics', 
 'INSERT INTO download_audit(
   user_name, 
   warnings, 
   errors, 
   deleted_rows, 
   fetched_rows, 
   download_rows, 
   bytes )
  VALUES (
   {ml s.username}, 
   {ml s.warnings}, 
   {ml s.errors}, 
   {ml s.fetched_rows}, 
   {ml s.deleted_rows}, 
   {ml s.filtered_rows}, 
   {ml s.bytes})')

在审计表中插入重要的统计信息之后,您将可以使用这些统计信息监控同步过程并在条件允许时进行优化。

Java 示例

以下对 MobiLink 系统过程的调用在同步脚本版本 ver1 时将名为 downloadStatisticsConnection 的 Java 方法注册为 download_statistics 事件的脚本。

CALL ml_add_java_connection_script(
  'ver1',
  'download_statistics',
  'ExamplePackage.ExampleClass.downloadStatisticsConnection' )

以下是 Java 方法 downloadStatisticsConnection 示例。它将读取的行数输出到 MobiLink 消息日志。(请注意:将读取的行数输出到 MobiLink 消息日志在开发时可能会有帮助,但会降低生产服务器的性能。)

public String downloadStatisticsConnection(
  String user,
  int warnings,
  int errors,
  int fetchedRows,
  int deletedRows,
  int bytes ) {
  java.lang.System.out.println( 
   "download connection stats fetchedRows: " 
   + fetchedRows );
  return ( null );
}
.NET 示例

以下对 MobiLink 系统过程的调用在同步脚本版本 ver1 时将名为 DownloadStats 的 .NET 方法注册为 download_statistics 连接事件的脚本。

CALL ml_add_dnet_connection_script(
  'ver1',
  'download_statistics',
  'TestScripts.Test.DownloadStats'
)

以下是 .NET 方法 DownloadStats 示例。它将读取的行数输出到 MobiLink 消息日志。(请注意:将读取的行数输出到 MobiLink 消息日志在开发时可能会有帮助,但会降低生产服务器的性能。)

public string DownloadStats(
  string user,
  int warnings,
  int errors,
  int deletedRows,
  int fetchedRows,
  int downloadRows,
  int bytes ) {  
  System.Console.WriteLine( 
   "download connection stats fetchedRows: " 
   + fetchedRows );
  return ( null );
}