private int Heartbeat() { Network.Client.SynClient sc = GetClient(); TrinityErrorCode eResult = sc.Heartbeat(); PutBackClient(sc); if (TrinityErrorCode.E_SUCCESS == eResult) { if (!m_connected) { m_connected = true; m_memorycloud.ReportServerConnectedEvent(this); } } else { if (m_connected) { m_connected = false; m_memorycloud.ReportServerDisconnectedEvent(this); InvalidateSynClients(); } } return(TrinityConfig.HeartbeatInterval); }
protected internal RemoteStorage(IEnumerable <ServerInfo> servers, int connPerServer, MemoryCloud mc, int partitionId, bool nonblocking) { this.m_memorycloud = mc; this.PartitionId = partitionId; var connect_async_task = Task.Factory.StartNew(() => { for (int k = 0; k < connPerServer; k++) // make different server connections interleaved { foreach (var s in servers) { Connect(s); } } if (mc != null && partitionId != -1) { BackgroundThread.AddBackgroundTask(new BackgroundTask(Heartbeat, TrinityConfig.HeartbeatInterval)); mc.ReportServerConnectedEvent(this); } }); if (!nonblocking) { try { connect_async_task.Wait(); } catch (AggregateException ex) { ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); } } }
internal RemoteStorage(AvailabilityGroup trinityServer, int connPerServer, MemoryCloud mc, int serverId, bool nonblocking) { this.memory_cloud = mc; this.MyServerId = serverId; retry = 3; var connect_async_task = Task.Factory.StartNew(() => { for (int k = 0; k < connPerServer; k++) // make different server connections interleaved { for (int i = 0; i < trinityServer.ServerInstances.Count; i++) { ConnectIPEndPoint(trinityServer.ServerInstances[i].EndPoint); } } BackgroundThread.AddBackgroundTask(new BackgroundTask(Heartbeat, TrinityConfig.HeartbeatInterval)); mc.ReportServerConnectedEvent(serverId); }); if (!nonblocking) { try { connect_async_task.Wait(); } catch (AggregateException ex) { ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); } } }