Deprecating old services. Refactored codebase to not use SwapResources GoSub.
This commit is contained in:
@ -49,13 +49,6 @@ Options REQUEST_TYPE = 'status', 'average', 'count', 'status/bulk', 'average/bul
|
||||
// Services
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Service SendStatus(MonitorName=MONITORS, StatusName, CurrentState=STATES)
|
||||
|
||||
Mona_Services("PostStatus", MonitorName, StatusName, CurrentState)
|
||||
|
||||
end service
|
||||
|
||||
|
||||
Service PostStatus(MonitorName, StatusName, CurrentState=STATES)
|
||||
|
||||
MonaQId = RTI_CreateGuid()
|
||||
@ -69,13 +62,6 @@ Service PostStatus(MonitorName, StatusName, CurrentState=STATES)
|
||||
end service
|
||||
|
||||
|
||||
Service SendMetric(MonitorName=MONITORS, MetricName, Number)
|
||||
|
||||
Mona_Services("PostAverageMetric", MonitorName, MetricName, Number)
|
||||
|
||||
end Service
|
||||
|
||||
|
||||
Service PostAverageMetric(MonitorName, MetricName, Number)
|
||||
|
||||
MonaQId = RTI_CreateGuid()
|
||||
@ -90,13 +76,6 @@ Service PostAverageMetric(MonitorName, MetricName, Number)
|
||||
end service
|
||||
|
||||
|
||||
Service SendCountMetric(MonitorName=MONITORS, MetricName, Number)
|
||||
|
||||
Mona_Services("PostCountMetric", MonitorName, MetricName, Number)
|
||||
|
||||
end Service
|
||||
|
||||
|
||||
Service PostCountMetric(MonitorName, MetricName, Number)
|
||||
|
||||
MonaQId = RTI_CreateGuid()
|
||||
@ -111,185 +90,11 @@ Service PostCountMetric(MonitorName, MetricName, Number)
|
||||
end service
|
||||
|
||||
|
||||
Service SendBufferedStatus(MonaResource, StatusName, StatusValue)
|
||||
|
||||
If MonaResource EQ '' then
|
||||
MonaResource = Environment_Services("GetMonaResource")
|
||||
end
|
||||
|
||||
Prod = Environment_Services('IsProd')
|
||||
If Not(Prod) then GoSub SwapResourceNames
|
||||
|
||||
DateTime = SRP_DateTime('Now')
|
||||
Year = SRP_Datetime("Year", DateTime)
|
||||
Month = SRP_Datetime("Month", DateTime)
|
||||
If Len(Month) EQ 1 then
|
||||
Month = '0':Month
|
||||
end
|
||||
Day = SRP_Datetime("Day", DateTime)
|
||||
If Len(Day) EQ 1 then
|
||||
Day = '0':Day
|
||||
end
|
||||
Hour = SRP_Datetime("Hour", DateTime)
|
||||
If Len(Hour) EQ 1 then
|
||||
Hour = '0':Hour
|
||||
end
|
||||
Minute = SRP_Datetime("Minute", DateTime)
|
||||
If Len(Minute) EQ 1 then
|
||||
Minute = '0':Minute
|
||||
end
|
||||
Second = SRP_Datetime("Second", DateTime)
|
||||
If Len(Second) EQ 1 then
|
||||
Second = '0':Second
|
||||
end
|
||||
|
||||
RequestBodyJson = '{ "resource": "':MonaResource:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "dateTime": "':Year:'-':Month:'-':Day:'T':Hour:':':Minute:':':Second:'Z"'
|
||||
RequestBodyJson = RequestBodyJson:', "statusName": "':StatusName:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "statusValue": "':StatusValue:'" }'
|
||||
|
||||
ApiUrl = Environment_Services("GetMonInBufferedWorkerApiUrl"):'/status'
|
||||
|
||||
retries = 3
|
||||
backoffSeconds = 1
|
||||
isSuccessful = False$
|
||||
|
||||
Loop
|
||||
while (isSuccessful EQ False$ and retries GT 0)
|
||||
waitSeconds = (3 - retries) * backoffSeconds
|
||||
Delay(waitSeconds)
|
||||
|
||||
retries = retries - 1
|
||||
|
||||
response = Httpclient_Services('SendHTTPRequest', 'POST', ApiUrl, 'Content-Type':@VM:'application/json':@FM:'Accept':@VM:'*/*', RequestBodyJson, '', '', False$, False$, '')
|
||||
|
||||
If response EQ '"Request queued for processing"' then
|
||||
isSuccessful = True$
|
||||
end
|
||||
Repeat
|
||||
|
||||
end service
|
||||
|
||||
|
||||
Service SendBufferedAverageMetric(MonaResource, MetricName, MetricValue)
|
||||
|
||||
If MonaResource EQ '' then
|
||||
MonaResource = Environment_Services("GetMonaResource")
|
||||
end
|
||||
|
||||
DateTime = SRP_DateTime('Now')
|
||||
Year = SRP_Datetime("Year", DateTime)
|
||||
Month = SRP_Datetime("Month", DateTime)
|
||||
If Len(Month) EQ 1 then
|
||||
Month = '0':Month
|
||||
end
|
||||
Day = SRP_Datetime("Day", DateTime)
|
||||
If Len(Day) EQ 1 then
|
||||
Day = '0':Day
|
||||
end
|
||||
Hour = SRP_Datetime("Hour", DateTime)
|
||||
If Len(Hour) EQ 1 then
|
||||
Hour = '0':Hour
|
||||
end
|
||||
Minute = SRP_Datetime("Minute", DateTime)
|
||||
If Len(Minute) EQ 1 then
|
||||
Minute = '0':Minute
|
||||
end
|
||||
Second = SRP_Datetime("Second", DateTime)
|
||||
If Len(Second) EQ 1 then
|
||||
Second = '0':Second
|
||||
end
|
||||
|
||||
RequestBodyJson = '{ "resource": "':MonaResource:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "dateTime": "':Year:'-':Month:'-':Day:'T':Hour:':':Minute:':':Second:'Z"'
|
||||
RequestBodyJson = RequestBodyJson:', "metricName": "':MetricName:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "metricValue": "':MetricValue:'" }'
|
||||
|
||||
ApiUrl = Environment_Services("GetMonInBufferedWorkerApiUrl"):'/average'
|
||||
|
||||
retries = 3
|
||||
backoffSeconds = 1
|
||||
isSuccessful = False$
|
||||
|
||||
Loop
|
||||
while (isSuccessful EQ False$ and retries GT 0)
|
||||
waitSeconds = (3 - retries) * backoffSeconds
|
||||
Delay(waitSeconds)
|
||||
|
||||
retries = retries - 1
|
||||
|
||||
response = Httpclient_Services('SendHTTPRequest', 'POST', ApiUrl, 'Content-Type':@VM:'application/json':@FM:'Accept':@VM:'*/*', RequestBodyJson, '', '', False$, False$, '')
|
||||
|
||||
If response EQ '"Request queued for processing"' then
|
||||
isSuccessful = True$
|
||||
end
|
||||
Repeat
|
||||
|
||||
end service
|
||||
|
||||
|
||||
Service SendBufferedCountMetric(MonaResource, MetricName, MetricValue)
|
||||
|
||||
If MonaResource EQ '' then
|
||||
MonaResource = Environment_Services("GetMonaResource")
|
||||
end
|
||||
|
||||
DateTime = SRP_DateTime('Now')
|
||||
Year = SRP_Datetime("Year", DateTime)
|
||||
Month = SRP_Datetime("Month", DateTime)
|
||||
If Len(Month) EQ 1 then
|
||||
Month = '0':Month
|
||||
end
|
||||
Day = SRP_Datetime("Day", DateTime)
|
||||
If Len(Day) EQ 1 then
|
||||
Day = '0':Day
|
||||
end
|
||||
Hour = SRP_Datetime("Hour", DateTime)
|
||||
If Len(Hour) EQ 1 then
|
||||
Hour = '0':Hour
|
||||
end
|
||||
Minute = SRP_Datetime("Minute", DateTime)
|
||||
If Len(Minute) EQ 1 then
|
||||
Minute = '0':Minute
|
||||
end
|
||||
Second = SRP_Datetime("Second", DateTime)
|
||||
If Len(Second) EQ 1 then
|
||||
Second = '0':Second
|
||||
end
|
||||
|
||||
RequestBodyJson = '{ "resource": "':MonaResource:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "dateTime": "':Year:'-':Month:'-':Day:'T':Hour:':':Minute:':':Second:'Z"'
|
||||
RequestBodyJson = RequestBodyJson:', "metricName": "':MetricName:'"'
|
||||
RequestBodyJson = RequestBodyJson:', "metricValue": "':MetricValue:'" }'
|
||||
|
||||
ApiUrl = Environment_Services("GetMonInBufferedWorkerApiUrl"):'/count'
|
||||
|
||||
retries = 3
|
||||
backoffSeconds = 1
|
||||
isSuccessful = False$
|
||||
|
||||
Loop
|
||||
while (isSuccessful EQ False$ and retries GT 0)
|
||||
waitSeconds = (3 - retries) * backoffSeconds
|
||||
Delay(waitSeconds)
|
||||
|
||||
retries = retries - 1
|
||||
|
||||
response = Httpclient_Services('SendHTTPRequest', 'POST', ApiUrl, 'Content-Type':@VM:'application/json':@FM:'Accept':@VM:'*/*', RequestBodyJson, '', '', False$, False$, '')
|
||||
|
||||
If response EQ '"Request queued for processing"' then
|
||||
isSuccessful = True$
|
||||
end
|
||||
Repeat
|
||||
|
||||
end service
|
||||
|
||||
|
||||
Service QueueLatencyAndCountMetrics(MonaResource, MetricName, StartTick, EndTick)
|
||||
|
||||
Diff = EndTick - StartTick
|
||||
Mona_Services('SendMetric', MonaResource, MetricName:'_LATENCY', Diff)
|
||||
Mona_Services('SendCountMetric', MonaResource, MetricName:'_COUNT', 1)
|
||||
Mona_Services('PostAverageMetric', MonaResource, MetricName:'_LATENCY', Diff)
|
||||
Mona_Services('PostCountMetric', MonaResource, MetricName:'_COUNT', 1)
|
||||
|
||||
end service
|
||||
|
||||
@ -769,29 +574,6 @@ end service
|
||||
// Internal GoSubs
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
SwapResourceNames:
|
||||
|
||||
// Swap out prod resource name with dev resource name
|
||||
Begin Case
|
||||
Case ( (MonaResource EQ 'GRP_OPENINSIGHT_MES_OP_FE_SAP_OUTBOUND') and (StatusName EQ 'SFTP-Interface-Outbound') )
|
||||
MonaResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_SAP_OUTBOUND'
|
||||
StatusName = 'SFTP-Interface-Outbound-Dev'
|
||||
|
||||
Case ( (MonaResource EQ 'GRP_OPENINSIGHT_MES_OP_FE_SAP_INBOUND') and (StatusName EQ 'SetSAPBatchQueue') )
|
||||
MonaResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_SAP_INBOUND'
|
||||
StatusName = 'SetSAPBatchQueue-Dev'
|
||||
|
||||
Case ( (MonaResource EQ 'GRP_OPENINSIGHT_MES_OP_FE_SAP_INBOUND') and (StatusName EQ 'SFTP-Interface-Inbound') )
|
||||
MonaResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_SAP_INBOUND'
|
||||
StatusName = 'SFTP-Interface-Inbound-Dev'
|
||||
|
||||
Case (MonaResource EQ 'GRP_OPENINSIGHT_MES_OP_FE_NICAINTEGRATIONSERVICE')
|
||||
MonaResource = 'GRP_OPENINSIGHT_MES_OP_FE_DEV_NICAINTEGRATIONSERVICE_DEV'
|
||||
End Case
|
||||
|
||||
return
|
||||
|
||||
|
||||
ClearCursors:
|
||||
|
||||
For counter = 0 to 8
|
||||
|
Reference in New Issue
Block a user