void RegistrationExpired(object state) { if (!opened) { return; } try { IPeerResolverClient proxy = GetProxy(); RefreshResponseInfo response; try { int oldValue = Interlocked.Exchange(ref this.updateSuccessful, 1); if (oldValue == 0) { SendUpdate(new UpdateInfo(this.registrationId, this.clientId, this.meshId, this.nodeAddress), ServiceDefaults.SendTimeout); return; } RefreshInfo info = new RefreshInfo(this.meshId, this.registrationId); response = proxy.Refresh(info); if (response.Result == RefreshResult.RegistrationNotFound) { RegisterInfo registerInfo = new RegisterInfo(clientId, meshId, nodeAddress); RegisterResponseInfo registerResponse = proxy.Register(registerInfo); registrationId = registerResponse.RegistrationId; this.defaultLifeTime = registerResponse.RegistrationLifetime; } else { Fx.Assert(response.Result == RefreshResult.Success, "Unrecognized value!!"); } proxy.Close(); } finally { proxy.Abort(); timer.Set(this.defaultLifeTime); } } catch (CommunicationException e) { DiagnosticUtility.TraceHandledException(e, TraceEventType.Information); } catch (Exception e) { if (Fx.IsFatal(e)) { throw; } DiagnosticUtility.TraceHandledException(e, TraceEventType.Information); } }
public virtual RefreshResponseInfo Refresh(RefreshInfo refreshInfo) { if (refreshInfo == null) { throw new ArgumentException("Refresh info cannot be null."); } if (!opened) { throw new InvalidOperationException("The service has never been opened or it was closed previously."); } return(client.Refresh(refreshInfo)); }
private void RegistrationExpired(object state) { if (this.opened) { try { IPeerResolverClient proxy = this.GetProxy(); try { if (Interlocked.Exchange(ref this.updateSuccessful, 1) == 0) { this.SendUpdate(new UpdateInfo(this.registrationId, this.clientId, this.meshId, this.nodeAddress), ServiceDefaults.SendTimeout); } else { RefreshInfo refreshInfo = new RefreshInfo(this.meshId, this.registrationId); if (proxy.Refresh(refreshInfo).Result == RefreshResult.RegistrationNotFound) { RegisterInfo registerInfo = new RegisterInfo(this.clientId, this.meshId, this.nodeAddress); RegisterResponseInfo info4 = proxy.Register(registerInfo); this.registrationId = info4.RegistrationId; this.defaultLifeTime = info4.RegistrationLifetime; } proxy.Close(); } } finally { proxy.Abort(); this.timer.Set(this.defaultLifeTime); } } catch (CommunicationException exception) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information); } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information); } } }
public virtual RefreshResponseInfo Refresh(RefreshInfo refreshInfo) { if (refreshInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("refreshInfo", SR.GetString(SR.PeerNullRefreshInfo)); } ThrowIfClosed("Refresh"); if (!refreshInfo.HasBody() || String.IsNullOrEmpty(refreshInfo.MeshId) || refreshInfo.RegistrationId == Guid.Empty) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("refreshInfo", SR.GetString(SR.PeerInvalidMessageBody, refreshInfo)); } RefreshResult result = RefreshResult.RegistrationNotFound; RegistrationEntry entry = null; MeshEntry meshEntry = GetMeshEntry(refreshInfo.MeshId, false); LiteLock ll = null; if (meshEntry != null) { try { LiteLock.Acquire(out ll, meshEntry.Gate); if (!meshEntry.EntryTable.TryGetValue(refreshInfo.RegistrationId, out entry)) { return(new RefreshResponseInfo(RefreshInterval, result)); } lock (entry) { if (entry.State == RegistrationState.OK) { entry.Expires = DateTime.UtcNow + RefreshInterval; result = RefreshResult.Success; } } } finally { LiteLock.Release(ll); } } return(new RefreshResponseInfo(RefreshInterval, result)); }
public virtual RefreshResponseInfo Refresh(RefreshInfo refreshInfo) { if (refreshInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("refreshInfo", System.ServiceModel.SR.GetString("PeerNullRefreshInfo")); } this.ThrowIfClosed("Refresh"); if ((!refreshInfo.HasBody() || string.IsNullOrEmpty(refreshInfo.MeshId)) || (refreshInfo.RegistrationId == Guid.Empty)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("refreshInfo", System.ServiceModel.SR.GetString("PeerInvalidMessageBody", new object[] { refreshInfo })); } RefreshResult registrationNotFound = RefreshResult.RegistrationNotFound; RegistrationEntry entry = null; MeshEntry meshEntry = this.GetMeshEntry(refreshInfo.MeshId, false); LiteLock liteLock = null; if (meshEntry != null) { try { LiteLock.Acquire(out liteLock, meshEntry.Gate); if (!meshEntry.EntryTable.TryGetValue(refreshInfo.RegistrationId, out entry)) { return(new RefreshResponseInfo(this.RefreshInterval, registrationNotFound)); } lock (entry) { if (entry.State == RegistrationState.OK) { entry.Expires = DateTime.UtcNow + this.RefreshInterval; registrationNotFound = RefreshResult.Success; } } } finally { LiteLock.Release(liteLock); } } return(new RefreshResponseInfo(this.RefreshInterval, registrationNotFound)); }
public RefreshResponseInfo Refresh(RefreshInfo refreshInfo) { var r = refreshInfo; log.WriteLine("REQUEST: Refresh (Mesh: {0}, Registraion: {1})", r.MeshId, r.RegistrationId); var mesh = GetExistingMesh(r.MeshId); var node = mesh.FirstOrDefault(n => n.RegistrationId == r.RegistrationId); if (node == null) { return new RefreshResponseInfo() { Result = RefreshResult.RegistrationNotFound } } ; node.Refresh(); return(new RefreshResponseInfo() { Result = RefreshResult.Success, RegistrationLifetime = RefreshInterval - (DateTime.Now - node.LastRefreshTime) }); }
void RegistrationExpired(object state) { if (!opened) return; try { IPeerResolverClient proxy = GetProxy(); RefreshResponseInfo response; try { int oldValue = Interlocked.Exchange(ref this.updateSuccessful, 1); if (oldValue == 0) { SendUpdate(new UpdateInfo(this.registrationId, this.clientId, this.meshId, this.nodeAddress), ServiceDefaults.SendTimeout); return; } RefreshInfo info = new RefreshInfo(this.meshId, this.registrationId); response = proxy.Refresh(info); if (response.Result == RefreshResult.RegistrationNotFound) { RegisterInfo registerInfo = new RegisterInfo(clientId, meshId, nodeAddress); RegisterResponseInfo registerResponse = proxy.Register(registerInfo); registrationId = registerResponse.RegistrationId; this.defaultLifeTime = registerResponse.RegistrationLifetime; } else { Fx.Assert(response.Result == RefreshResult.Success, "Unrecognized value!!"); } proxy.Close(); } finally { proxy.Abort(); timer.Set(this.defaultLifeTime); } } catch (CommunicationException e) { DiagnosticUtility.TraceHandledException(e, TraceEventType.Information); } catch (Exception e) { if (Fx.IsFatal(e)) throw; DiagnosticUtility.TraceHandledException(e, TraceEventType.Information); } }
public virtual new RefreshResponseInfo Refresh(RefreshInfo refreshInfo) { return default(RefreshResponseInfo); }
public virtual new RefreshResponseInfo Refresh(RefreshInfo refreshInfo) { return(default(RefreshResponseInfo)); }
public virtual RefreshResponseInfo Refresh(RefreshInfo refreshInfo) { if (refreshInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("refreshInfo", SR.GetString(SR.PeerNullRefreshInfo)); } ThrowIfClosed("Refresh"); if (!refreshInfo.HasBody() || String.IsNullOrEmpty(refreshInfo.MeshId) || refreshInfo.RegistrationId == Guid.Empty) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("refreshInfo", SR.GetString(SR.PeerInvalidMessageBody, refreshInfo)); } RefreshResult result = RefreshResult.RegistrationNotFound; RegistrationEntry entry = null; MeshEntry meshEntry = GetMeshEntry(refreshInfo.MeshId, false); LiteLock ll = null; if (meshEntry != null) { try { LiteLock.Acquire(out ll, meshEntry.Gate); if (!meshEntry.EntryTable.TryGetValue(refreshInfo.RegistrationId, out entry)) return new RefreshResponseInfo(RefreshInterval, result); lock (entry) { if (entry.State == RegistrationState.OK) { entry.Expires = DateTime.UtcNow + RefreshInterval; result = RefreshResult.Success; } } } finally { LiteLock.Release(ll); } } return new RefreshResponseInfo(RefreshInterval, result); }
public virtual RefreshResponseInfo Refresh(RefreshInfo refreshInfo) { if (refreshInfo == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("refreshInfo", System.ServiceModel.SR.GetString("PeerNullRefreshInfo")); } this.ThrowIfClosed("Refresh"); if ((!refreshInfo.HasBody() || string.IsNullOrEmpty(refreshInfo.MeshId)) || (refreshInfo.RegistrationId == Guid.Empty)) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("refreshInfo", System.ServiceModel.SR.GetString("PeerInvalidMessageBody", new object[] { refreshInfo })); } RefreshResult registrationNotFound = RefreshResult.RegistrationNotFound; RegistrationEntry entry = null; MeshEntry meshEntry = this.GetMeshEntry(refreshInfo.MeshId, false); LiteLock liteLock = null; if (meshEntry != null) { try { LiteLock.Acquire(out liteLock, meshEntry.Gate); if (!meshEntry.EntryTable.TryGetValue(refreshInfo.RegistrationId, out entry)) { return new RefreshResponseInfo(this.RefreshInterval, registrationNotFound); } lock (entry) { if (entry.State == RegistrationState.OK) { entry.Expires = DateTime.UtcNow + this.RefreshInterval; registrationNotFound = RefreshResult.Success; } } } finally { LiteLock.Release(liteLock); } } return new RefreshResponseInfo(this.RefreshInterval, registrationNotFound); }
private void RegistrationExpired(object state) { if (this.opened) { try { IPeerResolverClient proxy = this.GetProxy(); try { if (Interlocked.Exchange(ref this.updateSuccessful, 1) == 0) { this.SendUpdate(new UpdateInfo(this.registrationId, this.clientId, this.meshId, this.nodeAddress), ServiceDefaults.SendTimeout); } else { RefreshInfo refreshInfo = new RefreshInfo(this.meshId, this.registrationId); if (proxy.Refresh(refreshInfo).Result == RefreshResult.RegistrationNotFound) { RegisterInfo registerInfo = new RegisterInfo(this.clientId, this.meshId, this.nodeAddress); RegisterResponseInfo info4 = proxy.Register(registerInfo); this.registrationId = info4.RegistrationId; this.defaultLifeTime = info4.RegistrationLifetime; } proxy.Close(); } } finally { proxy.Abort(); this.timer.Set(this.defaultLifeTime); } } catch (CommunicationException exception) { DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Information); } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Information); } } }
public virtual RefreshResponseInfo Refresh (RefreshInfo refreshInfo) { if (refreshInfo == null) throw new ArgumentException ("Refresh info cannot be null."); if (! opened) throw new InvalidOperationException ("The service has never been opened or it was closed previously."); return client.Refresh (refreshInfo); }