Exemplo n.º 1
0
 public void SendFailureLogMsg(VertexPair notification)
 {
     if (logger != null)
     {
         if (algorithmConfig.OutputVerbosity == AllConcurConfig.OutputVerbosityType.INFO)
         {
             logger.Tell(new Messages.LogFailure(notification));
         }
         else if (algorithmConfig.OutputVerbosity == AllConcurConfig.OutputVerbosityType.DEBUG)
         {
             logger.Tell(new Messages.LogFailureVerbose(notification, failureNotifications.ToList().AsReadOnly()));
         }
     }
 }
Exemplo n.º 2
0
        public void Ready()
        {
            Receive <Messages.Abroadcast>(NewMessageToBroadcast);
            Receive <Messages.Rbroadcast>(NewRbroadcastedMessage);

            Receive <Terminated>((m) =>
            {
                IActorRef crashed = m.ActorRef;
                faultyServers.Add(crashed);
                IActorRef suspected     = Self;
                VertexPair notification = new VertexPair(crashed, suspected);
                if (!failureNotifications.Contains(notification))
                {
                    foreach (var a in reliableSuccessors)
                    {
                        a.Tell(new Messages.IndirectFailureNotification(crashed));
                    }
                }

                NewFailureNotification(notification);
            });
            Receive <Messages.IndirectFailureNotification>((m) =>
            {
                IActorRef crashed   = m.ActorRef;
                IActorRef suspected = Sender;
                faultyServers.Add(crashed);
                VertexPair notification = new VertexPair(crashed, suspected);
                if (!failureNotifications.Contains(notification))
                {
                    foreach (var a in reliableSuccessors)
                    {
                        a.Forward(m);
                    }
                }

                NewFailureNotification(notification);
            });
            ReceiveAny(_ => Stash.Stash());
        }
Exemplo n.º 3
0
        public void NewFailureNotification(VertexPair notification)
        {
            failureNotifications.Add(notification);

            SendFailureLogMsg(notification);

            foreach (var pair in trackingGraphs)
            {
                var graph = pair.Value;
                if (algorithmConfig.OutputVerbosity == AllConcurConfig.OutputVerbosityType.DEBUG)
                {
                    graph.ProcessCrash(notification, failureNotifications, true);
                }
                else
                {
                    graph.ProcessCrash(notification, failureNotifications, false);
                }
            }

            SendTrackGraphLogMsg();

            CheckTermination();
        }
Exemplo n.º 4
0
        public void ProcessCrash(VertexPair crashedLink, HashSet <VertexPair> F, bool outFlag)
        {
            IActorRef p  = crashedLink.V1;
            IActorRef pk = crashedLink.V2;

            if (!graph.ContainsKey(p))
            {
                return;
            }

            if (!hasSuccessors(p))
            {
                Queue <VertexPair> possibleRecipients = new Queue <VertexPair>();

                foreach (var n in allSuccessors[p])
                {
                    if (!n.Equals(pk) && !n.Equals(trackedServer))
                    {
                        possibleRecipients.Enqueue(new VertexPair(p, n));
                    }
                }

                while (possibleRecipients.Count != 0)
                {
                    VertexPair link = possibleRecipients.Dequeue();
                    graph[link.V1].AddLast(link.V2);
                    if (!graph.ContainsKey(link.V2))
                    {
                        graph[link.V2] = new LinkedList <IActorRef>();

                        foreach (var err in F)
                        {
                            if (err.V1.Path.Equals(link.V2.Path))
                            {
                                foreach (var n in allSuccessors[link.V2])
                                {
                                    if (n.Path.Equals(trackedServer.Path))
                                    {
                                        continue;
                                    }
                                    VertexPair additional = new VertexPair(link.V2, n);

                                    if (outFlag == true)
                                    {
                                        Console.WriteLine($"====================> Try to add {additional.V1.ToShortString()} {additional.V2.ToShortString()}");
                                    }

                                    if (!F.Contains(additional))
                                    {
                                        if (outFlag == true)
                                        {
                                            Console.WriteLine($"====================> added {additional.V1.ToShortString()} {additional.V2.ToShortString()}");
                                        }

                                        possibleRecipients.Enqueue(additional);
                                    }
                                }
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                graph[p].Remove(pk);

                if (graph[p].Count == 0) // Not checked
                {
                    Queue <IActorRef> pToDel = new Queue <IActorRef>();
                    pToDel.Enqueue(p);

                    while (pToDel.Count != 0)
                    {
                        IActorRef currentP = pToDel.Dequeue();
                        graph.Remove(currentP);

                        foreach (var key in graph.Keys)
                        {
                            graph[key].Remove(currentP);
                            if (graph[key].Count == 0)
                            {
                                pToDel.Enqueue(key);
                            }
                        }
                    }
                }

                List <IActorRef> keysToDelete = new List <IActorRef>();
                foreach (var pair in graph)
                {
                    if (!pathExists(pair.Key))
                    {
                        keysToDelete.Add(pair.Key);
                    }
                }
                foreach (var k in keysToDelete)
                {
                    graph.Remove(k);
                }
            }

            bool failure = false;

            foreach (var pair in graph)
            {
                IActorRef link = pair.Key;
                foreach (var err in F)
                {
                    if (err.V1.Path.Equals(link.Path))
                    {
                        failure = true;
                        break;
                    }
                }

                if (!failure)
                {
                    return;
                }
                failure = false;
            }
            if (outFlag)
            {
                Console.WriteLine($"XXXXX {trackedServer.ToShortString()} cleared");
            }
            Clear();
        }
Exemplo n.º 5
0
 private string failureString(VertexPair notification)
 {
     return($"XX> Failure notification about {notification.V1.ToShortString()} " +
            $"from {notification.V2.ToShortString()} was r-delivered <XX");
 }