/// <summary> /// Returns a value indicating whether or not this progress vector includes the provided /// <paramref name="version"/>. /// </summary> /// <param name="version">The version.</param> /// <returns> /// A value indicating whether or not this progress vector includes the provided <paramref name="version"/>. /// </returns> public bool IncludesVersionInPreviousEpoch(RecordVersion version) { var foundEntry = false; foreach (var entry in this.Progress) { if (entry.Epoch == version.Epoch) { // The next entry will indicate the highest committed log sequence number for // the subject's epoch. foundEntry = true; continue; } if (foundEntry) { // If the previous epoch (i.e, the subject's epoch) had a highest log sequence number // which is greater or equal to the subject's log sequence number, then this progress // vector includes the subject. return(entry.PreviousEpochHighestLogSequenceNumber >= version.LogSequenceNumber); } if (entry.Epoch > version.Epoch) { // Epochs are ordered, so if this epoch is greater than the subject's epoch, but // the previous epoch was not equal to the subject's epoch, then the subject's epoch // is not included in this progress vector. return(false); } } return(false); }
/// <summary> /// Calls the provided requests completion handler and waits for it to complete. /// </summary> /// <param name="request">The reqest.</param> /// <returns>A <see cref="Task"/> representing the work performed.</returns> private async Task CompleteOrderedReplication(ReplicationRequest request) { if (this.closing) { this.logger.Log(nameof(OperationReplicator <TOperation>) + nameof(this.CompleteOrderedReplication)); } try { var logSequenceNumber = await request.ReplicationCompleted.Task.ConfigureAwait(false); // Create a record to append. var version = new RecordVersion(this.stateProvider.CurrentEpoch, logSequenceNumber); var record = new OperationCommittedRecord <TOperation>(request.Operation, version); // Write the record. await this.stateProvider.AppendOperation(this.serializer.Serialize <Record>(record), logSequenceNumber).ConfigureAwait(false); } catch (Exception exception) { // If the error was caused by the state provider, propagate that exception. if (request.ReplicationCompleted.Task.Status == TaskStatus.RanToCompletion) { await request.CompletionHandler(Task.FromException <long>(exception)).ConfigureAwait(false); return; } } // Wait for the caller's completion handler to complete before continuing to // process other replication completion handlers. await request.CompletionHandler(request.ReplicationCompleted.Task).Suppressed().ConfigureAwait(false); }
void Start() { GameApp.Instance.UILogin = this; versionLabel.text = "版本: " + RecordVersion.Read(); GameApp.Instance.SoundInstance.PlayBgm("BGM_Login01"); // if (PlayerPrefs.HasKey(AccountLDKey)) { Account = PlayerPrefs.GetString(AccountLDKey); } if (PlayerPrefs.HasKey(PasswordLDKey)) { Password = PlayerPrefs.GetString(PasswordLDKey); } MobilePhoneLogin_Inp_PhoneNum.value = Account; PasswordLogin_Inp_PhoneNum.value = Account; ResetPassword_Inp_PhoneNum.value = Account; PasswordLogin_Inp_Password.value = Password; // LeSDKLoginRoot.transform.localScale = Vector3.zero; BeginGameRoot.transform.localScale = Vector3.zero; LoginTypeRoot.transform.localScale = Vector3.zero; MobilePhoneLoginRoot.transform.localScale = Vector3.zero; MobilePhoneLoginRoot.GetComponent <UIWidget>().alpha = 0; ResetPasswordRoot.transform.localScale = Vector3.zero; ResetPasswordRoot.GetComponent <UIWidget>().alpha = 0; RegisterAccountRoot.transform.localScale = Vector3.zero; RegisterAccountRoot.GetComponent <UIWidget>().alpha = 0; PasswordLoginRoot.transform.localScale = Vector3.zero; PasswordLoginRoot.GetComponent <UIWidget>().alpha = 0; }
/// <summary> /// Applies the provided, replicated <paramref name="operation"/>. /// </summary> /// <param name="operation">The operation.</param> /// <param name="cancellationtoken">The cancellation token.</param> /// <returns>A <see cref="Task"/> representing the work performed.</returns> public async Task ApplyReplicationOperation(IOperation operation, CancellationToken cancellationtoken) { try { foreach (var operationData in operation.Data) { var op = this.serializer.Deserialize <TOperation>(operationData); // Create a record to append. var version = new RecordVersion(this.stateProvider.CurrentEpoch, operation.SequenceNumber); var record = new OperationCommittedRecord <TOperation>(op, version); // Append the operation to the log at the current epoch. await this.stateProvider.AppendOperation(this.serializer.Serialize <Record>(record), operation.SequenceNumber); } } catch (Exception exception) { this.logger.Log($"Exception in {nameof(this.ApplyReplicationOperation)}: {exception}"); this.partition.ReportFault(FaultType.Transient); throw; } }
public Record(string left, string right, RecordVersion version) { this.left = left; this.right = right; this.version = version; }