protected internal override void AssertReservationQueueDoesNotExist(ReservationId r2) { CSQueue q2 = cs.GetQueue(r2.ToString()); NUnit.Framework.Assert.IsNull(q2); }
protected internal override void AssertReservationQueueDoesNotExist(ReservationId r) { Queue q = GetReservationQueue(r.ToString()); NUnit.Framework.Assert.IsNull(q); }
protected internal override void AssertReservationQueueExists(ReservationId r2, double expectedCapacity, double expectedMaxCapacity) { CSQueue q = cs.GetQueue(r2.ToString()); NUnit.Framework.Assert.IsNotNull(q); NUnit.Framework.Assert.AreEqual(expectedCapacity, q.GetCapacity(), 0.01); NUnit.Framework.Assert.AreEqual(expectedMaxCapacity, q.GetMaximumCapacity(), 1.0); }
public override string ToString() { return("Reservation confirmation #" + ReservationId.ToString() + " is for " + Name.PadRight(7) + " \n at " + ParkName + " park and at " + CampgroundName + " campground (#" + CampgroundId + ") at site #" + SiteId.ToString().PadRight(3) + "\n from " + FromDate.ToString("D") + " to " + ToDate.ToString("D") + " and was created on " + CreateDate.ToString("D") + "\n Total Cost is of stay: " + String.Format("{0:C2}", ((ToDate - FromDate).Days * DailyFee))); }
protected internal override Org.Apache.Hadoop.Yarn.Api.Records.Resource GetReservationQueueResourceIfExists (Plan plan, ReservationId reservationId) { CSQueue resQueue = cs.GetQueue(reservationId.ToString()); Org.Apache.Hadoop.Yarn.Api.Records.Resource reservationResource = null; if (resQueue != null) { reservationResource = Resources.Multiply(cs.GetClusterResource(), resQueue.GetAbsoluteCapacity ()); } return(reservationResource); }
/// <summary> /// Return a XML representation of this object. /// </summary> public XElement ToXML() => new XElement(OCPPNS.OCPPv1_6_CP + "reserveNowRequest", new XElement(OCPPNS.OCPPv1_6_CP + "connectorId", ConnectorId.ToString()), new XElement(OCPPNS.OCPPv1_6_CP + "expiryDate", ExpiryDate.ToIso8601()), new XElement(OCPPNS.OCPPv1_6_CP + "idTag", IdTag.ToString()), ParentIdTag.HasValue ? new XElement(OCPPNS.OCPPv1_6_CP + "parentIdTag", ParentIdTag.Value.ToString()) : null, new XElement(OCPPNS.OCPPv1_6_CP + "reservationId", ReservationId.ToString()) );
public override async void Initialize(Frame frame) { base.Initialize(frame); this.Reservation = await _data.GetReservationAsync(this.ReservationId); var rootMediaFolder = await Windows.Storage.ApplicationData.Current.TemporaryFolder.CreateFolderAsync("Media", CreationCollisionOption.OpenIfExists); _mediaFolder = await rootMediaFolder.CreateFolderAsync(ReservationId.ToString(), CreationCollisionOption.OpenIfExists); _mediaTempFolder = await Windows.Storage.ApplicationData.Current.TemporaryFolder.CreateFolderAsync("Media", CreationCollisionOption.OpenIfExists); _mediaFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Media", CreationCollisionOption.OpenIfExists); await LoadMediaFiles(); await RecoverDownloads(); }
/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="CustomReserveNowRequestSerializer">A delegate to serialize custom reserve now requests.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <ReserveNowRequest> CustomReserveNowRequestSerializer = null) { var JSON = JSONObject.Create( new JProperty("connectorId", ConnectorId.ToString()), new JProperty("expiryDate", ExpiryDate.ToIso8601()), new JProperty("idTag", IdTag.ToString()), new JProperty("reservationId", ReservationId.ToString()), ParentIdTag.HasValue ? new JProperty("parentIdTag", ParentIdTag.Value.ToString()) : null ); return(CustomReserveNowRequestSerializer != null ? CustomReserveNowRequestSerializer(this, JSON) : JSON); }
public virtual Dictionary <string, string> ToDictionary() { var dictionary = new Dictionary <string, string> { { nameof(AccountHashedId), AccountHashedId }, { nameof(AccountLegalEntityHashedId), AccountLegalEntityHashedId }, { nameof(Origin), Origin.ToString() } }; if (ReservationId.HasValue) { dictionary.Add(nameof(ReservationId), ReservationId.ToString()); } if (!string.IsNullOrWhiteSpace(StartMonthYear)) { dictionary.Add(nameof(StartMonthYear), StartMonthYear); } if (!string.IsNullOrWhiteSpace(CourseCode)) { dictionary.Add(nameof(CourseCode), CourseCode); } return(dictionary); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Reservation.Exceptions.PlanningException /// "/> /// <exception cref="System.Exception"/> /// <exception cref="Org.Apache.Hadoop.Security.AccessControlException"/> protected internal virtual void TestPlanFollower(bool isMove) { // Initialize plan based on move flag plan = new InMemoryPlan(scheduler.GetRootQueueMetrics(), policy, mAgent, scheduler .GetClusterResource(), 1L, res, scheduler.GetMinimumResourceCapability(), maxAlloc , "dedicated", null, isMove); // add a few reservations to the plan long ts = Runtime.CurrentTimeMillis(); ReservationId r1 = ReservationId.NewInstance(ts, 1); int[] f1 = new int[] { 10, 10, 10, 10, 10 }; NUnit.Framework.Assert.IsTrue(plan.ToString(), plan.AddReservation(new InMemoryReservationAllocation (r1, null, "u3", "dedicated", 0, 0 + f1.Length, ReservationSystemTestUtil.GenerateAllocation (0L, 1L, f1), res, minAlloc))); ReservationId r2 = ReservationId.NewInstance(ts, 2); NUnit.Framework.Assert.IsTrue(plan.ToString(), plan.AddReservation(new InMemoryReservationAllocation (r2, null, "u3", "dedicated", 3, 3 + f1.Length, ReservationSystemTestUtil.GenerateAllocation (3L, 1L, f1), res, minAlloc))); ReservationId r3 = ReservationId.NewInstance(ts, 3); int[] f2 = new int[] { 0, 10, 20, 10, 0 }; NUnit.Framework.Assert.IsTrue(plan.ToString(), plan.AddReservation(new InMemoryReservationAllocation (r3, null, "u4", "dedicated", 10, 10 + f2.Length, ReservationSystemTestUtil.GenerateAllocation (10L, 1L, f2), res, minAlloc))); AbstractSchedulerPlanFollower planFollower = CreatePlanFollower(); Org.Mockito.Mockito.When(mClock.GetTime()).ThenReturn(0L); planFollower.Run(); Queue q = GetReservationQueue(r1.ToString()); AssertReservationQueueExists(r1); // submit an app to r1 string user_0 = "test-user"; ApplicationId appId = ApplicationId.NewInstance(0, 1); ApplicationAttemptId appAttemptId_0 = ApplicationAttemptId.NewInstance(appId, 0); AppAddedSchedulerEvent addAppEvent = new AppAddedSchedulerEvent(appId, q.GetQueueName (), user_0); scheduler.Handle(addAppEvent); AppAttemptAddedSchedulerEvent appAttemptAddedEvent = new AppAttemptAddedSchedulerEvent (appAttemptId_0, false); scheduler.Handle(appAttemptAddedEvent); // initial default reservation queue should have no apps Queue defQ = GetDefaultQueue(); NUnit.Framework.Assert.AreEqual(0, GetNumberOfApplications(defQ)); AssertReservationQueueExists(r1, 0.1, 0.1); NUnit.Framework.Assert.AreEqual(1, GetNumberOfApplications(q)); AssertReservationQueueDoesNotExist(r2); AssertReservationQueueDoesNotExist(r3); Org.Mockito.Mockito.When(mClock.GetTime()).ThenReturn(3L); planFollower.Run(); NUnit.Framework.Assert.AreEqual(0, GetNumberOfApplications(defQ)); AssertReservationQueueExists(r1, 0.1, 0.1); NUnit.Framework.Assert.AreEqual(1, GetNumberOfApplications(q)); AssertReservationQueueExists(r2, 0.1, 0.1); AssertReservationQueueDoesNotExist(r3); Org.Mockito.Mockito.When(mClock.GetTime()).ThenReturn(10L); planFollower.Run(); q = GetReservationQueue(r1.ToString()); if (isMove) { // app should have been moved to default reservation queue NUnit.Framework.Assert.AreEqual(1, GetNumberOfApplications(defQ)); NUnit.Framework.Assert.IsNull(q); } else { // app should be killed NUnit.Framework.Assert.AreEqual(0, GetNumberOfApplications(defQ)); NUnit.Framework.Assert.IsNotNull(q); AppAttemptRemovedSchedulerEvent appAttemptRemovedEvent = new AppAttemptRemovedSchedulerEvent (appAttemptId_0, RMAppAttemptState.Killed, false); scheduler.Handle(appAttemptRemovedEvent); } AssertReservationQueueDoesNotExist(r2); AssertReservationQueueExists(r3, 0, 1.0); Org.Mockito.Mockito.When(mClock.GetTime()).ThenReturn(11L); planFollower.Run(); if (isMove) { // app should have been moved to default reservation queue NUnit.Framework.Assert.AreEqual(1, GetNumberOfApplications(defQ)); } else { // app should be killed NUnit.Framework.Assert.AreEqual(0, GetNumberOfApplications(defQ)); } AssertReservationQueueDoesNotExist(r1); AssertReservationQueueDoesNotExist(r2); AssertReservationQueueExists(r3, 0.1, 0.1); Org.Mockito.Mockito.When(mClock.GetTime()).ThenReturn(12L); planFollower.Run(); AssertReservationQueueDoesNotExist(r1); AssertReservationQueueDoesNotExist(r2); AssertReservationQueueExists(r3, 0.2, 0.2); Org.Mockito.Mockito.When(mClock.GetTime()).ThenReturn(16L); planFollower.Run(); AssertReservationQueueDoesNotExist(r1); AssertReservationQueueDoesNotExist(r2); AssertReservationQueueDoesNotExist(r3); VerifyCapacity(defQ); }
public override string ToString() { return(ReservationId.ToString().PadRight(6) + SiteId.ToString().PadRight(6) + Name.PadRight(30) + FromDate.PadRight(30) + ToDate.PadRight(30) + CreateDate.PadRight(30)); }
public override string ToString() { return(ReservationId.ToString().PadRight(6) + SiteId.ToString().PadRight(6) + FamilyName.PadRight(16) + StartDate.ToString().PadRight(6) + EndDate.ToString().PadRight(10) + CreateDate.ToString().PadRight(8)); }
public override void ExecuteCmdlet() { if (ParameterSetName.Equals(Constants.ParameterSetNames.ObjectParameterSet)) { string[] name = Reservation.Name.Split('/'); ReservationOrderId = new Guid(name[0]); ReservationId = new Guid(name[1]); } var resourceInfo = $"Reservation {ReservationId} in order {ReservationOrderId}"; if (ShouldProcess(resourceInfo, "Update")) { Patch Patch; if (AppliedScope != null) { //Pre-register for Microsoft.Compute string subscriptionId = ValidateAndGetAppliedSubscription(); PreRegister(subscriptionId); Patch = new Patch(AppliedScopeType, new List <string>() { AppliedScope }, InstanceFlexibility); } else { Patch = new Patch(AppliedScopeType, instanceFlexibility: InstanceFlexibility); } var response = new PSReservation(AzureReservationAPIClient.Reservation.Update(ReservationOrderId.ToString(), ReservationId.ToString(), Patch)); WriteObject(response); } }
protected internal override void AssertReservationQueueExists(ReservationId r) { CSQueue q = cs.GetQueue(r.ToString()); NUnit.Framework.Assert.IsNotNull(q); }
public override string ToString() { return(ReservationId.ToString()); // Für bessere Coded UI Test Erkennung }
public override async void Initialize(Frame frame) { base.Initialize(frame); this.Reservation = await _data.GetReservationAsync(this.ReservationId); _localMediaFolder = await GetOrCreateFolder(ApplicationData.Current.LocalFolder, "Media", ReservationId.ToString()); _tempMediaFolder = await GetOrCreateFolder(ApplicationData.Current.TemporaryFolder, "Media", ReservationId.ToString()); EmptyTempFolder(); await LoadMediaFiles(); }
protected internal override Org.Apache.Hadoop.Yarn.Api.Records.Resource GetReservationQueueResourceIfExists (Plan plan, ReservationId reservationId) { string reservationQueueName = GetReservationQueueName(plan.GetQueueName(), reservationId .ToString()); FSLeafQueue reservationQueue = fs.GetQueueManager().GetLeafQueue(reservationQueueName , false); Org.Apache.Hadoop.Yarn.Api.Records.Resource reservationResource = null; if (reservationQueue != null) { reservationResource = reservationQueue.GetSteadyFairShare(); } return(reservationResource); }
public override string ToString() { return(ReservationId.ToString().PadRight(9) + SiteId.ToString().PadRight(24) + Name.ToString().PadRight(32) + FromDate.ToShortDateString().PadRight(15) + ToDate.ToShortDateString().PadRight(17) + CreateDate.ToShortDateString().PadRight(10)); }
public override void ExecuteCmdlet() { if (ParameterSetName.Equals(Constants.ParameterSetNames.CommandParameterSet)) { if (ReservationId != default(Guid)) { var response = new PSReservation(AzureReservationAPIClient.Reservation.Get(ReservationId.ToString(), ReservationOrderId.ToString())); WriteObject(response); } else { PageResults(); } } else if (ParameterSetName.Equals(Constants.ParameterSetNames.ObjectParameterSet)) { if (ReservationOrder != null) { ReservationOrderId = new Guid(ReservationOrder.Name); PageResults(); } } else if (ParameterSetName.Equals(Constants.ParameterSetNames.PageObjectParameterSet)) { if (ReservationOrderPage != null) { foreach (PSReservationOrder reservationOrder in ReservationOrderPage) { ReservationOrderId = new Guid(reservationOrder.Name); PageResults(); } while (ReservationOrderPage.NextPageLink != null) { ReservationOrderPage = new PSReservationOrderPage( AzureReservationAPIClient.ReservationOrder.ListNext(ReservationOrderPage.NextPageLink)); foreach (PSReservationOrder reservationOrder in ReservationOrderPage) { ReservationOrderId = new Guid(reservationOrder.Name); PageResults(); } } } } }
public override string ToString() { return(ReservationId.ToString().PadRight(10) + Name.PadRight(40) + FromDate.ToString().PadRight(10) + EndDate.ToString().PadRight(10) + CreationDate.ToString().PadRight(10)); }
//public ChargingSession AddUserData(String Key, Object Value) //{ // this._UserDefined //} public JObject ToJSON(Boolean Embedded = false) => JSONObject.Create( Id.ToJSON("@id"), Embedded ? new JProperty("@context", "https://open.charging.cloud/contexts/wwcp+json/chargingSession") : null, new JProperty("sessionTime", JSONObject.Create( new JProperty("start", SessionTime.StartTime.ToIso8601()), SessionTime.EndTime.HasValue ? new JProperty("end", SessionTime.EndTime.Value.ToIso8601()) : null )), new JProperty("duration", Duration.TotalSeconds), RoamingNetworkId.HasValue ? new JProperty("roamingNetworkId", RoamingNetworkId.ToString()) : null, ChargingStationOperatorId.HasValue ? new JProperty("chargingStationOperatorId", ChargingStationOperatorId.ToString()) : null, ChargingPoolId.HasValue ? new JProperty("chargingPoolId", ChargingPoolId. ToString()) : null, ChargingStationId.HasValue ? new JProperty("chargingStationId", ChargingStationId. ToString()) : null, EVSEId.HasValue ? new JProperty("EVSEId", EVSEId. ToString()) : null, ChargingProduct != null ? new JProperty("chargingProduct", ChargingProduct. ToJSON()) : null, ProviderIdStart != null ? new JProperty("providerIdStart", ProviderIdStart.ToString()) : null, ProviderIdStop != null ? new JProperty("providerIdStop", ProviderIdStop.ToString()) : null, AuthenticationStart.IsDefined() ? new JProperty("authenticationStart", AuthenticationStart.ToJSON()) : null, AuthenticationStop.IsDefined() ? new JProperty("authenticationStop", AuthenticationStop.ToJSON()) : null, Reservation != null ? new JProperty("reservation", new JObject( new JProperty("reservationId", Reservation.Id.ToString()), new JProperty("start", Reservation.StartTime.ToIso8601()), new JProperty("duration", Reservation.Duration.TotalSeconds) ) ) : ReservationId != null ? new JProperty("reservationId", ReservationId.ToString()) : null, EnergyMeterId.HasValue ? new JProperty("energyMeterId", EnergyMeterId.ToString()) : null, EnergyMeteringValues.Any() ? new JProperty("energyMeterValues", new JObject( EnergyMeteringValues. Select(MeterValue => new JProperty(MeterValue.Timestamp.ToIso8601(), MeterValue.Value)) )) : null );
/// <summary>Internal method for submitting jobs to the system.</summary> /// <remarks> /// Internal method for submitting jobs to the system. /// <p>The job submission process involves: /// <ol> /// <li> /// Checking the input and output specifications of the job. /// </li> /// <li> /// Computing the /// <see cref="InputSplit"/> /// s for the job. /// </li> /// <li> /// Setup the requisite accounting information for the /// <see cref="Org.Apache.Hadoop.Mapreduce.Filecache.DistributedCache"/> /// of the job, if necessary. /// </li> /// <li> /// Copying the job's jar and configuration to the map-reduce system /// directory on the distributed file-system. /// </li> /// <li> /// Submitting the job to the <code>JobTracker</code> and optionally /// monitoring it's status. /// </li> /// </ol></p> /// </remarks> /// <param name="job">the configuration to submit</param> /// <param name="cluster">the handle to the Cluster</param> /// <exception cref="System.TypeLoadException"/> /// <exception cref="System.Exception"/> /// <exception cref="System.IO.IOException"/> internal virtual JobStatus SubmitJobInternal(Job job, Cluster cluster) { //validate the jobs output specs CheckSpecs(job); Configuration conf = job.GetConfiguration(); AddMRFrameworkToDistributedCache(conf); Path jobStagingArea = JobSubmissionFiles.GetStagingDir(cluster, conf); //configure the command line options correctly on the submitting dfs IPAddress ip = Sharpen.Runtime.GetLocalHost(); if (ip != null) { submitHostAddress = ip.GetHostAddress(); submitHostName = ip.GetHostName(); conf.Set(MRJobConfig.JobSubmithost, submitHostName); conf.Set(MRJobConfig.JobSubmithostaddr, submitHostAddress); } JobID jobId = submitClient.GetNewJobID(); job.SetJobID(jobId); Path submitJobDir = new Path(jobStagingArea, jobId.ToString()); JobStatus status = null; try { conf.Set(MRJobConfig.UserName, UserGroupInformation.GetCurrentUser().GetShortUserName ()); conf.Set("hadoop.http.filter.initializers", "org.apache.hadoop.yarn.server.webproxy.amfilter.AmFilterInitializer" ); conf.Set(MRJobConfig.MapreduceJobDir, submitJobDir.ToString()); Log.Debug("Configuring job " + jobId + " with " + submitJobDir + " as the submit dir" ); // get delegation token for the dir TokenCache.ObtainTokensForNamenodes(job.GetCredentials(), new Path[] { submitJobDir }, conf); PopulateTokenCache(conf, job.GetCredentials()); // generate a secret to authenticate shuffle transfers if (TokenCache.GetShuffleSecretKey(job.GetCredentials()) == null) { KeyGenerator keyGen; try { keyGen = KeyGenerator.GetInstance(ShuffleKeygenAlgorithm); keyGen.Init(ShuffleKeyLength); } catch (NoSuchAlgorithmException e) { throw new IOException("Error generating shuffle secret key", e); } SecretKey shuffleKey = keyGen.GenerateKey(); TokenCache.SetShuffleSecretKey(shuffleKey.GetEncoded(), job.GetCredentials()); } if (CryptoUtils.IsEncryptedSpillEnabled(conf)) { conf.SetInt(MRJobConfig.MrAmMaxAttempts, 1); Log.Warn("Max job attempts set to 1 since encrypted intermediate" + "data spill is enabled" ); } CopyAndConfigureFiles(job, submitJobDir); Path submitJobFile = JobSubmissionFiles.GetJobConfPath(submitJobDir); // Create the splits for the job Log.Debug("Creating splits at " + jtFs.MakeQualified(submitJobDir)); int maps = WriteSplits(job, submitJobDir); conf.SetInt(MRJobConfig.NumMaps, maps); Log.Info("number of splits:" + maps); // write "queue admins of the queue to which job is being submitted" // to job file. string queue = conf.Get(MRJobConfig.QueueName, JobConf.DefaultQueueName); AccessControlList acl = submitClient.GetQueueAdmins(queue); conf.Set(QueueManager.ToFullPropertyName(queue, QueueACL.AdministerJobs.GetAclName ()), acl.GetAclString()); // removing jobtoken referrals before copying the jobconf to HDFS // as the tasks don't need this setting, actually they may break // because of it if present as the referral will point to a // different job. TokenCache.CleanUpTokenReferral(conf); if (conf.GetBoolean(MRJobConfig.JobTokenTrackingIdsEnabled, MRJobConfig.DefaultJobTokenTrackingIdsEnabled )) { // Add HDFS tracking ids AList <string> trackingIds = new AList <string>(); foreach (Org.Apache.Hadoop.Security.Token.Token <TokenIdentifier> t in job.GetCredentials ().GetAllTokens()) { trackingIds.AddItem(t.DecodeIdentifier().GetTrackingId()); } conf.SetStrings(MRJobConfig.JobTokenTrackingIds, Sharpen.Collections.ToArray(trackingIds , new string[trackingIds.Count])); } // Set reservation info if it exists ReservationId reservationId = job.GetReservationId(); if (reservationId != null) { conf.Set(MRJobConfig.ReservationId, reservationId.ToString()); } // Write job file to submit dir WriteConf(conf, submitJobFile); // // Now, actually submit the job (using the submit name) // PrintTokens(jobId, job.GetCredentials()); status = submitClient.SubmitJob(jobId, submitJobDir.ToString(), job.GetCredentials ()); if (status != null) { return(status); } else { throw new IOException("Could not launch job"); } } finally { if (status == null) { Log.Info("Cleaning up the staging area " + submitJobDir); if (jtFs != null && submitJobDir != null) { jtFs.Delete(submitJobDir, true); } } } }
public override void ExecuteCmdlet() { if (ParameterSetName.Equals(Constants.ParameterSetNames.ObjectParameterSet)) { string[] name = Reservation.Name.Split('/'); ReservationOrderId = new Guid(name[0]); ReservationId = new Guid(name[1]); } var response = new PSReservationPage(AzureReservationAPIClient.Reservation.ListRevisions(ReservationId.ToString(), ReservationOrderId.ToString())); WriteObject(response, true); while (response.NextPageLink != null) { response = new PSReservationPage(AzureReservationAPIClient.Reservation.ListNext(response.NextPageLink)); WriteObject(response, true); } }