List of usage examples for java.lang Integer getInteger
public static Integer getInteger(String nm)
From source file:com.revo.deployr.rbroker.example.data.io.auth.discrete.task.RepoFileInGraphicsPlotOut.java
public RepoFileInGraphicsPlotOut() { RBroker rBroker = null;/* w w w . j a va 2s .c o m*/ try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); DiscreteBrokerConfig brokerConfig = new DiscreteBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ DiscreteBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.discreteTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "discrete broker [ RBroker ]."); /* * Create the DiscreteTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ DiscreteTaskOptions options = new DiscreteTaskOptions(); /* * Preload from the DeployR repository the following * data input file: * /testuser/example-data-io/hipStar.dat */ TaskPreloadOptions preloadWorkspace = new TaskPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; options.preloadWorkspace = preloadWorkspace; log.info("[ TASK INPUT ] Repository binary file input " + "set on task, [ DiscreteTaskOptions.preloadWorkspace ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.discreteTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Discrete task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.pooled.task.EncodedDataInBinaryFileOut.java
public EncodedDataInBinaryFileOut() { RBroker rBroker = null;/*w ww. ja va 2s. c o m*/ try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); PooledBrokerConfig brokerConfig = new PooledBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ PooledBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "pooled broker [ RBroker ]."); /* * Create the PooledTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PooledTaskOptions options = new PooledTaskOptions(); /* * Simulate application generated data. This data * is first encoded using the RDataFactory before * being passed as an input on the task. * * This encoded R input is automatically converted * into a workspace object before task execution. */ RData generatedData = DeployRUtil.simulateGeneratedData(log); if (generatedData != null) { List<RData> rinputs = Arrays.asList(generatedData); options.rinputs = rinputs; } log.info("[ TASK INPUT ] DeployR-encoded R input " + "set on task, [ PooledTaskOptions.rinputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.pooledTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Pooled task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.anon.discrete.task.MultipleDataInMultipleDataOut.java
public MultipleDataInMultipleDataOut() { RBroker rBroker = null;//from www . ja v a2 s . c o m try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ DiscreteBrokerConfig brokerConfig = new DiscreteBrokerConfig(endpoint, null, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ DiscreteBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.discreteTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established anonymous " + "discrete broker [ RBroker ]."); /* * Create the DiscreteTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ DiscreteTaskOptions options = new DiscreteTaskOptions(); /* * MultipleDataInMultipleDataOut Example Note: * * The inputs sent on this example are contrived * and superfluous as the hipStar.rData binary R * object input and the hipStarUrl input perform * the exact same purpose...to load the Hip STAR * dataset into the workspace ahead of execution. * * The example is provided to simply demonstrate * the mechanism of specifying multiple inputs. */ /* * Preload from the DeployR repository the following * binary R object input file: * /testuser/example-data-io/hipStar.rData * * As this is an anonymous operation "hipStar.rData" * must have it's repository-managed access controls * set to "public". */ TaskPreloadOptions preloadWorkspace = new TaskPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; options.preloadWorkspace = preloadWorkspace; log.info("[ DATA INPUT ] Repository binary file input " + "set on task, [ DiscreteTaskOptions.preloadWorkspace ]."); /* * Load an R object literal "hipStarUrl" into the * workspace prior to task execution. * * The R script checks for the existence of "hipStarUrl" * in the workspace and if present uses the URL path * to load the Hipparcos star dataset from the DAT file * at that location. */ RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL); List<RData> rinputs = Arrays.asList(hipStarUrl); options.rinputs = rinputs; log.info("[ DATA INPUT ] External data source input " + "set on task, [ DiscreteTaskOptions.rinputs ]."); /* * Request the retrieval of the "hip" data.frame and * two vector objects from the workspace following the * task execution. The corresponding R objects are named * as follows: * 'hip', hipDim', 'hipNames'. */ options.routputs = Arrays.asList("hip", "hipDim", "hipNames"); log.info("[ TASK OPTION ] DeployR-encoded R object request " + "set on task [ DiscreteTaskOptions.routputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.discreteTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Discrete task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.pooled.task.ExternalDataInDataFileOut.java
public ExternalDataInDataFileOut() { RBroker rBroker = null;// ww w. j ava 2 s .co m try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); PooledBrokerConfig brokerConfig = new PooledBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ PooledBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "pooled broker [ RBroker ]."); /* * Create the PooledTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PooledTaskOptions options = new PooledTaskOptions(); /* * Load an R object literal "hipStarUrl" into the * workspace prior to task execution. * * The R script checks for the existence of "hipStarUrl" * in the workspace and if present uses the URL path * to load the Hipparcos star dataset from the DAT file * at that location. */ RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL); List<RData> rinputs = Arrays.asList(hipStarUrl); options.rinputs = rinputs; log.info("[ TASK INPUT ] External data source input " + "set on task, [ PooledTaskOptions.rinputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.pooledTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Pooled task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.discrete.task.ExternalDataInDataFileOut.java
public ExternalDataInDataFileOut() { RBroker rBroker = null;/*ww w. j a v a 2 s .c o m*/ try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); DiscreteBrokerConfig brokerConfig = new DiscreteBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ DiscreteBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.discreteTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "discrete broker [ RBroker ]."); /* * Create the DiscreteTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ DiscreteTaskOptions options = new DiscreteTaskOptions(); /* * Load an R object literal "hipStarUrl" into the * workspace prior to task execution. * * The R script checks for the existence of "hipStarUrl" * in the workspace and if present uses the URL path * to load the Hipparcos star dataset from the DAT file * at that location. */ RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL); List<RData> rinputs = Arrays.asList(hipStarUrl); options.rinputs = rinputs; log.info("[ TASK INPUT ] External data source input " + "set on task, [ DiscreteTaskOptions.rinputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.discreteTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Discrete task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.pooled.task.RepoFileInRepoFileOut.java
public RepoFileInRepoFileOut() { try {//from w w w .j a va 2 s .co m /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); PooledBrokerConfig brokerConfig = new PooledBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ PooledBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "pooled broker [ RBroker ]."); /* * Create the PooledTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PooledTaskOptions options = new PooledTaskOptions(); /* * Preload from the DeployR repository the following * data input file: * /testuser/example-data-io/hipStar.dat */ TaskPreloadOptions preloadWorkspace = new TaskPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; options.preloadWorkspace = preloadWorkspace; log.info("[ TASK INPUT ] Repository binary file input " + "set on task, [ PooledTaskOptions.preloadWorkspace ]."); /* * Request repository storage of hip.csv file generated * by the dataIO.R script on task execution. * * Note, you can also use storageOptions.objects * to store individual objects from the workspace. */ TaskStorageOptions storageOptions = new TaskStorageOptions(); storageOptions.files = "hip.csv"; storageOptions.directory = "example-data-io"; options.storageOptions = storageOptions; log.info("[ TASK OPTION ] Repository storage request " + "set on task [ PooledTaskOptions.storageOptions ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.pooledTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Pooled task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.discrete.task.RepoFileInRepoFileOut.java
public RepoFileInRepoFileOut() { try {/*from w w w . j a v a 2 s .c om*/ /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); DiscreteBrokerConfig brokerConfig = new DiscreteBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ DiscreteBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.discreteTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "discrete broker [ RBroker ]."); /* * Create the DiscreteTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ DiscreteTaskOptions options = new DiscreteTaskOptions(); /* * Preload from the DeployR repository the following * data input file: * /testuser/example-data-io/hipStar.dat */ TaskPreloadOptions preloadWorkspace = new TaskPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; options.preloadWorkspace = preloadWorkspace; log.info("[ TASK INPUT ] Repository binary file input " + "set on task, [ DiscreteTaskOptions.preloadWorkspace ]."); /* * Request repository storage of hip.csv file generated * by the dataIO.R script on task execution. * * Note, you can also use storageOptions.objects * to store individual objects from the workspace. */ TaskStorageOptions storageOptions = new TaskStorageOptions(); storageOptions.files = "hip.csv"; storageOptions.directory = "example-data-io"; options.storageOptions = storageOptions; log.info("[ TASK OPTION ] Repository storage request " + "set on task [ DiscreteTaskOptions.storageOptions ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.discreteTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Discrete task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.pooled.task.RepoFileInEncodedDataOut.java
public RepoFileInEncodedDataOut() { RBroker rBroker = null;/*from w w w. j av a2 s . com*/ try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); PooledBrokerConfig brokerConfig = new PooledBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ PooledBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "pooled broker [ RBroker ]."); /* * Create the PooledTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ PooledTaskOptions options = new PooledTaskOptions(); /* * Preload from the DeployR repository the following * binary R object input file: * /testuser/example-data-io/hipStar.rData */ TaskPreloadOptions preloadWorkspace = new TaskPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; options.preloadWorkspace = preloadWorkspace; log.info("[ TASK INPUT ] Repository binary file input " + "set on task, [ PooledTaskOptions.preloadWorkspace ]."); /* * Request the retrieval of the "hip" data.frame and * two vector objects from the workspace following the * task execution. The corresponding R objects are named * as follows: * 'hip', hipDim', 'hipNames'. */ options.routputs = Arrays.asList("hip", "hipDim", "hipNames"); log.info("[ TASK OPTION ] DeployR-encoded R object request " + "set on task [ PooledTaskOptions.routputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.pooledTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Pooled task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.discrete.task.RepoFileInEncodedDataOut.java
public RepoFileInEncodedDataOut() { RBroker rBroker = null;/*ww w .j a v a2 s . c o m*/ try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); DiscreteBrokerConfig brokerConfig = new DiscreteBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ DiscreteBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.discreteTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "discrete broker [ RBroker ]."); /* * Create the DiscreteTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ DiscreteTaskOptions options = new DiscreteTaskOptions(); /* * Preload from the DeployR repository the following * binary R object input file: * /testuser/example-data-io/hipStar.rData */ TaskPreloadOptions preloadWorkspace = new TaskPreloadOptions(); preloadWorkspace.filename = "hipStar.rData"; preloadWorkspace.directory = "example-data-io"; preloadWorkspace.author = "testuser"; options.preloadWorkspace = preloadWorkspace; log.info("[ TASK INPUT ] Repository binary file input " + "set on task, [ DiscreteTaskOptions.preloadWorkspace ]."); /* * Request the retrieval of the "hip" data.frame and * two vector objects from the workspace following the * task execution. The corresponding R objects are named * as follows: * 'hip', hipDim', 'hipNames'. */ options.routputs = Arrays.asList("hip", "hipDim", "hipNames"); log.info("[ TASK OPTION ] DeployR-encoded R object request " + "set on task [ DiscreteTaskOptions.routputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.discreteTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Discrete task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }
From source file:com.revo.deployr.rbroker.example.data.io.auth.discrete.task.EncodedDataInBinaryFileOut.java
public EncodedDataInBinaryFileOut() { RBroker rBroker = null;//from w ww. j ava 2 s. c om try { /* * Determine DeployR server endpoint. */ String endpoint = System.getProperty("endpoint"); log.info("[ CONFIGURATION ] Using endpoint [ " + endpoint + " ]"); /* * Build configuration to initialize RBroker instance. */ RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"), System.getProperty("password")); DiscreteBrokerConfig brokerConfig = new DiscreteBrokerConfig(endpoint, rAuth, Integer.getInteger("example-max-concurrency")); log.info("[ CONFIGURATION ] Using broker config " + "[ DiscreteBrokerConfig ]"); /* * Establish RBroker connection to DeployR server. */ rBroker = RBrokerFactory.discreteTaskBroker(brokerConfig); /* * Register asynchronous listeners for task and * broker runtime events. */ rBroker.addTaskListener(this); rBroker.addBrokerListener(this); log.info("[ CONNECTION ] Established authenticated " + "discrete broker [ RBroker ]."); /* * Create the DiscreteTaskOptions object * to specify data inputs and output to the task. * * This options object can be used to pass standard * execution model parameters on execution calls. All * fields are optional. * * See the Standard Execution Model chapter in the * Client Library Tutorial on the DeployR website for * further details. */ DiscreteTaskOptions options = new DiscreteTaskOptions(); /* * Simulate application generated data. This data * is first encoded using the RDataFactory before * being passed as an input on the task execution. * * This encoded R input is automatically converted * into a workspace object before the task execution. */ RData generatedData = DeployRUtil.simulateGeneratedData(log); if (generatedData != null) { List<RData> rinputs = Arrays.asList(generatedData); options.rinputs = rinputs; } log.info("[ TASK INPUT ] DeployR-encoded R input " + "set on task, [ DiscreteTaskOptions.rinputs ]."); /* * Declare task for execution on broker based on * repository-managed R script: * /testuser/example-data-io/dataIO.R */ RTask rTask = RTaskFactory.discreteTask("dataIO.R", "example-data-io", "testuser", null, options); rBroker.submit(rTask); log.info("[ EXECUTION ] Discrete task " + "submitted to broker [ RTask ]."); /* * Simple block on main thread of this sample application * until example RTask execution completes. */ latch.await(); } catch (Exception ex) { log.warn("Unexpected error: ex=" + ex); } finally { /* * Clean-up after example completes. */ if (rBroker != null) { try { rBroker.shutdown(); } catch (Exception bex) { log.warn("RBroker.shutdown ex=" + bex); } } } }