Exemplo n.º 1
0
        private void RemoveFromQueue(bool localOnly, string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                throw new ArgumentException("The specified entry is not valid", "id");
            }

            ProcessQueue.Remove(x => x.Tag == id);

            if (!localOnly)
            {
                Task.Run(() =>
                {
                    InterNodeCommunicationMessage msg = new InterNodeCommunicationMessage {
                        Tag = id, IsLocalOnly = true, MessageType = InterNodeMessageType.RemoveFromQueue
                    };
                    // not sure this is valid as its non deterministic
                    lock (KnownNodes)
                    {
                        foreach (var el in KnownNodes)
                        {
                            SendToNode(el, InterNodeCommunicationMessageSerialiser.Serialise(msg));
                        }
                    }
                });
            }
        }
Exemplo n.º 2
0
        private void RemoveFromCache(bool localOnly, string id)
        {
            if (String.IsNullOrEmpty(id))
            {
                throw new ArgumentException("The key cannot be null or empty", "id");
            }

            ResultCache.Remove(id, localOnly);

            if (!localOnly)
            {
                Task.Run(() =>
                {
                    InterNodeCommunicationMessage msg = new InterNodeCommunicationMessage {
                        Tag = id, IsLocalOnly = true, MessageType = InterNodeMessageType.RemoveFromCache
                    };
                    // not sure this is valid as its non deterministic
                    lock (KnownNodes)
                    {
                        foreach (var el in KnownNodes)
                        {
                            SendToNode(el, InterNodeCommunicationMessageSerialiser.Serialise(msg));
                        }
                    }
                });
            }
        }
Exemplo n.º 3
0
 private void internode_OnClientConnectCompleted(object sender, IPEndPoint e)
 {
     if (e != null)
     {
         Console.WriteLine("Client connected...");
         InterNodeCommunicationMessage msg = new InterNodeCommunicationMessage {
             IsLocalOnly = true, MessageType = InterNodeMessageType.StartUp, Tag = e.Address.ToString()
         };
         SendToNode(e.Address, InterNodeCommunicationMessageSerialiser.Serialise(msg));
     }
 }
Exemplo n.º 4
0
        private void GetDataFromNode(IPAddress ip, InterNodeMessageType msgType)
        {
            if (ip == null)
            {
                throw new ArgumentException("ip cannot be null");
            }

            if (msgType == InterNodeMessageType.FullQueueUpdateSent || msgType == InterNodeMessageType.FullCacheUpdateSent)
            {
                InterNodeCommunicationMessage msg = new InterNodeCommunicationMessage {
                    MessageType = msgType, IsLocalOnly = true
                };
                SendToNode(ip, InterNodeCommunicationMessageSerialiser.Serialise(msg));
            }
        }
Exemplo n.º 5
0
        private void SendFullQueueUpdate(IPAddress ip)
        {
            if (ip == null)
            {
                throw new ArgumentException("The specified ip is not valid", "ip");
            }

            IObservableQueue <ClientProcess> temp = ProcessQueue;

            var msg = new InterNodeCommunicationMessage {
                Data = PrioritisedQueueSerialiser.Serialise(temp), IsLocalOnly = true, MessageType = InterNodeMessageType.FullQueueUpdateReceived
            };

            SendToNode(ip, InterNodeCommunicationMessageSerialiser.Serialise(msg));
        }
Exemplo n.º 6
0
        private void SendFullCacheUpdate(IPAddress ip)
        {
            if (ip == null)
            {
                throw new ArgumentException("The specified IP address is not valid", "ip");
            }

            if (!KnownNodes.Contains(ip))
            {
                throw new ArgumentException("The ip address specified is not known.", "ip");
            }

            // grab a copy of the cache
            CacheProvider <string, ClientResultMessage> temp = ResultCache;

            temp.ClearSubscribersNoNotify();
            InterNodeCommunicationMessage msg = new InterNodeCommunicationMessage {
                Data = CacheSerialiser.Serialise(temp), IsLocalOnly = true, MessageType = InterNodeMessageType.FullCacheUpdateReceived
            };

            SendToNode(ip, InterNodeCommunicationMessageSerialiser.Serialise(msg));
        }