/// <inheritdoc /> public void AppendSetData(IPersistedData data, long txtime, byte[] prevData, IMutableStat prevStat) { if (data == null) { throw new ArgumentNullException("data"); } if (prevStat == null) { throw new ArgumentNullException("prevStat"); } if (this.changelist == null) { this.changelist = this.createChangeList(); } data.AppendSetData(this.changelist); if (this.changelist != null) { this.changelist.SetTime(txtime); } if (this.isLockDown) { return; } this.RunOnAbort(() => { data.Data = prevData; data.Stat = prevStat; }); }
/// <inheritdoc /> public void AppendCreate(IPersistedDataFactory <Node> factory, IPersistedData data, long txtime) { if (factory == null) { throw new ArgumentNullException("factory"); } if (data == null) { throw new ArgumentNullException("data"); } if (this.changelist == null) { this.changelist = this.createChangeList(); } data.AppendCreate(this.changelist); if (this.changelist != null) { this.changelist.SetTime(txtime); } if (this.isLockDown) { return; } this.RunOnAbort(() => { factory.Delete(data); }); }
/// <summary> /// Record creation of that this instance of <see cref="IPersistedData"/>. /// </summary> /// <param name="changeList">The <see cref="IChangeList"/> associated with the creation</param> private void OnCreate(IChangeList changeList) { var list = (ChangeList)changeList; PersistenceEventSource.Log.RecordAddition(list.Id, this.Id, this.Name, this.Stat.Czxid); list.RecordAdd(this); }
/// <summary> /// Record an update to this instance of <see cref="IPersistedData"/>. /// </summary> /// <param name="changeList">The <see cref="IChangeList"/> associated with the update</param> private void OnUpdate(IChangeList changeList) { var list = (ChangeList)changeList; PersistenceEventSource.Log.RecordUpdate(list.Id, this.Id, this.Name, this.Stat.Mzxid, this.Stat.Pzxid); list.RecordUpdate(this); }
/// <summary> /// Record removal of this instance of <see cref="IPersistedData"/>. /// </summary> /// <param name="changeList">The <see cref="IChangeList"/> associated with the removal</param> private void OnRemove(IChangeList changeList) { var list = (ChangeList)changeList; PersistenceEventSource.Log.RecordRemoval(list.Id, this.Id, this.Name); list.RecordRemove(this); }
/// <summary> /// Associates an update (where a child was added to this instnace) with the given <see cref="IChangeList"/>. /// </summary> /// <param name="changeList">The <see cref="IChangeList"/> to associate with</param> /// <param name="child">The child that was added</param> public void AppendAddChild(IChangeList changeList, IPersistedData child) { if (child == null) { throw new ArgumentNullException(nameof(child)); } PersistenceEventSource.Log.PersistedDataAppendAddChild(this.Id, this.Name, child.Id, child.Name); this.OnUpdate(changeList); }
/// <summary> /// Associates the removal of this instance with the given <see cref="IChangeList"/>. /// </summary> /// <param name="changeList">The <see cref="IChangeList"/> to associate with</param> /// <param name="parent">The parent of this instance</param> /// <param name="isRecursive">If <c>true</c> the removal was recursive</param> public void AppendRemove(IChangeList changeList, IPersistedData parent, bool isRecursive = false) { PersistenceEventSource.Log.PersistedDataAppendRemove(this.Id, this.Name, isRecursive); // Log the change that this node, or the child, is removed. this.OnRemove(changeList); // Log the change on the parent, including Mzxid/Mtime in stat. ((PersistedData)parent).OnUpdate(changeList); }
/// <inheritdoc /> public void AppendRemove(IPersistedData parent, IPersistedData child, long txtime, IMutableStat prevChildStat, IMutableStat prevParentStat, Action recordUndeleteAction) { if (child == null) { throw new ArgumentNullException("child"); } if (parent == null) { throw new ArgumentNullException("parent"); } if (prevChildStat == null) { throw new ArgumentNullException("prevChildStat"); } if (prevParentStat == null) { throw new ArgumentNullException("prevParentStat"); } if (recordUndeleteAction == null) { throw new ArgumentNullException("recordUndeleteAction"); } if (this.changelist == null) { this.changelist = this.createChangeList(); } child.AppendRemove(this.changelist, parent); if (this.changelist != null) { this.changelist.SetTime(txtime); } if (this.isLockDown) { return; } this.RunOnAbort(() => { this.ValidateLockList(parent, Perm.WRITE, null, Perm.NONE); recordUndeleteAction(); parent.Node.AddChild(child.Node); child.Stat = prevChildStat; parent.Stat = prevParentStat; }); }
/// <summary> /// aborts the changes and locklist if needed /// </summary> private void CompleteAbortion() { this.MarkForAbort(); if (this.changelist != null) { this.onCommit = null; this.changelist.Abort(); this.changelist = null; } this.lockCollections.Release(); }
public FilteredChangeList(IChangeList wrappedList, IChangeFilter filter) { if (wrappedList == null) { throw new ArgumentNullException(nameof(wrappedList)); } if (filter == null) { throw new ArgumentNullException(nameof(filter)); } m_WrappedList = wrappedList; m_Filter = filter; }
/// <summary> /// Initializes a locklist, enclosing the ability of locking nodes, and creating a "replicated action" underneath /// </summary> /// <param name="auth">the authorization token</param> /// <param name="over">the overrides, optional</param> public void Initialize(ISessionAuth auth, IOperationOverrides over) { // we provision transactions at construction, which means they can commit in a different // order than monotonical increasing (if Tx1 starts becore Tx2 but Tx2 finishes before Tx1 does) this.SetTxIdAndTime(over); this.isLockDown = false; this.changelist = null; this.onAbort = null; this.readonlyInterfaceRequiresLocks = true; this.sessionAuth = auth; }
/// <inheritdoc /> public void AppendAddChild(IPersistedData parent, IPersistedData child, long txtime, IMutableStat prevStat) { if (parent == null) { throw new ArgumentNullException("parent"); } if (child == null) { throw new ArgumentNullException("child"); } if (prevStat == null) { throw new ArgumentNullException("prevStat"); } if (this.changelist == null) { this.changelist = this.createChangeList(); } parent.AppendAddChild(this.changelist, child); child.AppendSetParent(parent); if (this.changelist != null) { this.changelist.SetTime(txtime); } if (this.isLockDown) { return; } this.RunOnAbort(() => { this.ValidateLockList(parent, Perm.WRITE, null, Perm.NONE); parent.Node.RemoveChild(child.Name); parent.Stat = prevStat; }); }
/// <inheritdoc /> public void AppendRemoveNodeAndAllChildren(IPersistedData child, long txtime, Action recordUndeleteAction) { if (child == null) { throw new ArgumentNullException("child"); } if (recordUndeleteAction != null) { this.RunOnAbort(recordUndeleteAction); } if (this.changelist == null) { this.changelist = this.createChangeList(); } child.AppendRemove(this.changelist, child.Parent, true); if (this.changelist != null) { this.changelist.SetTime(txtime); } }
public bool IncludeInResult(IChangeList changeList) => true;
/// <summary> /// Appends the remove child operation to the changelist. /// </summary> /// <param name="chgs">The changelist object, or null if none exists yet.</param> /// <param name="child">The child being removed.</param> public void AppendRemoveChild(IChangeList chgs, IPersistedData child) { }
/// <summary> /// Appends the create. /// </summary> /// <param name="chgs">The CHGS.</param> public void AppendCreate(IChangeList chgs) { }
/// <summary> /// Appends the remove. /// </summary> /// <param name="chgs">The CHGS.</param> /// <param name="parent">The parent.</param> /// <param name="isRecursive">if true the deletion is recursive</param> public void AppendRemove(IChangeList chgs, IPersistedData parent, bool isRecursive = false) { }
/// <summary> /// Associates a poison pill with the given <see cref="IChangeList"/> /// </summary> /// <param name="spec">The poison pill spec</param> /// <param name="changeList">The <see cref="IChangeList"/> to associate with</param> public void AppendPoison(string spec, IChangeList changeList) { PersistenceEventSource.Log.PersistedDataAppendPoison(this.Id, this.Name, spec); }
/// <summary> /// Appends the set acl. /// </summary> /// <param name="chgs">The CHGS.</param> public void AppendSetAcl(IChangeList chgs) { }
/// <summary> /// Associates an update (where data was set on this instance) with the given <see cref="IChangeList"/>. /// </summary> /// <param name="changeList">The <see cref="IChangeList"/> to associate with</param> public void AppendSetData(IChangeList changeList) { PersistenceEventSource.Log.PersistedDataAppendSetData(this.Id, this.Name); this.OnUpdate(changeList); }
/// <summary> /// Ensures the data is fresh before reading it. May block the call until it is fresh /// </summary> /// <param name="chgs">The changelist.</param> public void AppendRead(IChangeList chgs) { PersistenceEventSource.Log.PersistedDataAppendRead(this.Id, this.Name); }
/// <summary> /// Appends the set data. /// </summary> /// <param name="chgs">The CHGS.</param> public void AppendSetData(IChangeList chgs) { }
/// <summary> /// Appends a poison pill for this node to the changelist. /// </summary> /// <param name="spec">Poison pill specification</param> /// <param name="chgs">The changelist.</param> public void AppendPoison(string spec, IChangeList chgs) { }
/// <summary> /// closes this locklist, and commits changes and unlocks all if context gets down to 0 /// </summary> /// <param name="task">async task to indicate the completion of the replication on output</param> /// <returns>true if it needs to be disposed</returns> public bool Complete(out Task task) { ManualResetEvent ev = null; bool abort = this.IsMarkedForAbort(); task = Task.FromResult(0); try { // if this is an abort and we are not in the topmost context, lock down this object so nothing else can be done other that unwind and abort if (abort) { if (this.onAbort != null) { // CAREFUL! this iteration will execute IN REVERSE ORDER. Because elements were inserted each on the first place!!! foreach (Action elem in this.onAbort) { elem(); } } if (this.changelist != null) { this.changelist.Abort(); } } else { List <Action> actions = this.onCommit; this.onCommit = null; // execute all oncommit actions now if (actions != null) { foreach (Action act in actions) { act(); } } if (this.changelist != null && !this.onlyOnEphemeral) { try { if (this.FinishSynchronous) { ev = ManualResetEventPool.InstancePool.GetOne(); this.changelist.CommitSync(this.TxId, ev, out task); } else { this.changelist.Commit(this.TxId, out task); } } catch (Exception e) { RmAssert.Fail("Commit failed: " + e); } RingMasterServerInstrumentation.Instance.OnTxCommitted(); } } } finally { // make sure we unlock the tree in all cases this.changelist = null; this.onAbort = null; this.onCommit = null; this.lockCollections.Release(); } if (ev != null) { ManualResetEventPool.InstancePool.WaitOneAndReturn(ref ev); } return(true); }
/// <summary> /// Ensures the data is fresh before reading it. May block the call until it is fresh /// </summary> /// <param name="chgs">The changelist.</param> public void AppendRead(IChangeList chgs) { }