private void saveExecutionFlow(ExecutionFlowPO executionFlow) { if (executionFlow != null) { //insertion bd (sans 1st methodCall (existe pas) String sCommandText = "INSERT INTO EXECUTION_FLOW(THREAD_NAME, JVM, BEGIN_TIME, END_TIME, BEGIN_TIME_AS_DATE, DURATION) VALUES(@THREAD_NAME, @JVM, @BEGIN_TIME, @END_TIME, @BEGIN_DATE, @DURATION);"; sCommandText += _dao.IdentityRequest; IDbCommand cmd = _dao.CreateCommand(sCommandText, CommandType.Text); cmd.Transaction = _dao.CurrentTransaction; cmd.Parameters.Add(_dao.CreateParameter("@THREAD_NAME", executionFlow.ThreadName)); cmd.Parameters.Add(_dao.CreateParameter("@JVM", executionFlow.ServerIdentifier)); cmd.Parameters.Add(_dao.CreateParameter("@BEGIN_TIME", executionFlow.BeginTime)); cmd.Parameters.Add(_dao.CreateParameter("@END_TIME", executionFlow.EndTime)); cmd.Parameters.Add(_dao.CreateParameter("@BEGIN_DATE", Util.TimeMillisToDate(executionFlow.BeginTime))); cmd.Parameters.Add(_dao.CreateParameter("@DURATION", executionFlow.Duration)); //cmd.Parameters.Add(_dao.CreateParameter("@FIRST_METHOD_CALL_ID", null)); //TODO FCH : Faire le test qui casse si on enleve cette ligne object tobject = cmd.ExecuteScalar(); executionFlow.Id = Convert.ToInt32(tobject); } }
public void InsertFullExecutionFlow(ExecutionFlowPO executionFlow) { _dao.Connection.Open(); IDbTransaction trans = _dao.BeginTransaction(); try { saveExecutionFlow(executionFlow); MethodCallPO tFirstMeth = executionFlow.FirstMethodCall; int totalIndex = saveRecursMethodCall(tFirstMeth, 0, 0); //relier le executionflaw avec le 1st method call SetFirstMethodCall(executionFlow, tFirstMeth); trans.Commit(); } catch (Exception externalException) { trans.Rollback(); throw new NMonitoringException("Unable to write Execution Flow",externalException); } finally { _dao.Connection.Close(); } }
public void insertExecutionFlowWithNoMethodCallPO() { ExecutionFlowPO flow= new ExecutionFlowPO("TEST-main", null, "myCLR"); IExecutionFlowWriter dao = new ExecutionFlowDao(); int nbMethodsCallBeforeDao = UtilTest.CountMethods(); dao.InsertFullExecutionFlow(flow); Thread.Sleep(SLEEP_DURATION_FOR_ASYNC_WRITE); int nbMethodsCallAfterDao = UtilTest.CountMethods(); UtilTest.DeleteAllData(); Assert.AreEqual(nbMethodsCallAfterDao, nbMethodsCallBeforeDao); }
public void WriteExecutionFlow(ExecutionFlowPO executionFlow) { try { IExecutionFlowWriter ExecutionflowWriter = Factory<IExecutionFlowWriter>.Instance.GetNewObject(); ExecutionflowWriter.InsertFullExecutionFlow(executionFlow); } catch (Exception internalException) { throw new NMonitoringException("AsynchroneDBWriter::AsynchroneWrite UNABLE TO STORE Flow", internalException); } }
public void WriteExecutionFlow(ExecutionFlowPO executionFlow) { //TODO FCH : Parametrer le nombre de thread //Let the old IOC parameters as they were. int unUsed, minIOC, maxIOC; ThreadPool.GetMinThreads(out unUsed, out minIOC); ThreadPool.GetMaxThreads(out unUsed, out maxIOC); ThreadPool.SetMinThreads(1, minIOC); ThreadPool.SetMaxThreads(1, maxIOC); // Use only 1 thread ThreadPool.QueueUserWorkItem(new WaitCallback(AsynchroneWrite), executionFlow); }
public void insertExecutionFlowWithOneMethodCallPOUsingConstructor() { long tStartTime = Util.CurrentTimeMillis(); MethodCallPO point= new MethodCallPO(null, "TestExecutionFlowDAO", "builNewFlow", "GrDefault", new ParameterInfo[0]); point.BeginTime = tStartTime; point.EndTime = tStartTime + 2; ExecutionFlowPO flow = new ExecutionFlowPO("TEST-main", point, "myCLR"); IExecutionFlowWriter dao = new ExecutionFlowDao(); int nbMethodsCallBeforeDao = UtilTest.CountMethods(); dao.InsertFullExecutionFlow(flow); Thread.Sleep(SLEEP_DURATION_FOR_ASYNC_WRITE); int nbMethodsCallAfterDao = UtilTest.CountMethods(); int nbExpextedMethodsCall = 1; UtilTest.DeleteAllData(); Assert.AreEqual(nbExpextedMethodsCall,nbMethodsCallAfterDao - nbMethodsCallBeforeDao); }
public void SetFlowRecusivly(ExecutionFlowPO flowPO) { mFlow = flowPO; MethodCallPO curMeth; foreach (Object it in mChildren) { curMeth = (MethodCallPO)it; curMeth.SetFlowRecusivly(flowPO); } }
private void SetFirstMethodCall(ExecutionFlowPO executionFlow, MethodCallPO firstMethodCall) { if ((executionFlow != null) && (firstMethodCall != null)) { //updater le lien de pExecution Flow vers son fils (il est nul jusque la) String sCommandText = @"UPDATE EXECUTION_FLOW SET FIRST_METHOD_CALL_INDEX_IN_FLOW = @FIRST_METHOD_CALL_INDEX_IN_FLOW WHERE ((ID = @FLOW_ID))"; IDbCommand cmd = _dao.CreateCommand(sCommandText, CommandType.Text); cmd.Transaction = _dao.CurrentTransaction; cmd.Parameters.Add(_dao.CreateParameter("@FLOW_ID", executionFlow.Id)); //TODO FCH : Faire le test qui casse si on passe un mauvais ID cmd.Parameters.Add(_dao.CreateParameter("@FIRST_METHOD_CALL_INDEX_IN_FLOW", firstMethodCall.Id)); cmd.ExecuteNonQuery(); if (cmd.ExecuteNonQuery() != 1) throw new NMonitoringException("The count of updated rows is not equal to 1 flow id = "+executionFlow.Id); } }
/** * Trace the <code>Exception</code> thrown during its execution. * * @param exception The <code>Exception</code> to trace. */ public void LogEndOfMethodWithException(Exception exception) { string externalExceptionMessage = ""; if (exception == null) { // On ne logue pas le détail EndMethodWithException(currentLogPoint, null, null); } else { externalExceptionMessage = exception.Message; EndMethodWithException(currentLogPoint, exception.GetType().FullName, externalExceptionMessage); } if (currentLogPoint.Parent == null) { // Dernier appel du Thread //String threadName = System.Threading.Thread.CurrentThread.ManagedThreadId.ToString(); String threadName = Thread.CurrentThread.GetHashCode().ToString(); if (Thread.CurrentThread.Name != null) threadName += " (" + Thread.CurrentThread.Name + ")"; ExecutionFlowPO tFlow = new ExecutionFlowPO(threadName, currentLogPoint, ConfigurationManager.getServerName()); storeWriter.WriteExecutionFlow(tFlow); currentLogPoint = null; } else { currentLogPoint = currentLogPoint.Parent; } }
/** * Trace the result of a method ended normally. * * @param result The result of the execution of the method. */ public void LogEndOfMethodNormal(Object result) { // To limit call to toString on business object, that could be expensive String tResultAsString = EndMethod(currentLogPoint, result); if (currentLogPoint.Parent == null) { // Dernier appel du Thread String threadName = Thread.CurrentThread.GetHashCode().ToString(); String threadName2 = Thread.CurrentThread.GetHashCode().ToString(CultureInfo.CurrentCulture.NumberFormat); if (Thread.CurrentThread.Name != null) threadName += " (" + Thread.CurrentThread.Name + ")"; ExecutionFlowPO tFlow = new ExecutionFlowPO(threadName, currentLogPoint, ConfigurationManager.getServerName()); storeWriter.WriteExecutionFlow(tFlow); currentLogPoint = null; } else { currentLogPoint = currentLogPoint.Parent; } }