Novell Home

Detecting Synthetic Time Programmatically

Novell Cool Solutions: Feature
By Peter Kuo

Digg This - Slashdot This

Posted: 5 Jun 2005
 

Previously, we discussed how you can determine if synthetic time is being used by examining console messages and from DSRepair logs on NetWare servers or using the health check option in iMonitor or via SNMP reporting for non-NetWare platforms.

This article presents a simple Win32 utility that can query an eDirectory server (regardless if it is NetWare or not) to see if synthetic time is being used, and if synthetic timestamps are being issued, how far ahead the future timestamp is so you can decide if a new time epoch should be declared using DSRepair or simply wait for the real time to catch up.

Associated with each replica is an attribute called Partition Status. This attribute contains information such as the name of the server hosting the replica, the last sync time, and so on. Unfortunately, it does not contain (at least not in a documented manner) the lastest timestamp that was issued by the system. Therefore, we cannot simply use the NWDSRead() API call to retrieve the Partition Status attribute and obtain the synthetic time information. That would be too easy! Instead, one must make use of the "DSP Replica Information Flags" (DSP flags for short). Using these flags in conjunction with the NWDSListPartitionsExtInfo() API call, one can retrieve a large number of replica-related information. The supported flags are:

Flag Name

Description

DSP_PARTITION_ID

Entry ID of the partition's root object on the local server

DSP_REPLICA_STATE

Current replica state

DSP_MODIFICATION_TIMESTAMP

The most recent modification timestamp and event ID

DSP_PURGE_TIME

Time at which all data has been synchronized

DSP_LOCAL_PARTITION_ID

Entry ID of the partition

DSP_PARTITION_DN

Distinguished name of the partition

DSP_REPLICA_TYPE

Replica type (e.g. Master)

DSP_PARTITION_BUSY

Flag indicating if partition is busy (e.g. being merged, split, or moved)

Of particular interest here is the DSP_MODIFICATION_TIMESTAMP flag. It tells NWDSListPartitionsExtInfo() to retrieve the most recent "real" timestamp -- that is, the last timestamp used when synthetic time is /not/ in effect. If the server is currently using synthetic time, the timestamp will be a time in the future. By comparing the timestamp returned using the DSP_MODIFICATION_TIMESTAMP flag against the current system time, one can easily determine if synthetic time is being used: if the returned timestamp is later in time (i.e. larger in value) than the current time, then synthetic time is in effect. This is also how iMonitor determines if synthetic time is being issued.

A simple Win32 console application, syntheticTime, was developed using C and Novell Developer Kit's eDirectory library to illustrate the above concepts. The following is a sample output from syntheticTime.exe which shows the server is not using synthetic time.

C:\>synthetictime w2k-test-nds.sitea
syntheticTime v1.0, Copyright (C) 2005  Peter Kuo (www.DreamLAN.com)
 +---------------------------------------------------+
 | syntheticTime comes with ABSOLUTELY NO WARRANTY.  |
 | This  is  free software, and you  are welcome to  |
 | redistribute or modify it under the GPL licensing |
 | terms.                                            |
 +---------------------------------------------------+

         Replica [Root]: No synthetic time in use.
         Replica O=DreamLAN: No synthetic time in use.
         Replica O=SiteA: No synthetic time in use.

The following illustrates the date is rolled back by a week in order to cause synthetic time:

C:\>date
The current date is: Tue 05/31/2005
Enter the new date: (mm/dd/yy) 05-24-2005
C:\>synthetictime w2k-test-nds.sitea
syntheticTime v1.0, Copyright (C) 2005  Peter Kuo (www.DreamLAN.com)
 +---------------------------------------------------+
 | syntheticTime comes with ABSOLUTELY NO WARRANTY.  |
 | This  is  free software, and you  are welcome to  |
 | redistribute or modify it under the GPL licensing |
 | terms.                                            |
 +---------------------------------------------------+

        Replica [Root]: Synthetic time in effect.
        Last "real" timestamp is 148:21:46 (534106 seconds) in the future.
        Replica O=DreamLAN: Synthetic time in effect.
        Last "real" timestamp is 167:57:13 (604633 seconds) in the future.
        Replica O=SiteA: Synthetic time in effect.
        Last "real" timestamp is 167:45:05 (603905 seconds) in the future.

Notice that the latest "real" timestamps on replicas O=DreamLAN and O=SiteA correspond to the seven day rollback as several objects were modified just before the date was changed. The timestamp on the [Root] replica is six days in the future as nothing there was changed for about a day before this time change.

The syntheticTime application accepts a server object name as command-line parameter, and determines if synthetic time has been issued for each replica hosted on the server. It sets an exit status code (so you can test for the result in a batch file):

 0 = no synthetic time in use
>0 = synthetic time in use (value depends on the number of replicas)
-1 = no server object name supplied
-2 = server has no replica
-3 = failed to obtain info from server

Download the executable and its C source code (ftp://ftp.dreamlan.com/Freeware/syntheticTime.zip)

A special thank you goes to Susan Perrin of Novell Developer Support for her explaining to me the dependencies and order of the NWDSListPartitionsExtInfo, NWDSGetPartitionExtInfoPtr, and NWDSGetPartitionExtInfo API calls.


Novell Cool Solutions (corporate web communities) are produced by WebWise Solutions. www.webwiseone.com

© 2014 Novell