public void Test_SplitBrain_Backup() { StateChanged <InstanceState> stateChanged = null; var observer = new MockStateObserver(s => stateChanged = s, Assert.IsNull); InstanceState localState; ClusterException cex = null; ClusterStateMachine machine = CreateClusterStateMachine(observer, NodeRole.Backup, out localState, ex => cex = ex); var newState = new InstanceState { CurrentState = machine.Active, Role = NodeRole.Backup, Status = NodeStatus.Active }; machine.TransitionToState(newState, machine.Active); var remoteState = new NodeState { Role = NodeRole.Primary, Status = NodeStatus.Active }; machine.RaiseEvent(newState, machine.PartnerStatusReceived, remoteState); Assert.AreEqual(ClusterFailureReason.SplitBrain, cex.Reason); Assert.AreEqual("Stopped", stateChanged.Previous.Name); Assert.AreEqual("Final", stateChanged.Current.Name); }
public void Test_InvalidTopology() { StateChanged <InstanceState> stateChanged = null; var observer = new MockStateObserver(s => stateChanged = s, Assert.IsNull); InstanceState localState; ClusterException cex = null; ClusterStateMachine machine = CreateClusterStateMachine(observer, NodeRole.Primary, out localState, ex => cex = ex); var remoteState = new NodeState { Role = NodeRole.Primary, Status = NodeStatus.Connecting }; machine.RaiseEvent(localState, machine.PartnerStatusReceived, remoteState); Assert.AreEqual(ClusterFailureReason.InvalidTopology, cex.Reason); Assert.AreEqual("Stopped", stateChanged.Previous.Name); Assert.AreEqual("Final", stateChanged.Current.Name); machine = CreateClusterStateMachine(observer, NodeRole.Backup, out localState, ex => cex = ex); remoteState = new NodeState { Role = NodeRole.Backup, Status = NodeStatus.Connecting }; machine.RaiseEvent(localState, machine.PartnerStatusReceived, remoteState); Assert.AreEqual(ClusterFailureReason.InvalidTopology, cex.Reason); Assert.AreEqual("Stopped", stateChanged.Previous.Name); Assert.AreEqual("Final", stateChanged.Current.Name); }
// Token: 0x060008BB RID: 2235 RVA: 0x0002A090 File Offset: 0x00028290 private static AmClusterException TranslateClusterExceptionForClient(ClusterException ex) { ClusterEvictWithoutCleanupException ex2 = ex as ClusterEvictWithoutCleanupException; if (ex2 != null) { return(new AmClusterEvictWithoutCleanupException(ex2.NodeName)); } ClusterNodeNotFoundException ex3 = ex as ClusterNodeNotFoundException; if (ex3 != null) { return(new AmClusterNodeNotFoundException(ex3.NodeName)); } ClusterNodeJoinedException ex4 = ex as ClusterNodeJoinedException; if (ex4 != null) { return(new AmClusterNodeJoinedException(ex4.NodeName)); } ClusterFileNotFoundException ex5 = ex as ClusterFileNotFoundException; if (ex5 != null) { return(new AmClusterFileNotFoundException(ex5.NodeName)); } return(new AmClusterException(ex.Message)); }
private void HandleClusterException(ClusterException exception) { if (exception.LocalState == null) { exception.LocalState = _localState; } if (_clusterExceptionAction != null) { _clusterExceptionAction(exception); } Debug.WriteLine("Cluster Failure. Reason:{0} Local:{1} Remote:{2}", exception.Reason, JsonConvert.SerializeObject(exception.LocalState), JsonConvert.SerializeObject(exception.RemoteState)); }
public void Test_LostPartner_During_Any_Should_LogException() { StateChanged <InstanceState> stateChanged = null; var observer = new MockStateObserver(s => stateChanged = s, Assert.IsNull); InstanceState localState; ClusterException cex = null; ClusterStateMachine machine = CreateClusterStateMachine(observer, NodeRole.Primary, out localState, ex => cex = ex); var remoteState = new NodeState { Role = NodeRole.Backup, Status = NodeStatus.Passive }; machine.RaiseEvent(localState, machine.PartnerStatusReceived, remoteState); machine.RaiseEvent(localState, machine.LostPartner, localState); Assert.AreEqual(ClusterFailureReason.LostPartner, cex.Reason); Assert.AreEqual("Connecting", stateChanged.Previous.Name); Assert.AreEqual("Active", stateChanged.Current.Name); }
public void Test_SplitBrain_Primary() { StateChanged <InstanceState> stateChanged = null; var observer = new MockStateObserver(s => stateChanged = s, Assert.IsNull); InstanceState localState; ClusterException cex = null; ClusterStateMachine machine = CreateClusterStateMachine(observer, NodeRole.Primary, out localState, ex => cex = ex); var remoteState = new NodeState { Role = NodeRole.Backup, Status = NodeStatus.Passive }; machine.RaiseEvent(localState, machine.PartnerStatusReceived, remoteState); remoteState = new NodeState { Role = NodeRole.Backup, Status = NodeStatus.Active }; machine.RaiseEvent(localState, machine.PartnerStatusReceived, remoteState); Assert.IsNull(cex); Assert.AreEqual("Connecting", stateChanged.Previous.Name); Assert.AreEqual("Active", stateChanged.Current.Name); }
private static void HandleClusterException(ClusterException exception) { Console.WriteLine("Cluster Failure. Reason:{0} Local:{1} Remote:{2}", exception.Reason, JsonConvert.SerializeObject(exception.LocalState), JsonConvert.SerializeObject(exception.RemoteState)); }