コード例 #1
0
        /// <summary>
        ///   <para>Gets the instance of the
        /// <see cref="Microsoft.Hpc.Scheduler.Session.Data.DataClient" /> class that has the specified
        /// string identifier.</para>
        /// </summary>
        /// <param name="dataClientId">
        ///   <para>A
        /// <see cref="System.String" /> that specifies the identifier for the
        /// <see cref="Microsoft.Hpc.Scheduler.Session.Data.DataClient" /> object that you want to get.</para>
        /// </param>
        /// <returns>
        ///   <para>A <see cref="Microsoft.Hpc.Scheduler.Session.Data.DataClient" /> object that has the specified identifier.</para>
        /// </returns>
        public static DataClient GetDataClient(string dataClientId)
        {
            Microsoft.Hpc.Scheduler.Session.Data.Utility.ValidateDataClientId(dataClientId);

            if (!inService)
            {
                throw new InvalidOperationException(SR.ServiceContextIsNotAvailable);
            }

            using (NonHARegistry registry = new NonHARegistry())
            {
                if (registry.CheckIfNonDomain().GetAwaiter().GetResult())
                {
                    return(GetNonDomainDataClient(dataClientId));
                }
            }

            if (SoaHelper.IsOnAzure())
            {
                // if it is running in Azure, just talk to DataProxy
                // Note: headnode name will not be used.
                return(DataClient.Open("dataproxy", dataClientId));
            }

            lock (lockDataServerInfoInitialized)
            {
                if (!bDataServerInfoInitialized)
                {
                    string strDataServerInfo = Environment.GetEnvironmentVariable(Microsoft.Hpc.Scheduler.Session.Internal.Constant.SoaDataServerInfoEnvVar);
                    if (!string.IsNullOrEmpty(strDataServerInfo))
                    {
                        dataServerInfo = new DataServerInfo(strDataServerInfo);
                    }
                    else
                    {
                        logger.TraceEvent(TraceEventType.Error, 0, "[ServiceContext] .GetDataClient: no data server configured");
                        DataServerInfoConfigException = new DataException(DataErrorCode.NoDataServerConfigured, SR.NoDataServerConfigured);
                    }

                    bDataServerInfoInitialized = true;
                }
            }

            if (dataServerInfo != null)
            {
                string containerPath = DataContainerHelper.OpenDataContainer(dataServerInfo, dataClientId);
                return(new DataClient(dataClientId, containerPath, /*readOnly = */ true));
            }
            else
            {
                throw DataServerInfoConfigException;
            }
        }
コード例 #2
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);
     }
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the DataClient class
 /// </summary>
 /// <param name="dataClientId">data client id</param>
 /// <param name="dataStorePath">data store path</param>
 /// <param name="readOnly">a flag indicating whether the DataClient instance is readonly or not</param>
 internal DataClient(string dataClientId, string dataStorePath, bool readOnly)
 {
     this.id            = dataClientId;
     this.isReadOnly    = readOnly;
     this.dataContainer = DataContainerHelper.GetDataContainer(dataStorePath);
 }