Refactored process proc queue service to handle more throughput. Fixed Metrology_Services import CDE qual service.
This commit is contained in:
@ -36,7 +36,7 @@ Function Environment_Services(@Service, @Params)
|
|||||||
|
|
||||||
#pragma precomp SRP_PreCompiler
|
#pragma precomp SRP_PreCompiler
|
||||||
|
|
||||||
$insert LOGICAL
|
$insert APP_INSERTS
|
||||||
$insert SERVICE_SETUP
|
$insert SERVICE_SETUP
|
||||||
$insert SRPMail_Inserts
|
$insert SRPMail_Inserts
|
||||||
|
|
||||||
@ -553,7 +553,20 @@ Service GetEnvironmentVariable(VariableName)
|
|||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
|
||||||
|
Service GetServiceManagerPort()
|
||||||
|
|
||||||
|
FilePath = Drive():'\SRPEngineServer.ini'
|
||||||
|
OSRead IniFile from FilePath then
|
||||||
|
CharIndex = Index(IniFile, 'Port', 1)
|
||||||
|
Line = IniFile[CharIndex, 'F':CRLF$]
|
||||||
|
Response = Trim(Line[-1, 'B='])
|
||||||
|
end
|
||||||
|
|
||||||
|
end service
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Internal GoSubs
|
// Internal GoSubs
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -1259,7 +1259,6 @@ end service
|
|||||||
Service ImportCDEQualData(RunData, ResourceID, PSN)
|
Service ImportCDEQualData(RunData, ResourceID, PSN)
|
||||||
|
|
||||||
Machine = 'CDE'
|
Machine = 'CDE'
|
||||||
ResourceID = Field(FileName, ' ', 1, 1)
|
|
||||||
URL = "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV3/":ResourceID:"/header"
|
URL = "https://oi-metrology-viewer-prod.mes.infineon.com/api/InfinityQSV3/":ResourceID:"/header"
|
||||||
TimeoutDuration = HTTPClient_Services('GetTimeoutDuration')
|
TimeoutDuration = HTTPClient_Services('GetTimeoutDuration')
|
||||||
If TimeoutDuration NE 30 then Httpclient_Services('SetTimeoutDuration', 30)
|
If TimeoutDuration NE 30 then Httpclient_Services('SetTimeoutDuration', 30)
|
||||||
@ -3273,3 +3272,4 @@ LoadRunDataToDatabase:
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
@ -300,18 +300,10 @@ return
|
|||||||
SendCommand:
|
SendCommand:
|
||||||
|
|
||||||
// Call the SRPEngineService and pass it the command
|
// Call the SRPEngineService and pass it the command
|
||||||
Server = Environment_Services('GetServer')
|
Server = Environment_Services('GetServer')
|
||||||
TCPServerSettings@ = Environment_Services('GetApplicationRootIP')
|
TCPServerSettings@ = Environment_Services('GetApplicationRootIP')
|
||||||
Convert '\\' to '' in TCPServerSettings@
|
Convert '\\' to '' in TCPServerSettings@
|
||||||
// Get the port from the SRPEngineServer.ini file instead.
|
TCPServerSettings@<2> = Environment_Services('GetServiceManagerPort')
|
||||||
FilePath = Drive():'\SRPEngineServer.ini'
|
|
||||||
OSRead IniFile from FilePath then
|
|
||||||
CharIndex = Index(IniFile, 'Port', 1)
|
|
||||||
Line = IniFile[CharIndex, 'F':CRLF$]
|
|
||||||
Port = Trim(Line[-1, 'B='])
|
|
||||||
TCPServerSettings@<2> = Port
|
|
||||||
end
|
|
||||||
|
|
||||||
TcpClientHandle = 0
|
TcpClientHandle = 0
|
||||||
If SRP_TcpClient(TcpClientHandle, 'CONNECT', TCPServerSettings@<1>, TCPServerSettings@<2>) then
|
If SRP_TcpClient(TcpClientHandle, 'CONNECT', TCPServerSettings@<1>, TCPServerSettings@<2>) then
|
||||||
SRP_TcpClient(TcpClientHandle, 'SEND_SES', Command)
|
SRP_TcpClient(TcpClientHandle, 'SEND_SES', Command)
|
||||||
|
@ -40,9 +40,10 @@ Equ Comma$ to ','
|
|||||||
Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@, Unused9@, Unused10@
|
Common /ServiceServices/ Unused1@, Unused2@, Unused3@, Unused4@, Unused5@, Unused6@, Unused7@, Unused8@, Unused9@, Unused10@
|
||||||
|
|
||||||
Declare function Service_Services, Memory_Services, SRP_List, SRP_FastArray, SRP_Array, Database_Services, Datetime
|
Declare function Service_Services, Memory_Services, SRP_List, SRP_FastArray, SRP_Array, Database_Services, Datetime
|
||||||
Declare function GetTickCount, SRP_Decode, RTI_CreateGuid, UCase, Environment_services, Logging_Services
|
Declare function GetTickCount, SRP_Decode, RTI_CreateGuid, UCase, Environment_services, Logging_Services,
|
||||||
|
Declare function SRP_TCPClient
|
||||||
Declare subroutine Service_Services, Memory_Services, SRP_List, SRP_FastArray, RList, Set_Status, Database_Services
|
Declare subroutine Service_Services, Memory_Services, SRP_List, SRP_FastArray, RList, Set_Status, Database_Services
|
||||||
Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract, Logging_Services, obj_Notes
|
Declare Subroutine Yield, WinYield, Sleepery, Btree.Extract, Logging_Services, obj_Notes, SRP_TCPClient
|
||||||
|
|
||||||
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ProcQueue'
|
LogPath = Environment_Services('GetApplicationRootPath') : '\LogFiles\ProcQueue'
|
||||||
LogDate = Oconv(Date(), 'D4/')
|
LogDate = Oconv(Date(), 'D4/')
|
||||||
@ -166,104 +167,145 @@ end service
|
|||||||
|
|
||||||
Service ProcessProcedureQueue()
|
Service ProcessProcedureQueue()
|
||||||
|
|
||||||
// Loop through the procedure queue until we can find a process request that is not yet locked
|
hSysLists = Database_Services('GetTableHandle', 'SYSLISTS')
|
||||||
// (i.e., already being crunched on by another engine). Process that one request and then end.
|
Lock hSysLists, ServiceKeyID then
|
||||||
Open 'PROC_QUEUE' to hProcQueue then
|
ServerIP = Environment_Services('GetApplicationRootIP')
|
||||||
Select hProcQueue
|
ServerPort = Environment_Services('GetServiceManagerPort')
|
||||||
EOF = False$
|
Convert '\' to '' in ServerIP
|
||||||
Done = False$
|
Open 'PROC_QUEUE' to hProcQueue then
|
||||||
Loop
|
Select hProcQueue
|
||||||
ReadNext RequestKeyID else EOF = True$
|
EOF = False$
|
||||||
Until EOF or Done
|
Loop
|
||||||
Lock hProcQueue, RequestKeyID then
|
ReadNext RequestKeyID else EOF = True$
|
||||||
DeleteRequest = True$
|
Until EOF
|
||||||
Server = Environment_Services('GetServer')
|
TcpClientHandle = 0
|
||||||
Done = True$
|
If SRP_TcpClient(TcpClientHandle, 'CONNECT', ServerIP, ServerPort) then
|
||||||
Database_Services('GetKeyIDLock', 'PROC_QUEUE', RequestKeyId)
|
Command = 'RUN SERVICE_SERVICES "ProcessRequest", ':Quote(RequestKeyID)
|
||||||
RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID)
|
SRP_TcpClient(TcpClientHandle, 'SEND_SES', Command)
|
||||||
If RequestRow NE '' then
|
SRP_TcpClient(TcpClientHandle, 'CLOSE_SES')
|
||||||
Procedure = RequestRow<PROC_QUEUE.PROC_NAME$>
|
|
||||||
Procedure = UCase(Procedure)
|
|
||||||
Params = RequestRow<PROC_QUEUE.PARAMS$>
|
|
||||||
If Procedure NE '' then
|
|
||||||
Dim ProcParams(12)
|
|
||||||
For each Param in Params using @VM setting pPos
|
|
||||||
ProcParams(pPos) = Param
|
|
||||||
Next Param
|
|
||||||
NumArguments = DCount(Params, @VM)
|
|
||||||
|
|
||||||
Begin Case
|
|
||||||
Case NumArguments EQ 0 ; Call @Procedure()
|
|
||||||
Case NumArguments EQ 1 ; Call @Procedure(ProcParams(1))
|
|
||||||
Case NumArguments EQ 2 ; Call @Procedure(ProcParams(1), ProcParams(2))
|
|
||||||
Case NumArguments EQ 3 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3))
|
|
||||||
Case NumArguments EQ 4 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4))
|
|
||||||
Case NumArguments EQ 5 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5))
|
|
||||||
Case NumArguments EQ 6 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6))
|
|
||||||
Case NumArguments EQ 7 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7))
|
|
||||||
Case NumArguments EQ 8 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8))
|
|
||||||
Case NumArguments EQ 9 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9))
|
|
||||||
Case NumArguments EQ 10 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9), ProcParams(10))
|
|
||||||
Case NumArguments EQ 11 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9), ProcParams(10), ProcParams(11))
|
|
||||||
Case Otherwise$
|
|
||||||
Error_Services('Add', 'Error in ':Service:' service. More than 11 arguments are not currently supported.')
|
|
||||||
End Case
|
|
||||||
end
|
|
||||||
|
|
||||||
Swap @VM with ',' in Params
|
|
||||||
LogData = LoggingDTM
|
|
||||||
LogData<2> = Server
|
|
||||||
LogData<3> = RequestKeyId
|
|
||||||
LogData<4> = Procedure
|
|
||||||
LogData<5> = Params
|
|
||||||
ErrCode = ''
|
|
||||||
If ( Get_Status(ErrCode) or Error_Services('HasError') ) then
|
|
||||||
NumAttempts = RequestRow<PROC_QUEUE.NUM_ATTEMPTS$> + 1
|
|
||||||
ErrorMessage = Error_Services('GetMessage')
|
|
||||||
If NumAttempts LT 3 then
|
|
||||||
DeleteRequest = False$
|
|
||||||
RequestRow<PROC_QUEUE.NUM_ATTEMPTS$> = NumAttempts
|
|
||||||
RequestRow<PROC_QUEUE.LAST_ATTEMPT_DTM$> = Datetime()
|
|
||||||
RequestRow<PROC_QUEUE.ERROR$> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode
|
|
||||||
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyId, RequestRow, True$, False$, False$)
|
|
||||||
end else
|
|
||||||
// Notify OI_SYSADMIN group
|
|
||||||
Recipients = ''
|
|
||||||
SentFrom = 'SYSTEM'
|
|
||||||
Subject = 'Background Procedure Queue Error'
|
|
||||||
Message = OConv(Datetime(), 'DT2/^H')
|
|
||||||
Message<2> = 'Error on server ':Server
|
|
||||||
Message<3> = 'Stored Procedure: ':Procedure
|
|
||||||
StatCodes = 'Parameters: ':Params
|
|
||||||
Message<4> = 'Error_Services error message: ':ErrorMessage
|
|
||||||
Message<5> = 'Get_Status error code: ':ErrCode
|
|
||||||
Swap @FM with \0D0A\ in Message
|
|
||||||
AttachWindow = ''
|
|
||||||
AttachKey = ''
|
|
||||||
SendToGroup = 'OI_SYSADMIN'
|
|
||||||
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
|
||||||
obj_Notes('Create',Parms)
|
|
||||||
|
|
||||||
// Move request to PROC_QUEUE_FAILED
|
|
||||||
RequestRow<PROC_QUEUE.NUM_ATTEMPTS$> = NumAttempts
|
|
||||||
RequestRow<PROC_QUEUE.LAST_ATTEMPT_DTM$> = Datetime()
|
|
||||||
RequestRow<PROC_QUEUE.ERROR$> = 'Error_Services error message: ':ErrorMessage:'Get_Status error code: ':ErrCode
|
|
||||||
Database_Services('WriteDataRow', 'PROC_QUEUE_FAILED', RequestKeyId, RequestRow, True$, False$, False$)
|
|
||||||
end
|
|
||||||
LogData<6> = 'Failed'
|
|
||||||
LogData<7> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode
|
|
||||||
end else
|
|
||||||
LogData<6> = 'Success'
|
|
||||||
end
|
|
||||||
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
|
||||||
end
|
|
||||||
If DeleteRequest then
|
|
||||||
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$)
|
|
||||||
end
|
end
|
||||||
Unlock hProcQueue, RequestKeyID else Null
|
Repeat
|
||||||
end
|
end
|
||||||
Repeat
|
Unlock hSysLists, ServiceKeyID else Null
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end service
|
||||||
|
|
||||||
|
|
||||||
|
Service ProcessRequest(RequestKeyID)
|
||||||
|
|
||||||
|
If RequestKeyID NE '' then
|
||||||
|
DeleteRequest = True$
|
||||||
|
Server = Environment_Services('GetServer')
|
||||||
|
Done = True$
|
||||||
|
If RowExists('PROC_QUEUE', RequestKeyID) then
|
||||||
|
RequestRow = Database_Services('ReadDataRow', 'PROC_QUEUE', RequestKeyID)
|
||||||
|
If RequestRow NE '' then
|
||||||
|
Procedure = RequestRow<PROC_QUEUE.PROC_NAME$>
|
||||||
|
Procedure = UCase(Procedure)
|
||||||
|
Params = RequestRow<PROC_QUEUE.PARAMS$>
|
||||||
|
If Procedure NE '' then
|
||||||
|
Dim ProcParams(12)
|
||||||
|
For each Param in Params using @VM setting pPos
|
||||||
|
ProcParams(pPos) = Param
|
||||||
|
Next Param
|
||||||
|
NumArguments = DCount(Params, @VM)
|
||||||
|
|
||||||
|
Begin Case
|
||||||
|
Case NumArguments EQ 0 ; Call @Procedure()
|
||||||
|
Case NumArguments EQ 1 ; Call @Procedure(ProcParams(1))
|
||||||
|
Case NumArguments EQ 2 ; Call @Procedure(ProcParams(1), ProcParams(2))
|
||||||
|
Case NumArguments EQ 3 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3))
|
||||||
|
Case NumArguments EQ 4 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4))
|
||||||
|
Case NumArguments EQ 5 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5))
|
||||||
|
Case NumArguments EQ 6 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6))
|
||||||
|
Case NumArguments EQ 7 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7))
|
||||||
|
Case NumArguments EQ 8 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8))
|
||||||
|
Case NumArguments EQ 9 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9))
|
||||||
|
Case NumArguments EQ 10 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9), ProcParams(10))
|
||||||
|
Case NumArguments EQ 11 ; Call @Procedure(ProcParams(1), ProcParams(2), ProcParams(3), ProcParams(4), ProcParams(5), ProcParams(6), ProcParams(7), ProcParams(8), ProcParams(9), ProcParams(10), ProcParams(11))
|
||||||
|
Case Otherwise$
|
||||||
|
Error_Services('Add', 'Error in ':Service:' service. More than 11 arguments are not currently supported.')
|
||||||
|
End Case
|
||||||
|
end
|
||||||
|
|
||||||
|
Swap @VM with ',' in Params
|
||||||
|
LogData = LoggingDTM
|
||||||
|
LogData<2> = Server
|
||||||
|
LogData<3> = RequestKeyId
|
||||||
|
LogData<4> = Procedure
|
||||||
|
LogData<5> = Params
|
||||||
|
ErrCode = ''
|
||||||
|
If ( Get_Status(ErrCode) or Error_Services('HasError') ) then
|
||||||
|
NumAttempts = RequestRow<PROC_QUEUE.NUM_ATTEMPTS$> + 1
|
||||||
|
ErrorMessage = Error_Services('GetMessage')
|
||||||
|
If NumAttempts LT 3 then
|
||||||
|
DeleteRequest = False$
|
||||||
|
RequestRow<PROC_QUEUE.NUM_ATTEMPTS$> = NumAttempts
|
||||||
|
RequestRow<PROC_QUEUE.LAST_ATTEMPT_DTM$> = Datetime()
|
||||||
|
RequestRow<PROC_QUEUE.ERROR$> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode
|
||||||
|
Database_Services('WriteDataRow', 'PROC_QUEUE', RequestKeyId, RequestRow, True$, False$, False$)
|
||||||
|
end else
|
||||||
|
// Notify OI_SYSADMIN group
|
||||||
|
Recipients = ''
|
||||||
|
SentFrom = 'SYSTEM'
|
||||||
|
Subject = 'Background Procedure Queue Error'
|
||||||
|
Message = OConv(Datetime(), 'DT2/^H')
|
||||||
|
Message<2> = 'Error on server ':Server
|
||||||
|
Message<3> = 'Stored Procedure: ':Procedure
|
||||||
|
StatCodes = 'Parameters: ':Params
|
||||||
|
Message<4> = 'Error_Services error message: ':ErrorMessage
|
||||||
|
Message<5> = 'Get_Status error code: ':ErrCode
|
||||||
|
Swap @FM with \0D0A\ in Message
|
||||||
|
AttachWindow = ''
|
||||||
|
AttachKey = ''
|
||||||
|
SendToGroup = 'OI_SYSADMIN'
|
||||||
|
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
||||||
|
obj_Notes('Create',Parms)
|
||||||
|
// Move request to PROC_QUEUE_FAILED
|
||||||
|
RequestRow<PROC_QUEUE.NUM_ATTEMPTS$> = NumAttempts
|
||||||
|
RequestRow<PROC_QUEUE.LAST_ATTEMPT_DTM$> = Datetime()
|
||||||
|
RequestRow<PROC_QUEUE.ERROR$> = 'Error_Services error message: ':ErrorMessage:'Get_Status error code: ':ErrCode
|
||||||
|
Database_Services('WriteDataRow', 'PROC_QUEUE_FAILED', RequestKeyId, RequestRow, True$, False$, False$)
|
||||||
|
end
|
||||||
|
LogData<6> = 'Failed'
|
||||||
|
LogData<7> = 'Error_Services error message: ':ErrorMessage:' Get_Status error code: ':ErrCode
|
||||||
|
end else
|
||||||
|
LogData<6> = 'Success'
|
||||||
|
end
|
||||||
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||||
|
end else
|
||||||
|
DeleteRequest = False$
|
||||||
|
// Failed to read request record.
|
||||||
|
ErrorMessage = Error_Services('GetMessage')
|
||||||
|
LogData = LoggingDTM
|
||||||
|
LogData<2> = Server
|
||||||
|
LogData<3> = RequestKeyId
|
||||||
|
LogData<4> = ''
|
||||||
|
LogData<5> = ''
|
||||||
|
LogData<6> = 'Failed'
|
||||||
|
LogData<7> = 'Failed to read request record. Error_Services error message: ':ErrorMessage
|
||||||
|
ErrCode = ''
|
||||||
|
Logging_Services('AppendLog', objLog, LogData, @RM, @FM)
|
||||||
|
// Notify OI_SYSADMIN group
|
||||||
|
Recipients = ''
|
||||||
|
SentFrom = 'SYSTEM'
|
||||||
|
Subject = 'Background Procedure Queue Error'
|
||||||
|
Message = OConv(Datetime(), 'DT2/^H')
|
||||||
|
Message<2> = 'Error on server ':Server
|
||||||
|
Message<3> = 'Failed to read request record. Error_Services error message: ':ErrorMessage
|
||||||
|
Swap @FM with \0D0A\ in Message
|
||||||
|
AttachWindow = ''
|
||||||
|
AttachKey = ''
|
||||||
|
SendToGroup = 'OI_SYSADMIN'
|
||||||
|
Parms = Recipients:@RM:SentFrom:@RM:Subject:@RM:Message:@RM:AttachWindow:@RM:AttachKey:@RM:SendToGroup
|
||||||
|
obj_Notes('Create',Parms)
|
||||||
|
end
|
||||||
|
If DeleteRequest then
|
||||||
|
Database_Services('DeleteDataRow', 'PROC_QUEUE', RequestKeyId, True$, False$)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end service
|
end service
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user