/// <summary> /// Load the setting from the config.xml. /// </summary> /// <param name="inputXml">The input xml.</param> /// <param name="workingDir">The working directory.</param> public void Initalize(string inputXml, string workingDir) { if (_isInitalized) { return; } _isInitalized = true; _tmocWorkRoot = workingDir; string packageRoot = string.Empty; // Inital TMOC config file. configVC = new TmocVcConfig(inputXml); // Make temporaray folder. if (string.IsNullOrEmpty(_localTempWorkingDir)) { _localTempWorkingDir = MakeLocalTempWorkDirectory(); } string runningLog = TmocPath.Combine(_localTempWorkingDir, TmocConstants.RunningLog); if (TmocFile.Exists(runningLog)) { TmocFile.Delete(runningLog); } // Load VC token number to calculate the VC percentage. var totalToken = GetTokenNum(); // Calculate the vc percentage from the machine number. percentAllocationVC = Math.Max(1, Math.Min(100, Convert.ToInt32(100 * (Convert.ToDouble(configVC.MaxTokenNum) / Convert.ToDouble(totalToken))))); _tmocPackageRoot = configVC.TmocDataPath; if (string.IsNullOrEmpty(_localTempWorkingDir)) { _localTempWorkingDir = MakeLocalTempWorkDirectory(); } // Initialize the local run or cosmos run. if (string.IsNullOrEmpty(configVC.VcName)) { _tmocBinaryRoot = Path.Combine(packageRoot, "bin"); _jobSubmitter = new JobSubmitter(_localTempWorkingDir); } else { if (TmocPath.IsCosmosPath(configVC.VcName)) { _tmocBinaryRoot = TmocPath.Combine(packageRoot, "bin"); _jobSubmitter = new JobSubmitter(configVC, _localTempWorkingDir); } else { throw new ArgumentException(string.Format("vcname must start with http://, but it is {0}", configVC.VcName)); } } }
/// <summary> /// Initializes a new instance of the <see cref="JobSubmitter" /> class. Intialize the job submmit for runing in cosmos. /// </summary> /// <param name="configVC">The vc to use.</param> /// <param name="tmpLocalDir">The tmp dir to store the tmp generated scripts.</param> public JobSubmitter(TmocVcConfig configVC, string tmpLocalDir = @".\") { this.tmpLocalDir = tmpLocalDir; this.configVC = configVC; cosmosObj = new COSMOSHelper(configVC); }