// Updates a node's registration with the resolver service. public override void Update(object registrationId, PeerNodeAddress updatedNodeAddress, TimeSpan timeout) { if (opened) { UpdateInfo info = new UpdateInfo(this.registrationId, clientId, meshId, updatedNodeAddress); this.nodeAddress = updatedNodeAddress; SendUpdate(info, timeout); } }
void SendUpdate(UpdateInfo updateInfo, TimeSpan timeout) { try { RegisterResponseInfo response; IPeerResolverClient proxy = GetProxy(); try { proxy.OperationTimeout = timeout; response = proxy.Update(updateInfo); proxy.Close(); this.registrationId = response.RegistrationId; this.defaultLifeTime = response.RegistrationLifetime; Interlocked.Exchange(ref this.updateSuccessful, 1); timer.Set(this.defaultLifeTime); } finally { proxy.Abort(); } } catch (CommunicationException e) { DiagnosticUtility.TraceHandledException(e, TraceEventType.Information); Interlocked.Exchange(ref this.updateSuccessful, 0); } catch (Exception e) { if (Fx.IsFatal(e)) throw; Interlocked.Exchange(ref this.updateSuccessful, 0); throw; } }
public virtual new RegisterResponseInfo Update(UpdateInfo updateInfo) { return default(RegisterResponseInfo); }
public virtual new RegisterResponseInfo Update(UpdateInfo updateInfo) { return(default(RegisterResponseInfo)); }
public virtual RegisterResponseInfo Update(UpdateInfo updateInfo) { if (updateInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("updateInfo", SR.GetString(SR.PeerNullRegistrationInfo)); } ThrowIfClosed("Update"); if (!updateInfo.HasBody() || String.IsNullOrEmpty(updateInfo.MeshId) || updateInfo.NodeAddress == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("updateInfo", SR.GetString(SR.PeerInvalidMessageBody, updateInfo)); } Guid registrationId = updateInfo.RegistrationId; RegistrationEntry entry; MeshEntry meshEntry = GetMeshEntry(updateInfo.MeshId); LiteLock ll = null; //handle cases when Update ----s with Register. if (updateInfo.RegistrationId == Guid.Empty || meshEntry == null) return Register(updateInfo.ClientId, updateInfo.MeshId, updateInfo.NodeAddress); // // preserve locking order between ThisLock and the LiteLock. lock (ThisLock) { try { LiteLock.Acquire(out ll, meshEntry.Gate); if (!meshEntry.EntryTable.TryGetValue(updateInfo.RegistrationId, out entry)) { try { // upgrade to writer lock ll.UpgradeToWriterLock(); return Register(updateInfo.ClientId, updateInfo.MeshId, updateInfo.NodeAddress); } finally { ll.DowngradeFromWriterLock(); } } lock (entry) { entry.Address = updateInfo.NodeAddress; entry.Expires = DateTime.UtcNow + this.RefreshInterval; } } finally { LiteLock.Release(ll); } } return new RegisterResponseInfo(registrationId, RefreshInterval); }
public virtual RegisterResponseInfo Update(UpdateInfo updateInfo) { if (updateInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("updateInfo", System.ServiceModel.SR.GetString("PeerNullRegistrationInfo")); } this.ThrowIfClosed("Update"); if ((!updateInfo.HasBody() || string.IsNullOrEmpty(updateInfo.MeshId)) || (updateInfo.NodeAddress == null)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("updateInfo", System.ServiceModel.SR.GetString("PeerInvalidMessageBody", new object[] { updateInfo })); } Guid registrationId = updateInfo.RegistrationId; MeshEntry meshEntry = this.GetMeshEntry(updateInfo.MeshId); LiteLock liteLock = null; if ((updateInfo.RegistrationId == Guid.Empty) || (meshEntry == null)) { return this.Register(updateInfo.ClientId, updateInfo.MeshId, updateInfo.NodeAddress); } try { RegistrationEntry entry; LiteLock.Acquire(out liteLock, meshEntry.Gate); if (!meshEntry.EntryTable.TryGetValue(updateInfo.RegistrationId, out entry)) { return this.Register(updateInfo.ClientId, updateInfo.MeshId, updateInfo.NodeAddress); } lock (entry) { entry.Address = updateInfo.NodeAddress; entry.Expires = DateTime.UtcNow + this.RefreshInterval; } } finally { LiteLock.Release(liteLock); } return new RegisterResponseInfo(registrationId, this.RefreshInterval); }
public virtual RegisterResponseInfo Update (UpdateInfo updateInfo) { if (updateInfo == null) throw new ArgumentException ("Update info cannot be null."); if (! opened) throw new InvalidOperationException ("The service has never been opened or it was closed previously."); return client.Update (updateInfo); }