Ejemplo n.º 1
0
        public IJobSubmissionClient Create(IJobSubmissionClientCredential credentials)
        {
            var    asBasic        = credentials as BasicAuthCredential;
            var    asSubscription = credentials as JobSubmissionCertificateCredential;
            string clusterName    = string.Empty;

            if (asBasic != null)
            {
                clusterName = asBasic.Server.Host.Split('.').First();
            }
            else if (asSubscription != null)
            {
                clusterName = asSubscription.Cluster;
            }
            else
            {
                throw new NotSupportedException("Credential type :" + credentials.GetType().Name + ": is not supported");
            }

            string clusterUri = GatewayUriResolver.GetGatewayUri(clusterName).AbsoluteUri.ToUpperInvariant();

            if (!jobSubmissionClients.ContainsKey(clusterUri))
            {
                AzureHDInsightClusterManagementClientSimulator.SimulatorClusterContainer cluster =
                    AzureHDInsightClusterManagementClientSimulator.GetClusterInternal(clusterName);
                var jobClient = new AzureHDInsightJobSubmissionClientSimulator(credentials, cluster);
                jobSubmissionClients.Add(clusterUri, jobClient);
            }

            return(jobSubmissionClients[clusterUri]);
        }
        public IJobSubmissionClient Create(IJobSubmissionClientCredential credentials)
        {
            var asBasic = credentials as BasicAuthCredential;
            var asSubscription = credentials as JobSubmissionCertificateCredential;
            string clusterName = string.Empty;

            if (asBasic != null)
            {
                clusterName = asBasic.Server.Host.Split('.').First();
            }
            else if (asSubscription != null)
            {
                clusterName = asSubscription.Cluster;
            }
            else
            {
                throw new NotSupportedException("Credential type :" + credentials.GetType().Name + ": is not supported");
            }

            string clusterUri = GatewayUriResolver.GetGatewayUri(clusterName).AbsoluteUri.ToUpperInvariant();
            if (!jobSubmissionClients.ContainsKey(clusterUri))
            {
                AzureHDInsightClusterManagementClientSimulator.SimulatorClusterContainer cluster =
                    AzureHDInsightClusterManagementClientSimulator.GetClusterInternal(clusterName);
                var jobClient = new AzureHDInsightJobSubmissionClientSimulator(credentials, cluster);
                jobSubmissionClients.Add(clusterUri, jobClient);
            }

            return jobSubmissionClients[clusterUri];
        }