Ejemplo n.º 1
0
 /// <summary>
 /// Constructor for specifying a configuration options for a Pooled Task
 /// </summary>
 /// <param name="deployrEndpoint">URL indicating the DeployR endpoint (i.e  http://localhost/deployr )</param>
 /// <param name="userCredentials">RAuthentication object containing the user credentials</param>
 /// <param name="maxConcurrentTaskLimit">integer containing the maximum concurrent task limit</param>
 /// <remarks></remarks>
 public PooledBrokerConfig(String deployrEndpoint,
                           RAuthentication userCredentials,
                           int maxConcurrentTaskLimit)
     : base(deployrEndpoint, userCredentials, maxConcurrentTaskLimit)
 {
     m_poolCreationOptions = null;
 }
 /// <summary>
 /// Constructor for specifying a configuration options for a Pooled Task
 /// </summary>
 /// <param name="deployrEndpoint">URL indicating the DeployR endpoint (i.e  http://localhost/deployr )</param>
 /// <param name="userCredentials">RAuthentication object containing the user credentials</param>
 /// <param name="maxConcurrentTaskLimit">integer containing the maximum concurrent task limit</param>
 /// <remarks></remarks>
 public PooledBrokerConfig(String deployrEndpoint,
                           RAuthentication userCredentials,
                           int maxConcurrentTaskLimit)
     : base(deployrEndpoint, userCredentials, maxConcurrentTaskLimit)
 {
     m_poolCreationOptions = null;
 }
        public static ProjectExecutionOptions migrate(PoolCreationOptions poolOptions)
        {
            ProjectExecutionOptions options = null;

            if (poolOptions != null)
            {

                options = new ProjectExecutionOptions();

                /*
                 * PoolCreationOptions to ProjectExecutionOptions.
                 */

                options.rinputs = poolOptions.rinputs;

                if (poolOptions.preloadWorkspace != null)
                {

                    options.preloadWorkspace = new ProjectPreloadOptions();
                    options.preloadWorkspace.filename = poolOptions.preloadWorkspace.filename;
                    options.preloadWorkspace.directory = poolOptions.preloadWorkspace.directory;
                    options.preloadWorkspace.author =  poolOptions.preloadWorkspace.author;
                    options.preloadWorkspace.version =  poolOptions.preloadWorkspace.version;
                }

                if (poolOptions.preloadDirectory != null)
                {

                    options.preloadDirectory = new ProjectPreloadOptions();
                    options.preloadDirectory.filename = poolOptions.preloadDirectory.filename;
                    options.preloadDirectory.directory =  poolOptions.preloadDirectory.directory;
                    options.preloadDirectory.author =  poolOptions.preloadDirectory.author;
                    options.preloadDirectory.version = poolOptions.preloadDirectory.version;
                }

                options.preloadByDirectory = poolOptions.preloadByDirectory;
            }

            return options;
        }
        public static ProjectExecutionOptions migrate(PoolCreationOptions poolOptions)
        {
            ProjectExecutionOptions options = null;

            if (poolOptions != null)
            {
                options = new ProjectExecutionOptions();

                /*
                 * PoolCreationOptions to ProjectExecutionOptions.
                 */

                options.rinputs = poolOptions.rinputs;

                if (poolOptions.preloadWorkspace != null)
                {
                    options.preloadWorkspace           = new ProjectPreloadOptions();
                    options.preloadWorkspace.filename  = poolOptions.preloadWorkspace.filename;
                    options.preloadWorkspace.directory = poolOptions.preloadWorkspace.directory;
                    options.preloadWorkspace.author    = poolOptions.preloadWorkspace.author;
                    options.preloadWorkspace.version   = poolOptions.preloadWorkspace.version;
                }

                if (poolOptions.preloadDirectory != null)
                {
                    options.preloadDirectory           = new ProjectPreloadOptions();
                    options.preloadDirectory.filename  = poolOptions.preloadDirectory.filename;
                    options.preloadDirectory.directory = poolOptions.preloadDirectory.directory;
                    options.preloadDirectory.author    = poolOptions.preloadDirectory.author;
                    options.preloadDirectory.version   = poolOptions.preloadDirectory.version;
                }

                options.preloadByDirectory = poolOptions.preloadByDirectory;
            }

            return(options);
        }
        public static void Execute()
        {
            try
            {
                /*
                 * 1. Prepare PooledBrokerConfig instance.
                 *
                 * This example creates an authenticated PooledTaskBroker
                 * to act as our scoring engine.
                 *
                 * The following steps initialize the pool of
                 * R sessions dedicated to our scoring engine.
                 *
                 * In this example, we pre-initialize the workspace
                 * for each R session in the pool to contain the
                 * R model used when scoring customer requests.
                 *
                 * The R model, insurModel.rData, is loaded from
                 * the DeployR repository into each workspace at
                 * startup time. Preloading the R model at startup
                 * reduces runtime overhead and improves overall
                 * response times in the application.
                 */
                RAuthentication rAuth = new RBasicAuthentication(Program.AUTH_USER_NAME, Program.AUTH_PASSWORD);

                PoolCreationOptions poolOptions = new PoolCreationOptions();

                PoolPreloadOptions preloadOptions = new PoolPreloadOptions();
                preloadOptions.filename = Program.TUTORIAL_INSURANCE_MODEL;
                preloadOptions.directory = Program.TUTORIAL_REPO_DIRECTORY;
                preloadOptions.author = Program.TUTORIAL_REPO_OWNER;

                poolOptions.preloadWorkspace = preloadOptions;

                /*
                 * 2. Create RBroker instance.
                 *
                 * The application designer, in conjunction with the
                 * DeployR administrator who provisions and sets
                 * limits on DeployR grid resources, need to decide how
                 * many R sessions will be reserved for the PooledRBroker
                 * used by our scoring engine application.
                 */

                int TARGET_POOL_SIZE = 10;

                PooledBrokerConfig brokerConfig = new PooledBrokerConfig(Program.DEPLOYR_ENDPOINT,
                                                                           rAuth,
                                                                           TARGET_POOL_SIZE,
                                                                           poolOptions);

                Console.WriteLine("About to create pooledTaskBroker.");

                RBroker rBroker = RBrokerFactory.pooledTaskBroker(brokerConfig);

                Console.WriteLine("R session pool size, requested: " +
                        TARGET_POOL_SIZE + " , actual: " +
                        rBroker.maxConcurrency() + "\n");

                /*
                 * 3. Create an RTaskAppSimulator. It will drive
                 * sample customer data scoring requests through the
                 * RBroker.
                 */

                ScoringEngineSimulation simulation = new ScoringEngineSimulation(rBroker);

                /*
                 * 4. Launch RTaskAppSimulator simulation.
                 */

                rBroker.simulateApp(simulation);

                /*
                 * 5. Block until all tasks are complete, and shutdown has been called
                 */
                rBroker.waitUntilShutdown();

            }
            catch(Exception tex)
            {
                Console.WriteLine("constructor: ex=" + tex.ToString());
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor for specifying a configuration options for a Pooled Task
 /// </summary>
 /// <param name="deployrEndpoint">URL indicating the DeployR endpoint (i.e  http://localhost/deployr )</param>
 /// <param name="userCredentials">RAuthentication object containing the user credentials</param>
 /// <remarks></remarks>
 public PooledBrokerConfig(String deployrEndpoint,
                           RAuthentication userCredentials)
     : base(deployrEndpoint, userCredentials, 1)
 {
     m_poolCreationOptions = null;
 }
 /// <summary>
 /// Constructor for specifying a configuration options for a Pooled Task
 /// </summary>
 /// <param name="deployrEndpoint">URL indicating the DeployR endpoint (i.e  http://localhost/deployr )</param>
 /// <param name="userCredentials">RAuthentication object containing the user credentials</param>
 /// <remarks></remarks>
 public PooledBrokerConfig(String deployrEndpoint,
                          RAuthentication userCredentials)
     : base(deployrEndpoint, userCredentials, 1)
 {
     m_poolCreationOptions = null;
 }