Opening a database by replica id with failover - possible at all?
While opening a database using LotusScript using failover is simple, opening the same database using the replica id (also with failover) doesn't seem so... The goals and premises of the below snippets are:
- I would like to open a database, with failover, using the replica id
- I know the database is normally available on server1/Example
- I do not know which other servers are in cluster with server1/Example
Normally opening a database is as simple as:
Dim db As New NotesDatabase("server1/Example", "mail\dadminis.nsf")
If db.IsOpen Then
Msgbox "Database at " + db.Server + "!!" + db.FilePath + " is open..."
Else
Msgbox "Couldn't open database..."
End If
After replacing one line of code the snippet becomes cluster aware and fails over beautifully to server2/Example if server1/Example is down.
Dim db As New NotesDatabase("", "")
Call db.OpenWithFailover("server1/Example", "mail\dadminis.nsf")
If db.IsOpen Then
Msgbox "Database at " + db.Server + "!!" + db.FilePath + " is open..."
Else
Msgbox "Couldn't open database..."
End If
Moving along I would like this code to work with a replica id instead of a filename. The obvious choice was to try and open the database using the replica id on server1/Example (which would be down), grab the filename and then open the found filename on server1/Example - now using failover.
Dim exists_in_cluster As Boolean
Dim db As New NotesDatabase("", "")
Call db.OpenByReplicaID("server1/Example", "C125711B0076CBF4")
If Not db.IsOpen Then
'try opening with failover
exists_in_cluster = db.OpenWithFailover(db.Server, db.Filepath)
End If
If exists_in_cluster Then
Msgbox "Database at " + db.Server + "!!" + db.FilePath + " is open..."
Else
Msgbox "Couldn't open database..."
End If
As you might expect this doesn't work. The database filename isn't available (after line 3) since the code has no way of translating the replica id to a filename (server1/Example is down - remember).
Another option would be to try and use the NotesDbDirectory class.
Dim dbdir As New NotesDbDirectory("server1/Example")
Dim db As NotesDatabase
Dim path As String
Dim next_db As Boolean
next_db = True
Set db = dbdir.GetFirstDatabase(DATABASE)
While Not (db Is Nothing) And next_db
If db.ReplicaID = "C125711B0076CBF4" Then
path = db.FilePath
next_db = False
Else
Set db = dbdir.GetNextDatabase()
End If
Wend
'try and open the database on server1
Call db.Open("", "")
If Not db.IsOpen Then
'try and open with failover in cluster
Set db = New NotesDatabase("", "")
Call db.OpenWithFailOver("server1/Example", path)
End If
If db.IsOpen Then
Msgbox "Database at " + db.Server + "!!" + db.FilePath + " is open..."
Else
Msgbox "Couldn't open database..."
End If
This doesn't work either because server1/Example is down hence I'm unable to get a directory listing from the server.
So... What is a LotusScript programmer to do? I could give in and use the Domino Cluster Directory to find the filename for a replica id and then go directly to opening the database using failover. I would however really like to avoid using the Cluster Directory which in my book is a system database which is best left alone. Another option is to use the catalog.nsf to do the same thing.
What really bothers me is that the Domino server and/or the Notes client must already have the functionality since it is used when failing the client over. Why not expose it?
Technorati tag(s): LotusScript, Lotus Notes



