/** * Prints {@link com.revo.deployr.client.broker.RTaskResult} * to console output. */ public static void printRTaskResult(RTask task, RTaskResult result, String error) { Console.WriteLine("\nTask: " + task); if(error != null) { Console.WriteLine("Status[fail]: cause=" + error); } else { switch(result.getType()) { case RTaskType.DISCRETE: if(result.isSuccess()) { Console.WriteLine("Status[ok]: [ code : " + result.getTimeOnCode() + " , server : " + result.getTimeOnServer() + " , call : " + result.getTimeOnCall() + " ]"); } else { Console.WriteLine("Status[fail]: cause=" + result.getFailure()); } break; case RTaskType.POOLED: if(result.isSuccess()) { Console.WriteLine("Status[ok]: [ code : " + result.getTimeOnCode() + " , server : " + result.getTimeOnServer() + " , call : " + result.getTimeOnCall() + " ]"); } else { Console.WriteLine("Status[fail]: cause=" + result.getFailure()); } break; case RTaskType.BACKGROUND: if(result.isSuccess()) { Console.WriteLine("Status[ok]: [ server : " + result.getTimeOnServer() + " , call : " + result.getTimeOnCall() + " ]"); } else { Console.WriteLine("Status[fail]: cause=" + result.getFailure()); } break; } } }
/** * Prints {@link com.revo.deployr.client.broker.RTaskResult} * to console output. */ public static void printRTaskResult(RTask task, RTaskResult result, String error) { Console.WriteLine("\nTask: " + task); if (error != null) { Console.WriteLine("Status[fail]: cause=" + error); } else { switch (result.getType()) { case RTaskType.DISCRETE: if (result.isSuccess()) { Console.WriteLine("Status[ok]: [ code : " + result.getTimeOnCode() + " , server : " + result.getTimeOnServer() + " , call : " + result.getTimeOnCall() + " ]"); } else { Console.WriteLine("Status[fail]: cause=" + result.getFailure()); } break; case RTaskType.POOLED: if (result.isSuccess()) { Console.WriteLine("Status[ok]: [ code : " + result.getTimeOnCode() + " , server : " + result.getTimeOnServer() + " , call : " + result.getTimeOnCall() + " ]"); } else { Console.WriteLine("Status[fail]: cause=" + result.getFailure()); } break; case RTaskType.BACKGROUND: if (result.isSuccess()) { Console.WriteLine("Status[ok]: [ server : " + result.getTimeOnServer() + " , call : " + result.getTimeOnCall() + " ]"); } else { Console.WriteLine("Status[fail]: cause=" + result.getFailure()); } break; } } }
public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { Console.WriteLine("DiscreteAsynchronous: onTaskCompleted: " + rTask.ToString() + ", result: " + rTaskResult.getTimeOnCall()); if (m_rBroker != null) { m_rBroker.shutdown(); Console.WriteLine("DiscreteAsynchronous: rBroker has been shutdown."); } }
/* * Updates RBrokerRuntimeStats for RBroker. */ private void updateBrokerStats(RTaskResult result) { Interlocked.Increment(ref m_totalTasksRunByBroker); if (result.isSuccess()) { Interlocked.Increment(ref m_totalTasksRunToSuccess); } Interlocked.Add(ref m_totalTaskTimeOnCode, result.getTimeOnCode()); Interlocked.Add(ref m_totalTaskTimeOnServer, result.getTimeOnServer()); Interlocked.Add(ref m_totalTaskTimeOnCall, result.getTimeOnCall()); }
/// <summary> /// Returns a resource token for the task back to the token pool. /// /// </summary> /// <param name="task">RTask submitted for execution as a background task</param> /// <param name="result">RTaskResult containing the results of the completed task</param> /// <remarks></remarks> public override void callback(RTask task, RTaskResult result) { Object obj; m_taskResourceTokenMap.TryGetValue(task, out obj); int resourceToken = (int)obj; Boolean added = m_resourceTokenPool.TryAdd(resourceToken); if(!added) { throw new Exception("BackgroundTaskBroker: callback, project could not be added back to pool, ???????."); } }
/// <summary> /// Returns a resource token for the task back to the token pool. /// /// </summary> /// <param name="task">RTask submitted for execution as a background task</param> /// <param name="result">RTaskResult containing the results of the completed task</param> /// <remarks></remarks> public override void callback(RTask task, RTaskResult result) { Object obj; m_taskResourceTokenMap.TryGetValue(task, out obj); int resourceToken = (int)obj; Boolean added = m_resourceTokenPool.TryAdd(resourceToken); if (!added) { throw new Exception("BackgroundTaskBroker: callback, project could not be added back to pool, ???????."); } }
/// <summary> /// RTaskResult object /// </summary> /// <returns>RTaskResult object</returns> /// <remarks></remarks> public RTaskResult getResult() { if (m_result != null) { return(m_result); } else { while (m_future == null) { try { Thread.Sleep(250); } catch (Exception iex) { throw iex; } } m_result = m_future.Result; return(m_result); } }
/* * RBrokerAsyncListener methods. */ public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { RBrokerStatsHelper.printRTaskResult(rTask, rTaskResult, null); }
static public void Execute() { RBroker rBroker = null; try { /* * 1. Create RBroker instance using RBrokerFactory. * * This example creates a DiscreteTaskBroker. */ DiscreteBrokerConfig brokerConfig = new DiscreteBrokerConfig(Program.DEPLOYR_ENDPOINT); rBroker = RBrokerFactory.discreteTaskBroker(brokerConfig); /* * 2. Define RTask * * This example creates a DiscreteTask that will * execute an R script, /testuser/tutorial-rbroker/5SecondNoOp. */ RTask rTask = RTaskFactory.discreteTask(Program.TUTORIAL_NOOP_SCRIPT, Program.TUTORIAL_REPO_DIRECTORY, Program.TUTORIAL_REPO_OWNER, "", null); /* * 3. Submit RTask to RBroker for execution. * * Note, unlike an RClient.executeScript call or * an RProject.executeScript call the RBroker.submit * call is non-blocking. * * The RTaskToken is returned immediately. You can * use the token to track the progress of RTask * and/or block while waiting for a result. */ RTaskToken rTaskToken = rBroker.submit(rTask); Console.WriteLine("DiscreteBlocking: submitted " + rTask + " for execution on RBroker."); /* * 4. Demonstrate blocking for an RTask result. * * The call to getResult() will either return * an RTaskResult or raise an Exception. An Exception * indicates the RTask failed to complete and why. */ RTaskResult rTaskResult = rTaskToken.getResult(); Console.WriteLine("DiscreteBlocking: " + rTask + " completed, result=" + rTaskResult.getTimeOnCall()); } catch (Exception tex) { Console.WriteLine("DiscreteBlocking: error=" + tex.ToString()); } finally { /* * Final Step: Shutdown RBroker to release * all associated resources, connections. */ if (rBroker != null) { rBroker.shutdown(); Console.WriteLine("DiscreteBlocking: rBroker has been shutdown."); } } }
public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { Console.WriteLine("DiscreteProfiling: onTaskCompleted: " + rTask + ", result: " + rTaskResult.getTimeOnCall()); RBrokerStatsHelper.printRTaskResult(rTask, rTaskResult, null); }
public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { Console.WriteLine("DiscreteProfiling: onTaskCompleted: " + rTask + ", result: " + rTaskResult.getTimeOnCall()); RBrokerStatsHelper.printRTaskResult(rTask, rTaskResult, null); }
/// <summary> /// Returns a resource token for the task back to the token pool. /// </summary> /// <param name="task">RTask submitted for execution as a background task</param> /// <param name="result">RTaskResult containing the results of the completed task</param> /// <remarks></remarks> public override void callback(RTask task, RTaskResult result) { Object obj; m_taskResourceTokenMap.TryGetValue(task, out obj); RProject rProject = (RProject)obj; /* * Check for Grid Exception */ Boolean bGridException = false; Exception failure = result.getFailure(); if (failure != null) { if (failure.GetType() == typeof(HTTPRestException)) { HTTPRestException ex = (HTTPRestException)failure; if (ex.errorCode >= 910 || ex.errorCode == 403) { bGridException = true; } } } if (bGridException == true) { /* * On detection of an RGridException drop the RProject from * the pool so further tasks are not directed to that RProject. * We achieve this by simply not adding the RProject back to the * resourceTokenPool on this callback. * * We then need to adjust the parallelTaskLimit so the RBroker * will report the new (smaller) pool size on * RBroker.maxConcurrency() calls. */ if (m_taskListener != null) { /* * When asynchronous listener in use, failed task * executions due to slot or grid failures can be * automatically resubmitted for execution by the RBroker. * * When RTaskResult.repeatTask is enabled the * RBrokerEngine.RBrokerListenerManager will skip * calling taskListener.onTaskCompleted(task, result). * This prevents a client application from seeing * (or having to handle) temporary slot or grid related * failures on RTasks. */ RTaskResultImpl resultImpl = (RTaskResultImpl)result; resultImpl.repeatTask = true; /* * Now re-submit for execution using the priority * queue to expedite processing. */ try { submit(task, true); } catch (Exception tex) { throw new Exception("PooledTaskBroker: callback, task re-submission ex=" + tex.ToString()); } } int resizedPoolSize = (int)Interlocked.Decrement(ref m_parallelTaskLimit); if (m_brokerListener != null) { Exception rbex; if (resizedPoolSize == 0) { rbex = new Exception("DeployR grid failure detected, pool no longer operational, advise RBroker shutdown."); } else { rbex = new Exception("DeployR grid failure detected, pool size auto-adjusted, max concurrency now " + resizedPoolSize + "."); } m_brokerListener.onRuntimeError(rbex.Message); } } else { if (rProject != null) { Boolean added = m_resourceTokenPool.TryAdd(rProject); if (!added) { throw new Exception("PooledTaskBroker: callback, project could not be added back to pool?"); } } else { throw new Exception("PooledTaskBroker: callback, task does not have matching project?"); } } }
/// <summary> /// Returns a resource token for the task back to the token pool. /// </summary> /// <param name="task">RTask submitted for execution as a background task</param> /// <param name="result">RTaskResult containing the results of the completed task</param> /// <remarks></remarks> public override void callback(RTask task, RTaskResult result) { Object obj; m_taskResourceTokenMap.TryGetValue(task, out obj); RProject rProject = (RProject)obj; /* * Check for Grid Exception */ Boolean bGridException = false; Exception failure = result.getFailure(); if (failure != null) { if (failure.GetType() == typeof(HTTPRestException)) { HTTPRestException ex = (HTTPRestException)failure; if (ex.errorCode >= 910 || ex.errorCode ==403) { bGridException = true; } } } if (bGridException == true) { /* * On detection of an RGridException drop the RProject from * the pool so further tasks are not directed to that RProject. * We achieve this by simply not adding the RProject back to the * resourceTokenPool on this callback. * * We then need to adjust the parallelTaskLimit so the RBroker * will report the new (smaller) pool size on * RBroker.maxConcurrency() calls. */ if (m_taskListener != null) { /* * When asynchronous listener in use, failed task * executions due to slot or grid failures can be * automatically resubmitted for execution by the RBroker. * * When RTaskResult.repeatTask is enabled the * RBrokerEngine.RBrokerListenerManager will skip * calling taskListener.onTaskCompleted(task, result). * This prevents a client application from seeing * (or having to handle) temporary slot or grid related * failures on RTasks. */ RTaskResultImpl resultImpl = (RTaskResultImpl)result; resultImpl.repeatTask = true; /* * Now re-submit for execution using the priority * queue to expedite processing. */ try { submit(task, true); } catch (Exception tex) { throw new Exception("PooledTaskBroker: callback, task re-submission ex=" + tex.ToString()); } } int resizedPoolSize = (int)Interlocked.Decrement(ref m_parallelTaskLimit); if (m_brokerListener != null) { Exception rbex; if (resizedPoolSize == 0) { rbex = new Exception("DeployR grid failure detected, pool no longer operational, advise RBroker shutdown."); } else { rbex = new Exception("DeployR grid failure detected, pool size auto-adjusted, max concurrency now " + resizedPoolSize + "."); } m_brokerListener.onRuntimeError(rbex.Message); } } else { if (rProject != null) { Boolean added = m_resourceTokenPool.TryAdd(rProject); if (!added) { throw new Exception("PooledTaskBroker: callback, project could not be added back to pool?"); } } else { throw new Exception("PooledTaskBroker: callback, task does not have matching project?"); } } }
private void RBrokerListenerManager() { while (Interlocked.Read(ref m_taskBrokerIsActive) == 1) { int tasksHandledOnLoop = 0; try { while (m_liveTaskTokens.Count() == 0 && Interlocked.Read(ref m_taskBrokerIsActive) == 1) { Thread.Sleep(LIVE_TASK_TOKEN_PEEK_INTERVAL); } foreach (RTaskToken rTaskToken in m_liveTaskTokens) { Boolean repeatTaskFound = false; if (rTaskToken.isDone()) { RTaskResult result = null; try { // Extract task result. result = (RTaskResult)rTaskToken.getResult(); if (m_taskListener != null) { if (((RTaskResultImpl)result).repeatTask) { repeatTaskFound = true; } else { try { m_taskListener.onTaskCompleted(rTaskToken.getTask(), result); } catch { /* * RBrokerEngine onTaskCompleted * is calling back into client * application code. That code * could erroneously throw an * Exception back into * RBrokerEngine. If so, swallow * it. */ } } } } catch (Exception ex) { if (m_taskListener != null) { m_taskListener.onTaskError(rTaskToken.getTask(), ex.ToString()); } } RTaskToken tempTaskToken = null; m_liveTaskTokens.TryTake(out tempTaskToken); if (!repeatTaskFound) { tasksHandledOnLoop++; updateBrokerStats(result); } } } } catch (Exception ex) { if (m_brokerListener != null) { m_brokerListener.onRuntimeError(ex.ToString()); } } if (tasksHandledOnLoop > 0) { if (m_brokerListener != null) { m_brokerListener.onRuntimeStats(buildStats(), (int)maxConcurrency()); } } } // while taskBrokerIsActive }
public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { Console.WriteLine("onTaskCompleted: " + rTask + ", result: " + rTaskResult); /* * Retrieve Job identifier from RTaskResult. */ String jobID = rTaskResult.getID(); Console.WriteLine("onTaskCompleted: " + rTask + ", background Job ID: " + jobID); if (m_rBroker != null) { /* * Important: * * To handle the results of a Background RTask you * must transition from using the RBroker Framework * API to using the .NET Client Library API. */ RUser rUser = m_rBroker.owner(); if (rUser != null) { try { RJob rJob = rUser.queryJob(jobID); Console.WriteLine("onTaskCompleted: " + rTask + ", rJob: " + rJob); /* * Next handle the result of the RJob as appropriate. * In this example, simly cancel and delete the job. */ try { rJob.cancel(); } catch (Exception cex) { Console.WriteLine("rJob.cancel ex=" + cex.ToString()); } try { rJob.delete(); } catch (Exception dex) { Console.WriteLine("rJob.delete ex=" + dex.ToString()); } } catch (Exception jex) { Console.WriteLine("rUser.queryJob ex=" + jex.ToString()); } } m_rBroker.shutdown(); Console.WriteLine("BackgroundBasics: rBroker has been shutdown."); } }
/// <summary> /// Callback for RBrokerWorker. Must be implemented by /// concrete implementation of RBrokerEngine. /// /// Responsible for adding an engineResourceToken /// back into the RBrokerEngine resourceTokenPool, /// making the token available for use by another /// RTask. /// </summary> /// <param name="task">RTask reference</param> /// <param name="result">RTaskResult reference</param> /// <remarks></remarks> public abstract void callback(RTask task, RTaskResult result);
/* * RBrokerAsyncListener methods. */ public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { RBrokerStatsHelper.printRTaskResult(rTask, rTaskResult, null); Console.WriteLine("onTaskCompleted: " + rTask + ", score " + ((RNumeric)rTaskResult.getGeneratedObjects()[0]).Value); }
public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { Console.WriteLine("DiscreteAsynchronous: onTaskCompleted: " + rTask.ToString() + ", result: " + rTaskResult.getTimeOnCall()); if (m_rBroker != null) { m_rBroker.shutdown(); Console.WriteLine("DiscreteAsynchronous: rBroker has been shutdown."); } }
/* * RBrokerAsyncListener methods. */ public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { RBrokerStatsHelper.printRTaskResult(rTask, rTaskResult, null); }
/// <summary> /// RTaskResult object /// </summary> /// <returns>RTaskResult object</returns> /// <remarks></remarks> public RTaskResult getResult() { if(m_result != null) { return m_result; } else { while(m_future == null) { try { Thread.Sleep(250); } catch(Exception iex) { throw iex; } } m_result = m_future.Result; return m_result; } }
/// <summary> /// Run the acutal background task using Job API /// </summary> /// <returns>Results of the background task</returns> /// <remarks></remarks> public RTaskResult call() { RTaskResult taskResult = null; RJob rJob = null; long timeOnCall = 0L; //long timeOnServer = 0L; try { long startTime = Environment.TickCount; JobExecutionOptions options = ROptionsTranslator.translate(m_task.options, m_isPriorityTask); if(m_task.code != "") { rJob = m_rUser.submitJobCode(m_task.name, m_task.description, m_task.code, options); } else { if(m_task.external != "") { rJob = m_rUser.submitJobExternal(m_task.external, m_task.description, m_task.code, options); } else { rJob = m_rUser.submitJobScript(m_task.name, m_task.description, m_task.filename, m_task.directory, m_task.author, m_task.version, options); } } timeOnCall = Environment.TickCount - startTime; taskResult = new RTaskResultImpl(rJob.about().id, RTaskType.BACKGROUND, true, 0L, 0L, timeOnCall, null); } catch (Exception ex) { //if(ex. instanceof InterruptedException) //{ try { /* * If RTaskToken.cancel() call raises InterruptedException * then ensure any corresponding scheduled RJob is * also cancelled. */ rJob.cancel(); } catch(Exception iex) { throw new Exception("RBroker: could not cancel job, cause: " + iex.ToString()); } //} taskResult = new RTaskResultImpl(null, RTaskType.BACKGROUND, false, 0L, 0L, 0L, ex); } finally { /* * Callback to PooledTaskBroker to release * RProject back into pool for other tasks. */ m_rBroker.callback(m_task, taskResult); } return taskResult; }
/// <summary> /// Run the acutal discrete task using Project API /// </summary> /// <returns>Results of the pooled task</returns> /// <remarks></remarks> public RTaskResult call() { RTaskResult taskResult = null; long timeOnCall = 0L; //long timeOnServer = 0L; try { ProjectExecutionOptions options = ROptionsTranslator.translate(m_task.options); long startTime = Environment.TickCount; RProjectExecution execResult = m_rProject.executeScript(m_task.filename, m_task.directory, m_task.author, m_task.version, options); timeOnCall = Environment.TickCount - startTime; String generatedConsole = execResult.about().console; List <String> generatedPlots = new List <String>(); if (execResult.about().results != null) { foreach (RProjectResult result in execResult.about().results) { generatedPlots.Add(result.about().url); } } List <String> generatedFiles = new List <String>(); if (execResult.about().artifacts != null) { foreach (RProjectFile artifact in execResult.about().artifacts) { generatedFiles.Add(artifact.about().url); } } List <RData> generatedObjects = execResult.about().workspaceObjects; List <String> storedFiles = new List <String>(); if (execResult.about().repositoryFiles != null) { foreach (RRepositoryFile repoFile in execResult.about().repositoryFiles) { storedFiles.Add(repoFile.about().url); } } taskResult = new RTaskResultImpl(execResult.about().id, RTaskType.POOLED, true, execResult.about().timeCode, execResult.about().timeTotal, timeOnCall, null, false, generatedConsole, generatedPlots, generatedFiles, generatedObjects, storedFiles); } catch (Exception ex) { //if(ex.getCause() instanceof InterruptedException) //{ try { /* * If RTaskToken.cancel() raises InterruptedException * then ensure any corresponding execution on RProject is * also cancelled. */ m_rProject.interruptExecution(); } catch (Exception iex) { throw new Exception("Project cancel Exception occurred: " + iex.ToString()); } //} taskResult = new RTaskResultImpl(null, RTaskType.POOLED, false, 0L, 0L, 0L, ex); } finally { /* * Callback to PooledTaskBroker to release * RProject back into pool for other tasks. */ m_rBroker.callback(m_task, taskResult); } return(taskResult); }
public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { Console.WriteLine("onTaskCompleted: " + rTask + ", result: " + rTaskResult); /* * Retrieve Job identifier from RTaskResult. */ String jobID = rTaskResult.getID(); Console.WriteLine("onTaskCompleted: " + rTask + ", background Job ID: " + jobID); if(m_rBroker != null) { /* * Important: * * To handle the results of a Background RTask you * must transition from using the RBroker Framework * API to using the .NET Client Library API. */ RUser rUser = m_rBroker.owner(); if(rUser != null) { try { RJob rJob = rUser.queryJob(jobID); Console.WriteLine("onTaskCompleted: " +rTask + ", rJob: " + rJob); /* * Next handle the result of the RJob as appropriate. * In this example, simly cancel and delete the job. */ try { rJob.cancel(); } catch(Exception cex) { Console.WriteLine("rJob.cancel ex=" + cex.ToString()); } try { rJob.delete(); } catch(Exception dex) { Console.WriteLine("rJob.delete ex=" + dex.ToString()); } } catch(Exception jex) { Console.WriteLine("rUser.queryJob ex=" + jex.ToString()); } } m_rBroker.shutdown(); Console.WriteLine("BackgroundBasics: rBroker has been shutdown."); } }
/// <summary> /// Run the acutal discrete task using Client API /// </summary> /// <returns>Results of the discrete task</returns> /// <remarks></remarks> public RTaskResult call() { RTaskResult taskResult = null; long timeOnCall = 0L; //long timeOnServer = 0L; try { AnonymousProjectExecutionOptions options = ROptionsTranslator.translate(m_task.options); long startTime = Environment.TickCount; RScriptExecution execResult = m_rClient.executeScript(m_task.filename, m_task.directory, m_task.author, m_task.version, options); timeOnCall = Environment.TickCount - startTime; String generatedConsole = execResult.about().console; List <String> generatedPlots = new List <String>(); if (execResult.about().results != null) { foreach (RProjectResult result in execResult.about().results) { generatedPlots.Add(result.about().url); } } List <String> generatedFiles = new List <String>(); if (execResult.about().artifacts != null) { foreach (RProjectFile artifact in execResult.about().artifacts) { generatedFiles.Add(artifact.about().url); } } List <RData> generatedObjects = execResult.about().workspaceObjects; List <String> storedFiles = new List <String>(); if (execResult.about().repositoryFiles != null) { foreach (RRepositoryFile repoFile in execResult.about().repositoryFiles) { storedFiles.Add(repoFile.about().url); } } taskResult = new RTaskResultImpl(execResult.about().id, RTaskType.DISCRETE, true, execResult.about().timeCode, execResult.about().timeTotal, timeOnCall, null, false, generatedConsole, generatedPlots, generatedFiles, generatedObjects, storedFiles); } catch (Exception ex) { //if(ex.getCause() == typeof(InterruptedException)) //{ /* * RTaskToken.cancel() can raise an InterruptedException. * When an InterruptedException is detected the DiscreteTask * executing on the server should be aborted at this point. * However, there is no way to obtain DeployR reference, such * as a projectId, for an stateless execution in-progress, so * aborting the current RTask operation is not possible. */ //} taskResult = new RTaskResultImpl(null, RTaskType.DISCRETE, false, 0L, 0L, 0L, ex); } finally { /* * Callback to PooledTaskBroker to release * RProject back into pool for other tasks. */ m_rBroker.callback(m_task, taskResult); } return(taskResult); }
/// <summary> /// Callback for RBrokerWorker. Must be implemented by /// concrete implementation of RBrokerEngine. /// /// Responsible for adding an engineResourceToken /// back into the RBrokerEngine resourceTokenPool, /// making the token available for use by another /// RTask. /// </summary> /// <param name="task">RTask reference</param> /// <param name="result">RTaskResult reference</param> /// <remarks></remarks> public abstract void callback(RTask task, RTaskResult result);
/* * Updates RBrokerRuntimeStats for RBroker. */ private void updateBrokerStats(RTaskResult result) { Interlocked.Increment(ref m_totalTasksRunByBroker); if(result.isSuccess()) { Interlocked.Increment(ref m_totalTasksRunToSuccess); } Interlocked.Add(ref m_totalTaskTimeOnCode, result.getTimeOnCode()); Interlocked.Add(ref m_totalTaskTimeOnServer, result.getTimeOnServer()); Interlocked.Add(ref m_totalTaskTimeOnCall, result.getTimeOnCall()); }
/* * RBrokerAsyncListener methods. */ public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { RBrokerStatsHelper.printRTaskResult(rTask, rTaskResult, null); Console.WriteLine("onTaskCompleted: " + rTask + ", score " + ((RNumeric)rTaskResult.getGeneratedObjects()[0]).Value); }