/// <summary> /// Open an existing DataClient with the specified ID, job ID and job secret /// </summary> /// <param name="hpcContext">The <see cref="IHpcContext"/> instance.</param> /// <param name="dataClientId">ID of the DataClient to be opened</param> /// <param name="jobId">Job ID</param> /// <param name="jobSecret">Job Secret</param> /// <returns>DataClient instance that provides read/write access to the specified DataClient</returns> internal static DataClient Open(string dataClientId, int jobId, string jobSecret) { var context = HpcContext.GetOrAdd(EndpointsConnectionString.LoadFromEnvVarsOrWindowsRegistry(), CancellationToken.None, true); Utility.ValidateDataClientId(dataClientId); DataClientInfo info = OpenBySecretInternal(context, dataClientId, jobId, jobSecret); return(new DataClient(context.ResolveSessionLauncherNodeAsync().GetAwaiter().GetResult(), dataClientId, info.PrimaryDataPath, true, TransportScheme.NetTcp, null, null)); }
/// <summary> /// Initializes a new instance of the HpcSchedulerAdapterInternalClient class /// </summary> /// <param name="headNode">indicating the headnode</param> public HpcSchedulerAdapterInternalClient(string headNode) : base( BindingHelper.HardCodedInternalSchedulerDelegationBinding, SoaHelper.CreateInternalCertEndpointAddress( new Uri(SoaHelper.GetSchedulerDelegationInternalAddress(headNode)), HpcContext.GetOrAdd(headNode, CancellationToken.None).GetSSLThumbprint().GetAwaiter().GetResult())) { // use certificate for cluster internal authentication string thunbprint = HpcContext.GetOrAdd(headNode, CancellationToken.None).GetSSLThumbprint().GetAwaiter().GetResult(); this.ClientCredentials.UseInternalAuthentication(thunbprint); this.InnerChannel.OperationTimeout = OperationTimeout; }
/// <summary> /// This method closes the session async with the given ID /// </summary> /// <param name="headNode">Headnode name</param> /// <param name="sessionId">The ID of the session to be closed</param> /// <param name="binding">indicting the binding</param> /// <param name="isAadUser">If the session is belong to a AAD user</param> /// <param name="token">The cancellation token.</param> public static async Task CloseSessionAsync(string headNode, int sessionId, Binding binding, bool isAadUser, CancellationToken token) { Utility.ThrowIfEmpty(headNode, "headNode"); SessionLauncherClient client = null; BrokerLauncherClient broker = null; string headNodeMachine = await HpcContext.GetOrAdd(headNode, token).ResolveSessionLauncherNodeAsync().ConfigureAwait(false); try { client = new SessionLauncherClient(headNodeMachine, binding, isAadUser); client.InnerChannel.OperationTimeout = GetTimeout(DateTime.MaxValue); //TODO: need to change the endpoint prefix for https SessionInfo info = null; if (binding is NetTcpBinding) { info = Utility.BuildSessionInfoFromDataContract(await client.GetInfoV5Async(SessionLauncherClient.EndpointPrefix, sessionId).ConfigureAwait(false)); } #if !net40 else if (binding is BasicHttpBinding || binding is NetHttpBinding || binding is NetHttpsBinding) { info = Utility.BuildSessionInfoFromDataContract(await client.GetInfoV5Async(SessionLauncherClient.HttpsEndpointPrefix, sessionId).ConfigureAwait(false)); } #endif broker = new BrokerLauncherClient(info, binding, new Uri(info.BrokerLauncherEpr)); broker.InnerChannel.OperationTimeout = GetTimeout(DateTime.MaxValue); broker.Close(sessionId); } catch (FaultException <SessionFault> e) { throw Utility.TranslateFaultException(e); } finally { if (client != null) { Utility.SafeCloseCommunicateObject(client); } if (broker != null) { Utility.SafeCloseCommunicateObject(broker); } } }