Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the HpcSchedulerAdapterClient class
        /// </summary>
        /// <param name="headnode">indicating the headnode</param>
        /// <param name="instanceContext">indicating the instance context</param>
        public HpcSchedulerAdapterClient(string headnode, string certThrumbprint, InstanceContext instanceContext)
            : base(
                instanceContext,
                BindingHelper.HardCodedInternalSchedulerDelegationBinding,
                SoaHelper.CreateInternalCertEndpointAddress(new Uri(SoaHelper.GetSchedulerDelegationAddress(headnode)), certThrumbprint))
        {
            BrokerTracing.TraceVerbose("[HpcSchedulerAdapterClient] In constructor");
            this.ClientCredentials.UseInternalAuthentication(certThrumbprint);
            if (BrokerIdentity.IsHAMode)
            {
                // Bug 10301 : Explicitly open channel when impersonating the resource group's account if running on failover cluster so identity flows correctly when
                //      calling HpcSession.
                //  NOTE: The patch we got from the WCF team (KB981001) only works when the caller is on a threadpool thread.
                //  NOTE: Channel must be opened before setting OperationTimeout
                using (BrokerIdentity identity = new BrokerIdentity())
                {
                    identity.Impersonate();
                    this.Open();
                }
            }

            this.InnerChannel.OperationTimeout = SchedulerAdapterTimeout;

            foreach (OperationDescription op in this.Endpoint.Contract.Operations)
            {
                DataContractSerializerOperationBehavior dataContractBehavior = op.Behaviors.Find <DataContractSerializerOperationBehavior>() as DataContractSerializerOperationBehavior;
                if (dataContractBehavior != null)
                {
                    dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
                }
            }
        }
        /// <summary>
        /// Create client
        /// </summary>
        private async Task CreateClient()
        {
            BrokerTracing.TraceVerbose(
                "[SchedulerAdapterClientFactory] Creating client with StartInfo.IpAddress: {0}, StartInfo.EprList: {1}, WithoutSessionLayer: {2}",
                this.sharedData.StartInfo.IpAddress != null,
                this.sharedData.StartInfo.EprList != null,
                SoaCommonConfig.WithoutSessionLayer);

            if (SoaCommonConfig.WithoutSessionLayer)
            {
                this.schedulerAdapterClient = new DummySchedulerAdapterClient(this.sharedData.StartInfo.IpAddress, this.dispatcherManager);
            }
            else
            {
                // TODO: implementing new authentication logic between brokerworker and sessionlauncher

                string headnodeMachine = await this.context.ResolveSessionLauncherNodeAsync();

                // certThrumbprint = await this.context.GetSSLThumbprint();


                // if (this.monitor.TransportScheme == TransportScheme.AzureStorage)
                // {
                //     this.schedulerAdapterClient = new SchedulerAdapterClient(
                //         new TableTransportBinding() { ConnectionString = this.monitor.SharedData.BrokerInfo.AzureStorageConnectionString, TargetPartitionKey = Guid.NewGuid().ToString() },
                //         new EndpointAddress(new Uri(TelepathyConstants.SessionSchedulerDelegationAzureTableBindingAddress)),
                //         this.sharedData.StartInfo.IpAddress,
                //         this.dispatcherManager);
                // }
                // else
                // {
                // this.schedulerAdapterClient = new HpcSchedulerAdapterClient(headnodeMachine, certThrumbprint, new System.ServiceModel.InstanceContext(this.monitor));
                this.schedulerAdapterClient = new SchedulerAdapterClient(
                    BindingHelper.HardCodedUnSecureNetTcpBinding,
                    new EndpointAddress(new Uri(SoaHelper.GetSchedulerDelegationAddress(headnodeMachine))),
                    this.sharedData.StartInfo.IpAddress,
                    this.dispatcherManager,
                    new System.ServiceModel.InstanceContext(this.monitor));
                // }
            }
        }
Exemple #3
0
        /// <summary>
        /// Start scheduler delegation service
        /// </summary>
        private void StartSchedulerDelegationService()
        {
            string schedulerDelegationAddress = SoaHelper.GetSchedulerDelegationAddress("localhost");

            this.delegationHost = new ServiceHost(this.schedulerDelegation, new Uri(schedulerDelegationAddress));
            BindingHelper.ApplyDefaultThrottlingBehavior(this.delegationHost);
#if HPCPACK
            if (this.schedulerDelegation is IHpcSchedulerAdapterInternal)
            {
                this.delegationHost.AddServiceEndpoint(typeof(IHpcSchedulerAdapterInternal), BindingHelper.HardCodedInternalSchedulerDelegationBinding, "Internal");
                this.delegationHost.AddServiceEndpoint(typeof(IHpcSchedulerAdapter), BindingHelper.HardCodedInternalSchedulerDelegationBinding, string.Empty);
                this.delegationHost.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerOrChainTrust;
                this.delegationHost.Credentials.ClientCertificate.Authentication.RevocationMode            = X509RevocationMode.NoCheck;
                this.delegationHost.Credentials.ServiceCertificate.SetCertificate(
                    StoreLocation.LocalMachine,
                    StoreName.My,
                    X509FindType.FindByThumbprint,
                    TelepathyContext.Get().GetSSLThumbprint().GetAwaiter().GetResult());
            }
            else
#endif
            {
                // Use insecure binding until unified authentication logic is implemented
                this.delegationHost.AddServiceEndpoint(typeof(ISchedulerAdapter), BindingHelper.HardCodedUnSecureNetTcpBinding, string.Empty);
                // if (SessionLauncherRuntimeConfiguration.OpenAzureStorageListener)
                // {
                //     this.delegationHost.AddServiceEndpoint(
                //         typeof(ISchedulerAdapter),
                //         new TableTransportBinding() { ConnectionString = SessionLauncherRuntimeConfiguration.SessionLauncherStorageConnectionString, TargetPartitionKey = "all" },
                //         TelepathyConstants.SessionSchedulerDelegationAzureTableBindingAddress);
                // }
            }

            this.delegationHost.Faulted += SchedulerDelegationHostFaultHandler;
            this.delegationHost.Open();
            TraceHelper.TraceEvent(TraceEventType.Information, "Open scheduler delegation service at {0}", schedulerDelegationAddress);
        }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the SchedulerHelper class
 /// </summary>
 public SchedulerHelper(ITelepathyContext context)
 {
     this.context         = context;
     this.sessionNode     = new Lazy <string>(() => this.ResolveSessionNodeWithRetries().GetAwaiter().GetResult(), LazyThreadSafetyMode.ExecutionAndPublication);
     this.certThumbprint  = new Lazy <string>(() => this.context.GetSSLThumbprint().GetAwaiter().GetResult(), LazyThreadSafetyMode.ExecutionAndPublication);
     this.schedulerClient = new Lazy <SchedulerAdapterClient>(
         () => new SchedulerAdapterClient(BindingHelper.HardCodedUnSecureNetTcpBinding, new EndpointAddress(SoaHelper.GetSchedulerDelegationAddress(this.sessionNode.Value)), new InstanceContext(new TraceOnlyServiceJobMonitor())),
         LazyThreadSafetyMode.ExecutionAndPublication);
     this.sessionLauncherClient = new Lazy <SessionLauncherClient>(
         () => new SessionLauncherClient(this.sessionNode.Value, this.certThumbprint.Value),
         LazyThreadSafetyMode.ExecutionAndPublication);
 }
Exemple #5
0
        /// <summary>
        /// Renew client proxy to scheduler adapter internal service
        /// </summary>
        private async Task RenewSchedulerAdapterClientAsync()
        {
            if (this.schedulerClient.IsValueCreated)
            {
                await this.schedulerClientSS.WaitAsync();

                try
                {
                    if (this.schedulerClient.IsValueCreated)
                    {
                        if (this.schedulerClient.Value != null)
                        {
                            Utility.AsyncCloseICommunicationObject(this.schedulerClient.Value);
                        }

                        this.sessionNode     = new Lazy <string>(() => this.ResolveSessionNodeWithRetries().GetAwaiter().GetResult(), LazyThreadSafetyMode.ExecutionAndPublication);
                        this.certThumbprint  = new Lazy <string>(() => this.context.GetSSLThumbprint().GetAwaiter().GetResult(), LazyThreadSafetyMode.ExecutionAndPublication);
                        this.schedulerClient = new Lazy <SchedulerAdapterClient>(
                            () => new SchedulerAdapterClient(BindingHelper.HardCodedUnSecureNetTcpBinding, new EndpointAddress(SoaHelper.GetSchedulerDelegationAddress(this.sessionNode.Value)), new InstanceContext(new TraceOnlyServiceJobMonitor())),
                            LazyThreadSafetyMode.ExecutionAndPublication);
                    }
                }
                finally
                {
                    this.schedulerClientSS.Release();
                }
            }
        }