EDMIService/Scheduler: Log timings and memory usage for jobs
This commit is contained in:
parent
5cb7891abf
commit
3d6a012bea
@ -20,6 +20,7 @@ Public Class DatatableJob
|
|||||||
Dim oCronJobTitle As String = oJobData.Item("CronJobTitle")
|
Dim oCronJobTitle As String = oJobData.Item("CronJobTitle")
|
||||||
Dim oLogger As Logger = oLogConfig.GetLogger()
|
Dim oLogger As Logger = oLogConfig.GetLogger()
|
||||||
|
|
||||||
|
Dim oStopWatch As New Stopwatch()
|
||||||
Dim oResult As New JobResult()
|
Dim oResult As New JobResult()
|
||||||
|
|
||||||
oLogger.Info("Running Datatable Job [{0}]/[{1}]", context.JobDetail.Key, oCronJobTitle)
|
oLogger.Info("Running Datatable Job [{0}]/[{1}]", context.JobDetail.Key, oCronJobTitle)
|
||||||
@ -43,12 +44,18 @@ Public Class DatatableJob
|
|||||||
oLogger.Debug("Datatable Name: {0}", oDatatableName)
|
oLogger.Debug("Datatable Name: {0}", oDatatableName)
|
||||||
oLogger.Debug("Connection Id: {0}", oConnectionId)
|
oLogger.Debug("Connection Id: {0}", oConnectionId)
|
||||||
|
|
||||||
|
oStopWatch.Start()
|
||||||
|
|
||||||
Dim oConnectionString = oMSSQL.Get_ConnectionStringforID(oConnectionId)
|
Dim oConnectionString = oMSSQL.Get_ConnectionStringforID(oConnectionId)
|
||||||
Dim oDecryptedConnectionString = MSSQLServer.DecryptConnectionString(oConnectionString)
|
Dim oDecryptedConnectionString = MSSQLServer.DecryptConnectionString(oConnectionString)
|
||||||
|
|
||||||
Dim oTable = oMSSQL.GetDatatableWithConnection(oSQL, oDecryptedConnectionString, COMMAND_SQL_TIMEOUT)
|
Dim oTable = oMSSQL.GetDatatableWithConnection(oSQL, oDecryptedConnectionString, COMMAND_SQL_TIMEOUT)
|
||||||
oTable.TableName = oDatatableName
|
oTable.TableName = oDatatableName
|
||||||
|
|
||||||
|
oStopWatch.Stop()
|
||||||
|
oLogger.Debug("[Time] Getting Data From DB: {0}ms", oStopWatch.ElapsedMilliseconds)
|
||||||
|
oStopWatch.Restart()
|
||||||
|
|
||||||
Dim oView As DataView = Nothing
|
Dim oView As DataView = Nothing
|
||||||
|
|
||||||
' This creates an Index for the columns specified in INDEX_COLUMNS to speed up calls to 'Table.Select'!
|
' This creates an Index for the columns specified in INDEX_COLUMNS to speed up calls to 'Table.Select'!
|
||||||
@ -59,6 +66,10 @@ Public Class DatatableJob
|
|||||||
}
|
}
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
oStopWatch.Stop()
|
||||||
|
oLogger.Debug("[Time] Creating Indexes: {0}ms", oStopWatch.ElapsedMilliseconds)
|
||||||
|
oStopWatch.Restart()
|
||||||
|
|
||||||
oLogger.Debug("Result Datatable [{0}] contains [{1}] rows", oTable.TableName, oTable.Rows.Count)
|
oLogger.Debug("Result Datatable [{0}] contains [{1}] rows", oTable.TableName, oTable.Rows.Count)
|
||||||
|
|
||||||
Dim oResultTable = New JobResult.ResultTable() With {
|
Dim oResultTable = New JobResult.ResultTable() With {
|
||||||
@ -81,6 +92,9 @@ Public Class DatatableJob
|
|||||||
oResultTable.TableRelationColumn = oParentColumn
|
oResultTable.TableRelationColumn = oParentColumn
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
oStopWatch.Stop()
|
||||||
|
oLogger.Debug("[Time] Adding Relations: {0}ms", oStopWatch.ElapsedMilliseconds)
|
||||||
|
|
||||||
oLogger.Info("Fetched Datatable [{0}]", oDatatableName)
|
oLogger.Info("Fetched Datatable [{0}]", oDatatableName)
|
||||||
oResult.Tables.Add(oResultTable)
|
oResult.Tables.Add(oResultTable)
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
|
|||||||
@ -164,13 +164,14 @@ Public Class JobListener
|
|||||||
|
|
||||||
Dim oName As String = Result.DetailRow.Item("DT_NAME")
|
Dim oName As String = Result.DetailRow.Item("DT_NAME")
|
||||||
Dim oDetailId As Integer = Result.DetailRow.Item("GUID")
|
Dim oDetailId As Integer = Result.DetailRow.Item("GUID")
|
||||||
Dim oDatatableNameTemp As String = oName & "-TEMP"
|
|
||||||
|
|
||||||
' Used for debugging relations and constraints
|
' Used for debugging relations and constraints
|
||||||
'_Logger.Debug("Dataset BEFORE saving datatables")
|
'_Logger.Debug("Dataset BEFORE saving datatables")
|
||||||
'ListTables(Dataset)
|
'ListTables(Dataset)
|
||||||
|
|
||||||
If Dataset.Tables.Contains(oName) Then
|
If Dataset.Tables.Contains(oName) Then
|
||||||
|
_Logger.Debug("Datatable [{0}] already exists, replacing.", oName)
|
||||||
|
|
||||||
' Replace existing table
|
' Replace existing table
|
||||||
If Result.ChildTable IsNot Nothing Then
|
If Result.ChildTable IsNot Nothing Then
|
||||||
ReplaceExistingTable(oName, oTable, Dataset, Result.ChildTable)
|
ReplaceExistingTable(oName, oTable, Dataset, Result.ChildTable)
|
||||||
@ -179,6 +180,8 @@ Public Class JobListener
|
|||||||
ReplaceExistingTable(oName, oTable, Dataset)
|
ReplaceExistingTable(oName, oTable, Dataset)
|
||||||
End If
|
End If
|
||||||
Else
|
Else
|
||||||
|
_Logger.Debug("Datatable [{0}] does not exist yet, adding.", oName)
|
||||||
|
|
||||||
AddNewTable(oName, oTable, Dataset)
|
AddNewTable(oName, oTable, Dataset)
|
||||||
|
|
||||||
If Result.ChildTable IsNot Nothing Then
|
If Result.ChildTable IsNot Nothing Then
|
||||||
@ -192,6 +195,11 @@ Public Class JobListener
|
|||||||
'_Logger.Debug("Dataset AFTER saving datatables")
|
'_Logger.Debug("Dataset AFTER saving datatables")
|
||||||
'ListTables(Dataset)
|
'ListTables(Dataset)
|
||||||
|
|
||||||
|
Dim oMemoryUsage = GC.GetTotalMemory(True)
|
||||||
|
Dim oUsageString = Utils.BytesToString(oMemoryUsage)
|
||||||
|
|
||||||
|
_Logger.Debug("Estimated memory usage after Job is [{0}]", oUsageString)
|
||||||
|
|
||||||
_MSSQL.ExecuteNonQuery($"INSERT INTO TBAPPSERV_CRON_DETAIL_HISTORY (DETAIL_ID) VALUES ({oDetailId})")
|
_MSSQL.ExecuteNonQuery($"INSERT INTO TBAPPSERV_CRON_DETAIL_HISTORY (DETAIL_ID) VALUES ({oDetailId})")
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Warn("Unexpected error in JobListener: {0}", ex.Message)
|
_Logger.Warn("Unexpected error in JobListener: {0}", ex.Message)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user