private void InitializeClientOnCluster(Guid targetClusterId) { // submitted inside synchronized(clientStateMutex) try { lock (_clientStateMutex) { if (!targetClusterId.Equals(_clusterId)) { Logger.Warning("Won't send client state to cluster: " + targetClusterId + " Because switched to a new cluster: " + _clusterId); return; } } _client.SendStateToCluster(); lock (_clientStateMutex) { if (targetClusterId.Equals(_clusterId)) { if (Logger.IsFinestEnabled) { Logger.Finest("Client state is sent to cluster: " + targetClusterId); } _clientState = ClientState.INITIALIZED_ON_CLUSTER; _client.LifecycleService.FireLifecycleEvent(LifecycleEvent.LifecycleState.ClientConnected); } else if (Logger.IsFinestEnabled) { Logger.Warning("Cannot set client state to " + ClientState.INITIALIZED_ON_CLUSTER + " because current cluster id: " + _clusterId + " is different than expected cluster id: " + targetClusterId); } } } catch (Exception e) { var clusterName = _client.ClusterService.ClusterName; Logger.Warning("Failure during sending state to the cluster.", e); lock (_clientStateMutex) { if (targetClusterId.Equals(_clusterId)) { if (Logger.IsFinestEnabled) { Logger.Warning("Retrying sending state to the cluster: " + targetClusterId + ", name: " + clusterName); } _client.ExecutionService.Submit(() => InitializeClientOnCluster(targetClusterId)); } } } }
private void InitializeClientOnCluster(Guid targetClusterId) { // submitted inside synchronized(clientStateMutex) try { lock (_clientStateMutex) { if (!targetClusterId.Equals(_clusterId)) { Logger.Warning(string.Format( "Won't send client state to cluster: {0} Because switched to a new cluster: {1}", targetClusterId, _clusterId)); return; } } _client.SendStateToCluster(); lock (_clientStateMutex) { if (targetClusterId.Equals(_clusterId)) { if (Logger.IsFinestEnabled) { Logger.Finest($"Client state is sent to cluster: {targetClusterId}"); } _clientState = ClientState.InitializedOnCluster; _client.LifecycleService.FireLifecycleEvent(LifecycleEvent.LifecycleState.ClientConnected); } else if (Logger.IsFinestEnabled) { Logger.Warning(string.Format( "Cannot set client state to {0} because current cluster id: {1} is different than expected cluster id: {2}", ClientState.InitializedOnCluster, _clusterId, targetClusterId)); } } } catch (Exception e) { var clusterName = _client.ClusterService.ClusterName; Logger.Warning("Failure during sending state to the cluster.", e); lock (_clientStateMutex) { if (targetClusterId.Equals(_clusterId)) { if (Logger.IsFinestEnabled) { Logger.Warning($"Retrying sending state to the cluster:{targetClusterId}, name:{clusterName}"); } _client.ExecutionService.Submit(() => InitializeClientOnCluster(targetClusterId)); } } } }