private void saveMethodCall(MethodCallPO currentMethodCall, int currentIndex, int totalIndex) { //insertion bd //idparent(bd) = currentMethodCall.Parrent.Id; (null si premier) //select @@id pour recuperer identifiant et updater l'objet + setId String sCommandText = "INSERT INTO METHOD_CALL (INDEX_IN_FLOW, PARAMETERS, BEGIN_TIME, END_TIME, FULL_CLASS_NAME, METHOD_NAME, THROWABLE_CLASS_NAME, THROWABLE_MESSAGE, RESULT, GROUP_NAME, PARENT_INDEX_IN_FLOW, FLOW_ID, SUB_METH_INDEX) VALUES (@INDEX_IN_FLOW, @PARAMETERS, @BEGIN_TIME, @END_TIME, @FULL_CLASS_NAME, @METHOD_NAME, @THROWABLE_CLASS_NAME, @THROWABLE_MESSAGE, @RESULT, @GROUP_NAME, @PARENT_INDEX_IN_FLOW, @FLOW_ID, @SUB_METH_INDEX)"; // ;SELECT * FROM METHOD_CALL WHERE (INDEX_IN_FLOW = SCOPE_IDENTITY())"; IDbCommand cmd = _dao.CreateCommand(sCommandText, CommandType.Text); cmd.Transaction = _dao.CurrentTransaction; cmd.Parameters.Add(_dao.CreateParameter("@INDEX_IN_FLOW", totalIndex)); currentMethodCall.Id = totalIndex; cmd.Parameters.Add(_dao.CreateParameter("@PARAMETERS", currentMethodCall.Params.ToString())); cmd.Parameters.Add(_dao.CreateParameter("@BEGIN_TIME", currentMethodCall.BeginTime)); cmd.Parameters.Add(_dao.CreateParameter("@END_TIME", currentMethodCall.EndTime)); cmd.Parameters.Add(_dao.CreateParameter("@FULL_CLASS_NAME", currentMethodCall.ClassName)); cmd.Parameters.Add(_dao.CreateParameter("@METHOD_NAME", currentMethodCall.MethodName)); cmd.Parameters.Add(_dao.CreateParameter("@THROWABLE_CLASS_NAME", currentMethodCall.ThrowableClass)); cmd.Parameters.Add(_dao.CreateParameter("@THROWABLE_MESSAGE", currentMethodCall.ThrowableMessage)); cmd.Parameters.Add(_dao.CreateParameter("@RESULT", currentMethodCall.ReturnValue)); cmd.Parameters.Add(_dao.CreateParameter("@GROUP_NAME", currentMethodCall.GroupName)); //TODO FCH : Faire le test qui casse si on passe un mauvais ID if (currentMethodCall.Parent != null) cmd.Parameters.Add(_dao.CreateParameter("@PARENT_INDEX_IN_FLOW", currentMethodCall.Parent.Id)); else cmd.Parameters.Add(_dao.CreateParameter("@PARENT_INDEX_IN_FLOW", null)); //TODO FCH : Faire le test qui casse si on passe un mauvais ID cmd.Parameters.Add(_dao.CreateParameter("@FLOW_ID", currentMethodCall.Flow.Id)); cmd.Parameters.Add(_dao.CreateParameter("@SUB_METH_INDEX", currentIndex)); cmd.ExecuteNonQuery(); }
/** * * @param pParent The <code>MethodCallPO</code> from which we made the call to the current * <code>MethodCallPO</code>. * @param pClassName The name of the <code>Class</code> on which we call the statement associated with this * <code>MethodCallDTO</code>. * @param pMethodName The method name of the statement associated with this <code>MethodCallDTO</code>. * @param pGroupName The name of the group associated to this <code>MethodCallDTO</code>. * @param pParams The parameters passed to the method <code>pMethodName</code>. */ public MethodCallPO(MethodCallPO parent, String className, String methodName, String groupName, Object[] parameters) { if (parent != null) { // On chaine la hierachie parent.AddChildren(this); } mClassName = className; mMethodName = methodName; mBeginTime = Util.CurrentTimeMillis(); mParams = getParamsAsString(parameters, className, methodName); mGroupName = groupName; }
/// <summary> /// <param name="pThreadName">The name of the Thread of this flow</param> /// <param name="pFirstMeasure">First <code>MeasurePoint</code> of this flow.</param> /// <param name="pServerIdentifier">The identifier of this Server.</param> /// </summary> public ExecutionFlowPO(String threadName, MethodCallPO firstMeasure, String serverIdentifier) { this.threadName = threadName; this.serverIdentifier = serverIdentifier; this.firstMethodCall = firstMeasure; if (this.firstMethodCall != null) { this.beginTime = firstMethodCall.BeginTime; this.endTime = firstMethodCall.EndTime; this.firstMethodCall.SetFlowRecusivly(this); } }
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); }
/** * Define the return value of the method associated with this <code>MethodCallDTO</code> when it didn't throw a * <code>Throwable</code>. * * @param methodCall the current methodcall to manage. * @param returnValue The return value of the method. */ public static String EndMethod(MethodCallPO methodCall, Object returnValue) { if (methodCall == null) { throw new NMonitoringException("No methodCall to log"); } String returnValueAsString = null; methodCall.EndTime = Util.CurrentTimeMillis(); if (returnValue != null) { try { returnValueAsString = returnValue.ToString(); methodCall.ReturnValue = returnValueAsString; } catch (Exception externalException) { throw new NMonitoringException("Unable to trace return value of call.",externalException); } } return returnValueAsString; }
/** * @param pParent The mParent to set. */ private void SetParentMethodCall(MethodCallPO parent) { if (parent == null) { if (this.parent != null) { this.parent.mChildren.Remove(this); } } else { parent.mChildren.Add(this); } this.parent = parent; }
public void RemoveChildren(MethodCallPO child) { if (child != null) { mChildren.Remove(child); child.parent = null; } }
public void AddChildren(MethodCallPO child) { if (child != null) { mChildren.Add(child); child.parent = this; } }
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); } }
private int saveRecursMethodCall(MethodCallPO currentMethodCall, int currentIndex, int totalIndex) { int newTotalIndex = totalIndex; if (currentMethodCall != null) { newTotalIndex++; saveMethodCall(currentMethodCall, currentIndex, newTotalIndex); int currentLocalIndex = 0; foreach (MethodCallPO childMethodCall in currentMethodCall.Children) { newTotalIndex = saveRecursMethodCall(childMethodCall, currentLocalIndex, newTotalIndex); currentLocalIndex++; } } return newTotalIndex; }
/** * Define the <code>Throwable</code> thrown by the method associated with this <code>MethodCallDTO</code>. * * @param methodCall the current methodcall to manage. * @param exceptionClassName The name of the <code>Class</code> of the <code>Exception</code>. * @param exceptionMessage The message of the <code>Exception</code>. */ private static void EndMethodWithException(MethodCallPO methodCall, String exceptionClassName, String exceptionMessage) { methodCall.EndTime = Util.CurrentTimeMillis(); methodCall.ThrowableClass = exceptionClassName; methodCall.ThrowableMessage = exceptionMessage; }
/** * 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; } }
public void LogBeginOfMethod(string className, string operationName, Object [] args, String groupName) { if (currentLogPoint == null) { // Premier appel du Thread currentLogPoint = new MethodCallPO(null, className, operationName, groupName, args); } else { MethodCallPO tOldPoint = currentLogPoint; currentLogPoint = new MethodCallPO(tOldPoint, className, operationName, groupName, args); } }