Beispiel #1
0
        static void Main(string[] args)
        {
            // 1. Establish a connection to DeployR.
            //
            // This example assumes the DeployR server is running on localhost.
            //
            String  deployrEndpoint = "http://localhost:7400/deployr";
            RClient rClient         = RClientFactory.createClient(deployrEndpoint);

            //
            // 2. Authenticate an end-user or client application.
            //
            // The RBasicAuthentication supports basic username/password authentication.
            // The RUser returned represents an authenticated end-user or application.
            //
            RAuthentication authToken = new RBasicAuthentication("testuser", "changeme");
            RUser           rUser     = rClient.login(authToken);

            //
            // 3. Logout the user
            //
            // The authenticated user is logged out from the DeployR server
            //
            rClient.logout(rUser);
        }
        /// <summary>
        /// Constructor for specifying a Discrete Instance of RBroker
        /// </summary>
        /// <param name="brokerConfig">Discrete Broker Configuration object</param>
        /// <remarks></remarks>
        public DiscreteTaskBroker(DiscreteBrokerConfig brokerConfig)
            : base((RBrokerConfig)brokerConfig)
        {
            m_rClient = RClientFactory.createClient(brokerConfig.deployrEndpoint, brokerConfig.maxConcurrentTaskLimit);

            if (brokerConfig.userCredentials != null)
            {
                m_rUser = m_rClient.login(brokerConfig.userCredentials);
            }
            else
            {
                m_rUser = null;
            }

            /*
             * Prep the base RBrokerEngine.
             */

            initEngine(brokerConfig.maxConcurrentTaskLimit);

            /*
             * Initialize the resourceTokenPool with Integer
             * based resourceTokens.
             */
            for (int i = 0; i < brokerConfig.maxConcurrentTaskLimit; i++)
            {
                m_resourceTokenPool.TryAdd(i);
            }
        }
 static void Main(string[] args)
 {
     //
     // 1. Establish a connection to DeployR.
     //
     // This example assumes the DeployR server is running on localhost.
     //
     String  deployrEndpoint = "http://localhost:7400/deployr";
     RClient rClient         = RClientFactory.createClient(deployrEndpoint);
 }
Beispiel #4
0
        static public RClient Connect()
        {
            //
            // Establish a connection to DeployR.
            //
            // This example assumes the DeployR server is running on localhost.
            //
            String  deployrEndpoint = "http://localhost:7400/deployr";
            RClient rClient         = RClientFactory.createClient(deployrEndpoint);

            //RClientFactory.setDebugMode(true); //un-comment if you want to have the API calls printed to the console

            Console.WriteLine("Client connection made to the DeployR Server: " + deployrEndpoint);

            return(rClient);
        }
        /// <summary>
        /// Constructor for specifying a Pooled Instance of RBroker
        /// </summary>
        /// <param name="brokerConfig">Pooled Broker Configuration object</param>
        /// <remarks></remarks>
        public PooledTaskBroker(PooledBrokerConfig brokerConfig)
            : base((RBrokerConfig)brokerConfig)
        {
            m_rClient = RClientFactory.createClient(brokerConfig.deployrEndpoint, brokerConfig.maxConcurrentTaskLimit);

            m_rUser = m_rClient.login(brokerConfig.userCredentials);

            if (brokerConfig.poolCreationOptions != null)
            {
                if (brokerConfig.poolCreationOptions.releaseGridResources == true)
                {
                    m_rUser.releaseProjects();
                }
            }

            ProjectCreationOptions options = ROptionsTranslator.translate(brokerConfig.poolCreationOptions);

            List <RProject> deployrProjectPool = m_rUser.createProjectPool(brokerConfig.maxConcurrentTaskLimit, options);

            /*
             * Prep the base RBrokerEngine.
             */

            initEngine(deployrProjectPool.Count());

            /*
             * Initialize the resourceTokenPool with RProject.
             */
            foreach (RProject rProject in deployrProjectPool)
            {
                m_resourceTokenPool.TryAdd(rProject);
            }

            try
            {
                Task.Factory.StartNew(() => HTTPKeepAliveManager(m_rUser));
            }
            catch (Exception rex)
            {
                shutdown();
                throw new Exception("Broker failed to start HTTP keep-alive manager, cause: " + rex.ToString());
            }
        }
Beispiel #6
0
        /// <summary>
        /// Constructor for specifying a Background Instance of RBroker
        /// </summary>
        /// <param name="brokerConfig">Background Broker Configuration object</param>
        /// <remarks></remarks>
        public BackgroundTaskBroker(BackgroundBrokerConfig brokerConfig)
            : base((RBrokerConfig)brokerConfig)
        {
            m_rClient = RClientFactory.createClient(brokerConfig.deployrEndpoint);

            m_rUser = m_rClient.login(brokerConfig.userCredentials);

            /*
             * Prep the base RBrokerEngine.
             */

            initEngine(PARALLEL_TASK_LIMIT);

            /*
             * Initialize the resourceTokenPool with Integer
             * based resourceTokens.
             */
            for (int i = 0; i < PARALLEL_TASK_LIMIT; i++)
            {
                m_resourceTokenPool.TryAdd(i);
            }
        }