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

SQL Anywhere 17 » MobiLink - Server Administration » MobiLink events » Synchronization events

synchronization_statistics connection event

Tracks synchronization statistics.

Parameters

In the following table, the description provides the SQL data type. If you are writing your script in Java or .NET, use the appropriate corresponding data type.

In SQL scripts, you can specify event parameters by name or with a question mark. Using question marks has been deprecated. Use named parameters instead. You cannot mix names and question marks within a script. If you use question marks, the parameters must be in the order shown below and are optional only if no subsequent parameters are specified (for example, you must use parameter 1 if you are going to use parameter 2). If you use named parameters, you can specify any subset of the parameters in any order.

Parameter name for SQL scripts Description Order (deprecated for SQL)
s.remote_id VARCHAR(128). The MobiLink remote ID. You can only reference the remote ID if you are using named parameters. Not applicable

s.username

VARCHAR(128). The MobiLink user name.

1

s.warnings

INTEGER. The number of warnings issued during the synchronization.

2

s.errors

INTEGER. The number of errors that occurred during the synchronization.

3

s.deadlocks

INTEGER. The number of deadlocks in the consolidated database that were detected for the synchronization.

4

s.synchronized_tables

INTEGER. The number of client tables that were involved in the synchronization.

5

s.connection_retries

INTEGER. The number of times the MobiLink server retried the connection to the consolidated database.

6

s.script_version VARCHAR(128). Optional IN parameter to specify that the MobiLink server passes the script version string used for the current synchronization to this parameter. Question marks cannot be used to specify this parameter. Not applicable
Default action

None.

Remarks

The synchronization_statistics event allows you to gather, for any user and connection, various statistics about the current synchronization. The synchronization_statistics connection script is called just before the commit at the end of the end synchronization transaction.

Note Depending on the command line, not all warnings are logged. The warnings count passed to this script is the number of warnings that would be logged when no warnings are disabled, which may be more than the number of warnings logged.
SQL example

The following example inserts synchronization statistics into the sync_con_audit table.

CALL ml_add_connection_script(
  'ver1',
  'synchronization_statistics',
 'INSERT INTO sync_con_audit(
   ml_user, 
   warnings, 
   errors,
   deadlocks, 
   synchronized_tables,
   connection_retries)
  VALUES (
   {ml s.username}, 
   {ml s.warnings}, 
   {ml s.errors}, 
   {ml s.deadlocks}, 
   {ml s.synchronized_tables}, 
   {ml s.connection_retries})' )

Once statistics are inserted into the audit table, you may use these statistics to monitor your synchronizations and make optimizations where applicable.

Java example

The following call to a MobiLink system procedure registers a Java method called synchronizationStatisticsConnection as the script for the synchronization_statistics connection event when synchronizing the script version ver1.

CALL ml_add_java_connection_script(
  'ver1',
  'synchronization_statistics',
  'ExamplePackage.ExampleClass.synchronizationStatisticsConnection'
)

The following is the sample Java method synchronizationStatisticsConnection. It logs some of the statistics to the MobiLink message log. (Logging statistics to the MobiLink message log might be useful at development time but would slow down a production server.)

package ExamplePackage;
public class ExampleClass {
    String _curUser = null;
public void synchronizationStatisticsConnection(
  String user, 
  int warnings, 
  int errors, 
  int deadlocks,
  int synchronizedTables, 
  int connectionRetries ) {
  java.lang.System.out.println( 
   "synch statistics number of deadlocks: " 
   + deadlocks );
  }}
.NET example

The following call to a MobiLink system procedure registers a .NET method called SyncStats as the script for the synchronization_statistics connection event when synchronizing the script version ver1.

CALL ml_add_dnet_connection_script(
  'ver1',
  'synchronization_statistics',
  'TestScripts.Test.SyncStats'
)

The following is the sample .NET method SyncStats. It logs some of the statistics to the MobiLink message log. (Logging statistics to the MobiLink message log might be useful at development time but would slow down a production server.)

namespace TestScripts
{
    public class Test
    {
	public void SyncStats( string	user,
			       int	warnings,
			       int	errors,
			       int	deadLocks,
			       int	syncedTables,
			       int	connRetries ) 
	{
	    System.Console.WriteLine( "synch statistics number of deadlocks: " + deadLocks );
	}
    }
}