コード例 #1
0
        public void FaultNode(Guid activityId = default(Guid))
        {
            TestabilityTrace.TraceSource.WriteInfo(TraceType, "{0}: Faulting node: '{1}'", activityId, this);

            // First confirm that the node is not already faulted or unavailable due to a fault in a child entity
            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.FaultNode_NodeInTransition_TelemetryId,
                !this.IsAvailableToFault,
                string.Format(
                    StringResources.ChaosEngineError_NodeEntity_NodeInTransition,
                    this.CurrentNodeInfo.NodeName),
                this.ClusterSnapshot);

            ChaosUtility.ThrowOrAssertIfTrue(
                ChaosConstants.FaultNode_UnsafeNode_TelemetryId,
                !this.ClusterSnapshot.UnsafeModeEnabled && this.IsUnsafeToFault,
                string.Format(
                    StringResources.ChaosEngineError_NodeEntity_UnsafeNode,
                    this.CurrentNodeInfo.NodeName),
                this.ClusterSnapshot);

            TestabilityTrace.TraceSource.WriteInfo("Here are all the codepackages:");

            var cps = this.ClusterSnapshot.GetAllCodePackages();

            foreach (var cp in cps)
            {
                TestabilityTrace.TraceSource.WriteInfo(TraceType, "Codepackage={0}", cp);
            }

            // Faulting a node will result in all the code packages and the replicas on the node
            // in turn faulting. In this case faulting all the code packages will result
            // in the replicas inside the code package to also fault. That is why we only fault the
            // code packages here since that takes care of marking the replicas as faulted
            foreach (var codePackage in this.ClusterSnapshot.GetAllCodePackages())
            {
                if (codePackage.NodeName == this.CurrentNodeInfo.NodeName)
                {
                    // This will also fault the replicas
                    TestabilityTrace.TraceSource.WriteInfo(
                        TraceType, "{0}: Going to fault code package: '{1}' due to faulting node '{2}'",
                        activityId,
                        codePackage,
                        this);

                    codePackage.FaultCodePackage(activityId);
                }
            }

            // Mark current node as faulted
            this.NodeFlags |= ClusterEntityFlags.Faulted;
        }
コード例 #2
0
        public void ClearNodeOfExclusionFlags()
        {
            if (!this.IsExcludedForFaults())
            {
                return;
            }

            foreach (var codePackage in this.ClusterSnapshot.GetAllCodePackages())
            {
                if (codePackage.NodeName == this.CurrentNodeInfo.NodeName)
                {
                    codePackage.ClearCodePackageOfExclusionFlags();
                }
            }

            this.NodeFlags &= ~ClusterEntityFlags.Excluded;
        }
コード例 #3
0
 public void ClearReplicaOfExclusionFlags()
 {
     this.ReplicaFlags &= ~ClusterEntityFlags.Excluded;
 }
コード例 #4
0
 public void MarkReplicaAsExcludedFromFault()
 {
     this.ReplicaFlags |= ClusterEntityFlags.Excluded;
 }
コード例 #5
0
 public void MarkReplicaAsUnsafeToFault()
 {
     this.ReplicaFlags |= ClusterEntityFlags.Unsafe;
 }
コード例 #6
0
 public void MarkNodeAsExcludedForFaults()
 {
     this.NodeFlags |= ClusterEntityFlags.Excluded;
 }
コード例 #7
0
 public void MarkNodeAsUnavailableForFaults()
 {
     this.NodeFlags |= ClusterEntityFlags.Unavailable;
 }
コード例 #8
0
 public void MarkNodeAsUnsafeToFault()
 {
     this.NodeFlags |= ClusterEntityFlags.Unsafe;
 }