Пример #1
0
 /// <summary>
 /// Initializes a new instance of the DataClient class
 /// </summary>
 /// <param name="headNode">head node name</param>
 /// <param name="dataClientId">data client id</param>
 /// <param name="info">data client info</param>
 /// <param name="readOnly">a flag indicating whether the DataClient instance is readonly or not</param>
 /// <param name="userName">user name</param>
 /// <param name="password">the password name</param>
 private DataClient(string headNode, string dataClientId, DataClientInfo info, bool readOnly, TransportScheme scheme, string userName = null, string password = null)
     : this(dataClientId, info, readOnly)
 {
     this.headNode = headNode;
     this.userName = userName;
     this.password = password;
     this.scheme   = scheme;
 }
Пример #2
0
        /// <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));
        }
Пример #3
0
        /// <summary>
        /// Open an existing DataClient with the specified ID
        /// </summary>
        /// <param name="headNode">cluster head node name</param>
        /// <param name="dataClientId">ID of the DataClient to be opened</param>
        /// <param name="userName">user name</param>
        /// <param name="password">the password name</param>
        /// <returns>DataClient instance that provides read/write access to the specified DataClient</returns>
        public static DataClient Open(string headNode, string dataClientId, DataLocation location)
        {
            Utility.ValidateHeadNode(headNode);
            Utility.ValidateDataClientId(dataClientId);

            DataClientInfo info = OpenInternal(headNode, dataClientId, location, TransportScheme.NetTcp, null, null);

            return(new DataClient(headNode, dataClientId, info.PrimaryDataPath, /*readOnly=*/ true, TransportScheme.NetTcp, null, null));
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the DataClient class
 /// </summary>
 /// <param name="dataClientId">data client id</param>
 /// <param name="info">data client info</param>
 /// <param name="readOnly">a flag indicating whether the DataClient instance is readonly or not</param>
 internal DataClient(string dataClientId, DataClientInfo info, bool readOnly)
 {
     this.id         = dataClientId;
     this.isReadOnly = readOnly;
     if (string.IsNullOrEmpty(info.SecondaryDataPath))
     {
         this.dataContainer = DataContainerHelper.GetDataContainer(info.PrimaryDataPath);
     }
     else
     {
         this.dataContainer = DataContainerHelper.GetDataContainer(info.PrimaryDataPath, info.SecondaryDataPath);
     }
 }
Пример #5
0
        /// <summary>
        /// Open an existing DataClient with the specified ID
        /// </summary>
        /// <param name="startInfo">the session start info</param>
        /// <param name="dataClientId">data client id</param>
        /// <returns>DataClient instance that provides read/write access to the specified DataClient</returns>
        public static DataClient Open(SessionStartInfo startInfo, string dataClientId)
        {
            Utility.ValidateHeadNode(startInfo.Headnode);
            Utility.ValidateDataClientId(dataClientId);
            DataLocation location = DataLocation.FileShare;

            if (Microsoft.Hpc.Scheduler.Session.Internal.SoaHelper.IsSchedulerOnIaaS(startInfo.Headnode))
            {
                location = DataLocation.AzureBlob;
            }

            DataClientInfo info = OpenInternal(startInfo.Headnode, dataClientId, location, startInfo.TransportScheme, startInfo.Username, startInfo.InternalPassword);

            return(new DataClient(startInfo.Headnode, dataClientId, info.PrimaryDataPath, /*readOnly=*/ true, startInfo.TransportScheme, startInfo.Username, startInfo.InternalPassword));
        }
Пример #6
0
        /// <summary>
        /// Create a DataClient instance with the specified data client id
        /// </summary>
        /// <param name="headNode">head node name</param>
        /// <param name="dataClientId">data client id</param>
        /// <param name="allowedUsers">privileged users who has read permission to the data client</param>
        /// <param name="scheme">the transport scheme</param>
        /// <param name="location">the data location</param>
        /// <param name="userName">the user name</param>
        /// <param name="password">the password</param>
        /// <returns>a new DataClient instance</returns>
        private static DataClient CreateInternal(string headNode, string dataClientId, string[] allowedUsers, TransportScheme scheme, DataLocation location, string userName, string password)
        {
            if (allowedUsers != null)
            {
                foreach (string allowedUser in allowedUsers)
                {
                    Microsoft.Hpc.Scheduler.Session.Internal.Utility.ThrowIfNullOrEmpty(allowedUser, "allowed user");
                }
            }

            IDataService dataAgent = GetDataServiceAgent(headNode, scheme, userName, password);

            DataClientInfo info = InvokeDataOperation <DataClientInfo>(
                dataAgent,
                delegate(IDataService agent)
            {
                return(agent.CreateDataClientV4(dataClientId, allowedUsers, location));
            });

            Debug.Assert(!string.IsNullOrEmpty(info.PrimaryDataPath), "primaryDataPath");
            return(new DataClient(headNode, dataClientId, info, /*readOnly = */ false, scheme, userName, password));
        }