/** * 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()); }
/* * 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()); }
public void onTaskCompleted(RTask rTask, RTaskResult rTaskResult) { Console.WriteLine("DiscreteProfiling: onTaskCompleted: " + rTask + ", result: " + rTaskResult.getTimeOnCall()); 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."); } } }