Example #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);
        }
Example #2
0
        static public void Cleanup(RUser rUser, RClient rClient)
        {
            //
            // Clenaup and logout when we are finished
            //
            if (rUser != null)
            {
                Console.WriteLine("User logged out: " + rUser.about().Username);

                rClient.logout(rUser);
            }
        }
        /// <summary>
        /// Implementation of RBroker Interface 'shutdown' method
        /// </summary>
        /// <remarks></remarks>
        public void shutdown()
        {
            Interlocked.Exchange(ref m_taskBrokerIsActive, 0);

            if (m_resourceTokenPool.Count > 0)
            {
                Boolean releaseGridResources = false;

                if (m_brokerConfig is PooledBrokerConfig)
                {
                    PooledBrokerConfig pbcfg = (PooledBrokerConfig)m_brokerConfig;
                    releaseGridResources = pbcfg.poolCreationOptions.releaseGridResources;
                }

                if (releaseGridResources)
                {
                    /*
                     * If PooledTaskBroker resource tokens
                     * and rUser available, perform a server-wide
                     * flush of projects on the grid.
                     */
                    m_rUser.releaseProjects();
                }
                else
                {
                    /*
                     * If PooledTaskBroker resource tokens
                     * and rUser not available, perform
                     * project-by-project flush on the grid.
                     */

                    foreach (Object resourceToken in m_resourceTokenPool)
                    {
                        try
                        {
                            if (resourceToken is RProject)
                            {
                                RProject projectToken = (RProject)resourceToken;
                                projectToken.close();
                            }
                        }
                        catch (Exception cex)
                        {
                            throw new Exception("RBroker: project close failed, cause: " + cex.ToString());
                        }
                    }
                }
            }

            if (m_rClient != null)
            {
                try
                {
                    if (m_rUser != null)
                    {
                        m_rClient.logout(m_rUser);
                    }
                }
                catch (Exception rex)
                {
                    throw new Exception("RBroker: RClient logout failed, cause: " + rex.ToString());
                }
            }
        }