Recently I had a need to make a solution that can periodically clean replication history for list of databases.
Native LotusScript/Java classes do not allow that, but there is an C API for that.
Here is a cross platform solution (works for Windows/Linux)
Declare
Public Const W32_LIB = {nnotes.dll}
Public Const LINUX_LIB = {libnotes.so}
Declare Function W32_NSFDbOpen Lib W32_LIB Alias {NSFDbOpen} (ByVal dbName As String, hDb As Long) As Integer
Declare Function W32_NSFDbClose Lib W32_LIB Alias {NSFDbClose} (ByVal hDb As Long) As Integer
Declare Function W32_NSFDbClearReplHistory Lib W32_LIB Alias {NSFDbClearReplHistory} (ByVal hDb As Long, flags As Integer) As Integer
Declare Function LINUX_NSFDbOpen Lib LINUX_LIB Alias {NSFDbOpen} (ByVal dbName As String, hDb As Long) As Integer
Declare Function LINUX_NSFDbClose Lib LINUX_LIB Alias {NSFDbClose} (ByVal hDb As Long) As Integer
Declare Function LINUX_NSFDbClearReplHistory Lib LINUX_LIB Alias {NSFDbClearReplHistory} (ByVal hDb As Long, flags As Integer) As Integer
Using C API functions
// get a handler to database
If IS_WINDOWS Then
rc = W32_NSFDbOpen(Server & "!!" & FileName, hDb)
Else
rc = LINUX_NSFDbOpen(Server & "!!" & FileName, hDb)
End If
// clear replication history
If IS_WINDOWS Then
rc = W32_NSFDbClearReplHistory(hDb, 0)
Else
rc = LINUX_NSFDbClearReplHistory(hDb, 0)
End If
// close datababase (be sure you always close hDb if you opened it, otherwise memory leak).
If IS_WINDOWS Then
rc = W32_NSFDbClose(hDb)
Else
rc = LINUX_NSFDbClose(hDb)
End If
Be sure that you always close hDb handler if you opened the database, otherwise it would lead to memory leak)
See the full solution on GitHub: DominoReplicationHistoryCleaner
No comments :
Post a Comment