Dim WshShell, fso, oExec, oRun, oCosmiHome, oRecover, oCjsleep
Set WshShell = CreateObject("WScript.Shell")
oCosmiHome = WshShell.ExpandEnvironmentStrings("%COSMINEXUS_HOME%")
oRecover = """" & oCosmiHome & "¥CC¥server¥bin¥cjstartrecover"""
oCjsleep = """" & oCosmiHome & "¥CC¥server¥bin¥cjsleep"""
'==== Open ====
Function Open( )
Resource.LogInformation "======== Entering Open. ========"
' --- J2EE Server Name ---
If Resource.PropertyExists("ServerName") = False Then
Resource.LogInformation "### Private property ServerName is not set. ###"
End If
' --- Inprocess OTS Status Path ---
If Resource.PropertyExists("StatusPath") = False Then
Resource.LogInformation "### Private property StatusPath is not set. ###"
End If
' --- Cluster IP Address ---
If Resource.PropertyExists("IPAddress") = False Then
Resource.LogInformation "### Private property IPAddress is not set. ###"
End If
' --- Cluster Host Name ---
If Resource.PropertyExists("HostName") = False Then
Resource.LogInformation "### Private property HostName is not set. ###"
End If
Open = True
End Function
'==== Online ====
Function Online( )
Resource.LogInformation "======== Entering Online. ========"
RecoverSuccess = 0
'--- private properties ---
If Resource.PropertyExists("ServerName") = False Or _
Resource.PropertyExists("StatusPath") = False Or _
Resource.PropertyExists("IPAddress") = False Or _
Resource.PropertyExists("HostName") = False Then
Resource.LogInformation "### Private property is not set. ###"
Online = False
Exit Function
End If
' --- A parameters of recover command ---
Dir_Name = "C:¥MSCS¥RecoverExclusive"
Sleep_Time = 60
Retries = 30
Set fso = CreateObject("Scripting.FileSystemObject")
oRun = oRecover & " " & Resource.ServerName _
& " -p vbroker.se.iiop_tp.host=" & Resource.IPAddress _
& " -p ejbserver.distributedtx.ots.status.directory1=" & Resource.StatusPath _
& " -t 600"
On Error Resume Next
For i=0 To Retries
Err.Clear
fso.CreateFolder(Dir_Name)
If Err.Number = 0 Then
'--- cjstartrecover ---
Resource.LogInformation "[" & Resource.HostName & "]--- cjstartrecover start... ---"
Resource.LogInformation "[" & Resource.HostName & "]" & oRun
Set oResult = WshShell.Run(oRun, 0, True)
If oResult <> 0 Then
Resource.LogInformation "[" & Resource.HostName & _
"]### cjstartrecover command is failed. ### rtn=" & oResult
End If
fso.DeleteFolder(Dir_Name)
RecoverSuccess = 1
Resource.LogInformation "[" & Resource.HostName & "]--- The revover command finished. ---"
Exit For
Else
Resource.LogInformation "[" & Resource.HostName & "]CreateFolder()=" & Err.Number & " " & Err.Description
Resource.LogInformation "[" & Resource.HostName & "]" & oCjsleep & " " & Sleep_Time & " retry=" & i
WshShell.Run oCjsleep & " " & Sleep_Time, 0, True
End If
Next
On Error Goto 0
If RecoverSuccess = 0 Then
Resource.LogInformation "[" & Resource.HostName & "]### Timeout occurred before starting cjstartrecover. ###"
Resource.LogInformation "[" & Resource.HostName & "]### Perform following command manually. ###"
Resource.LogInformation "[" & Resource.HostName & "]" & oRun
Online = False
Exit Function
End If
WshShell.Run "cluster res " & Resource.Name & " /off", 0, False
Online = True
End Function
'==== LooksAlive ====
Function LooksAlive( )
Resource.LogInformation "======== Entering LooksAlive. ========"
LooksAlive = True
End Function
'==== IsAlive ====
Function IsAlive( )
Resource.LogInformation "======== Entering IsAlive. ========"
IsAlive = True
End Function
'==== Offline ====
Function Offline( )
Resource.LogInformation "======== Entering Offline. ========"
Offline = True
End Function
'==== Close ====
Function Close( )
Resource.LogInformation "======== Entering Close. ========"
Close = True
End Function
'==== Terminate ====
Function Terminate( )
Resource.LogInformation "======== Entering Terminate. ========"
Terminate = True
End Function |