/// <summary> /// Allocate the session resource. The function will check password /// </summary> /// <param name="client"></param> /// <param name="startInfo"></param> private async Task BeginAllocate(SessionStartInfo startInfo, CredType credType) { bool durable = (GetType() == typeof(DurableSessionAsyncResult)); SessionBase.TraceSource.TraceEvent(TraceEventType.Verbose, 0, "[Session:Unknown] Start to create session, IsDurable = {0}.", durable); while (retry > 0) { try { SessionBase.TraceSource.TraceEvent(TraceEventType.Verbose, 0, "[Session:Unknown] Authenticating... Retry Count = {0}, CredType = {1}", HardCodedRetryLimit + 1 - retry, credType); if (SoaHelper.IsSchedulerOnAzure(this.StartInfo.Headnode) || SoaHelper.IsSchedulerOnIaaS(this.StartInfo.Headnode)) { SessionBase.RetrieveCredentialOnAzure(this.StartInfo); } else { await SessionBase.RetrieveCredentialOnPremise(this.StartInfo, credType, this.binding).ConfigureAwait(false); SessionBase.CheckCredential(this.StartInfo); } break; } catch (AuthenticationException) { if (credType == CredType.None) { credType = await CredUtil.GetCredTypeFromClusterAsync(this.StartInfo, this.binding).ConfigureAwait(false); } this.StartInfo.ClearCredential(); SessionBase.PurgeCredential(this.StartInfo); retry--; if (retry == 0) { throw; } } } SessionLauncherClient client = new SessionLauncherClient(startInfo, this.binding); try { SessionBase.TraceSource.TraceEvent(TraceEventType.Verbose, 0, "[Session:Unknown] Allocating resource..."); if (durable) { if ((StartInfo.TransportScheme & TransportScheme.NetTcp) == TransportScheme.NetTcp) { client.BeginAllocateDurable(this.StartInfo.Data, SessionLauncherClient.EndpointPrefix, this.AllocateCallback, client); } else if ((StartInfo.TransportScheme & TransportScheme.NetHttp) == TransportScheme.NetHttp) { client.BeginAllocateDurable(this.StartInfo.Data, SessionLauncherClient.HttpsEndpointPrefix, this.AllocateCallback, client); } else if ((StartInfo.TransportScheme & TransportScheme.Http) == TransportScheme.Http) { client.BeginAllocateDurable(this.StartInfo.Data, SessionLauncherClient.HttpsEndpointPrefix, this.AllocateCallback, client); } else if ((StartInfo.TransportScheme & TransportScheme.Custom) == TransportScheme.Custom) { client.BeginAllocateDurable(this.StartInfo.Data, SessionLauncherClient.EndpointPrefix, this.AllocateCallback, client); } } else { if ((StartInfo.TransportScheme & TransportScheme.NetTcp) == TransportScheme.NetTcp) { client.BeginAllocate(this.StartInfo.Data, SessionLauncherClient.EndpointPrefix, this.AllocateCallback, client); } else if ((StartInfo.TransportScheme & TransportScheme.NetHttp) == TransportScheme.NetHttp) { client.BeginAllocate(this.StartInfo.Data, SessionLauncherClient.HttpsEndpointPrefix, this.AllocateCallback, client); } else if ((StartInfo.TransportScheme & TransportScheme.Http) == TransportScheme.Http) { client.BeginAllocate(this.StartInfo.Data, SessionLauncherClient.HttpsEndpointPrefix, this.AllocateCallback, client); } else if ((StartInfo.TransportScheme & TransportScheme.Custom) == TransportScheme.Custom) { client.BeginAllocate(this.StartInfo.Data, SessionLauncherClient.EndpointPrefix, this.AllocateCallback, client); } } } catch (EndpointNotFoundException e) { SessionBase.TraceSource.TraceEvent(TraceEventType.Error, 0, "[Session:Unknown] EndpointNotFoundException occured while allocating resource: {0}", e); SessionBase.HandleEndpointNotFoundException(this.StartInfo.Headnode); } return; }