Beispiel #1
0
        public void SpreadSubscription(ProcessHeader brokerHeader, String topicName)
        {
            Topic topic = topicRoot.GetSubtopic(topicName);
            IList <ProcessHeader> brokerList = adjacentBrokerList.Keys.ToList();

            //if this isn't the origin of subscription
            if (!brokerHeader.Equals(Header))
            {
                //mark broker as interested in topic
                topic.AddBroker(brokerHeader);
                //remove the previous sender from the list
                brokerList.Remove(brokerHeader);
            }

            foreach (ProcessHeader broker in brokerList)
            {
                try {
                    //send it
                    adjacentBrokerList[broker].SpreadSubscription(Header, topicName);
                } catch (SocketException) {
                    Console.WriteLine("Unregistered " + broker.ProcessName);
                    adjacentBrokerList.Remove(broker);
                }
            }
        }
Beispiel #2
0
        public void AddBroker(ProcessHeader brokerHeader)
        {
            IMessageBrokerService brokerService = (IMessageBrokerService)Activator.GetObject(
                typeof(IMessageBrokerService),
                brokerHeader.ProcessURL);

            adjacentBrokerList.Add(brokerHeader, brokerService);
        }
 public void AckDelivery(ProcessHeader subscriberHeader, ProcessHeader publisherHeader)
 {
     if (Process.Frozen)
     {
         Process.Freeze(new Task(() => { Process.AckDelivery(subscriberHeader, publisherHeader); }));
         return;
     }
     Process.AckDelivery(subscriberHeader, publisherHeader);
 }
 //child->broker
 public void RegisterBroker(ProcessHeader brokerHeader)
 {
     if (Process.Frozen)
     {
         Process.Freeze(new Task(() => { Process.AddBroker(brokerHeader); }));
         return;
     }
     Process.AddBroker(brokerHeader);
 }
 public void SpreadUnsubscription(ProcessHeader brokerHeader, String topicName)
 {
     if (Process.Frozen)
     {
         Process.Freeze(new Task(() => { Process.SpreadUnsubscription(brokerHeader, topicName); }));
         return;
     }
     Process.SpreadUnsubscription(brokerHeader, topicName);
 }
 //subscriber->broker
 public void RegisterSubscriber(ProcessHeader subscriberHeader)
 {
     if (Process.Frozen)
     {
         Process.Freeze(new Task(() => { Process.AddSubscriber(subscriberHeader); }));
         return;
     }
     Process.AddSubscriber(subscriberHeader);
 }
 public void Unsubscribe(ProcessHeader subscriberHeader, String topicName)
 {
     if (Process.Frozen)
     {
         Process.Freeze(new Task(() => { Process.RemoveSubscription(subscriberHeader, topicName); }));
         return;
     }
     Process.RemoveSubscription(subscriberHeader, topicName);
 }
Beispiel #8
0
        public void MakeSubscription(ProcessHeader subscriberHeader, String topicName)
        {
            Topic topic = topicRoot.GetSubtopic(topicName);

            topic.AddSubscriber(subscriberHeader);
            if (routingPolicy == RoutingPolicyType.FILTER)
            {
                SpreadSubscription(Header, topicName);
            }
        }
Beispiel #9
0
        static void Main(string[] args)
        {
            ProcessHeader processHeader = new ProcessHeader(args[0], ProcessType.SUBSCRIBER, args[1], args[2]);
            Subscriber    process       = new Subscriber(processHeader);

            process.LaunchService <SubscriberService, ISubscriber>(((ISubscriber)process));
            process.ConnectToParentBroker(args[3]);

            Console.WriteLine(process);
            Console.ReadLine();
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            ProcessHeader processHeader = new ProcessHeader(args[0], ProcessType.PUBLISHER, args[1], args[2]);
            Publisher     process       = new Publisher(processHeader);

            process.LaunchService <PublisherService, IPublisher>(((IPublisher)process));
            process.ConnectToParentBroker(args[3]);

            Console.WriteLine(process);
            Console.ReadLine();
        }
Beispiel #11
0
        public void AddSubscriber(ProcessHeader subscriberHeader)
        {
            //get subscriber remote object
            ISubscriberService newSubscriber =
                (ISubscriberService)Activator.GetObject(
                    typeof(ISubscriberService),
                    subscriberHeader.ProcessURL);

            //add the new subscriber
            subscriberList.Add(subscriberHeader, newSubscriber);
        }
Beispiel #12
0
 private void ReadHeader(ProcessHeader processHeader, PoolElement poolElement)
 {
     if (processHeader?.Created != null)
     {
         DateTime dateTime;
         if (DateTime.TryParse(processHeader.Created.Value, out dateTime))
         {
             poolElement.CreatedOn = dateTime;
         }
     }
 }
Beispiel #13
0
        public void AckDelivery(ProcessHeader subscriberHeader, ProcessHeader publisherHeader)
        {
            Event @event;

            lock (locker) {
                if (orderManager.TryGetPendingEvent(subscriberHeader, publisherHeader, out @event))
                {
                    subscriberList[subscriberHeader].DeliverEvent(@event);
                }
            }
        }
Beispiel #14
0
 public MessageBroker(ProcessHeader processHeader) :
     base(processHeader)
 {
     topicRoot            = new Topic("", null);
     mainBroker           = null;
     subscriberList       = new Dictionary <ProcessHeader, ISubscriberService>();
     adjacentBrokerList   = new Dictionary <ProcessHeader, IMessageBrokerService>();
     replicatedBrokerList = new Dictionary <ProcessHeader, IMessageBrokerService>();
     brokerSeqNumList     = new Dictionary <String, int>();
     orderManager         = new EventOrderManager();
     secondaryManager     = new EventOrderManager();
     locker        = new Object();
     rootSeqNumber = 0;
 }
Beispiel #15
0
        public void Present(
            SimpleInterfaceServerDispatcher interfaceServerDispatcher,
            FromProcessMeasurement <Interface.MemoryStruct.IMemoryMeasurement> measurement)
        {
            MeasurementLastHeader?.SetStatus(measurement.MemoryMeasurementLastStatusEnum());

            ProcessHeader?.SetStatus(ProcessChoice.ProcessStatusEnum());

            LicenseDataContext.Dispatcher = interfaceServerDispatcher;

            var sessionDurationRemainingTooShort = !(measurement?.Value).SessionDurationRemainingSufficientToStayExposed();

            SessionDurationRemainingTextBox.Text             = (measurement?.Value?.SessionDurationRemaining?.ToString() ?? "????");
            SessionDurationRemainingTooShortGroup.Visibility = (sessionDurationRemainingTooShort && null != measurement) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;

            Measurement?.Present(measurement);
        }
 public bool TrySetPendingEvent(ProcessHeader subscriber, Event @event)
 {
     if (Ordering == OrderingType.NO_ORDER)
     {
     }
     else if (Ordering == OrderingType.FIFO)
     {
         Queue <Event> pendingDeliveryList;
         lock (pendingDeliveryBuffer) {
             if (!pendingDeliveryBuffer.TryGetValue(subscriber + @event.PublisherHeader, out pendingDeliveryList))
             {
                 pendingDeliveryList = new Queue <Event>();
                 pendingDeliveryBuffer.Add(subscriber + @event.PublisherHeader, pendingDeliveryList);
                 pendingDeliveryList.Enqueue(@event);
                 return(false);
             }
             if (pendingDeliveryList.Any())
             {
                 return(true);
             }
         }
     }
     else if (Ordering == OrderingType.TOTAL_ORDER)
     {
         Queue <Event> pendingDeliveryList;
         lock (pendingDeliveryBuffer) {
             if (!pendingDeliveryBuffer.TryGetValue(subscriber.ProcessName, out pendingDeliveryList))
             {
                 pendingDeliveryList = new Queue <Event>();
                 pendingDeliveryBuffer.Add(subscriber.ProcessName, pendingDeliveryList);
                 pendingDeliveryList.Enqueue(@event);
                 return(false);
             }
             if (pendingDeliveryList.Any())
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Beispiel #17
0
        static void Main(string[] args)
        {
            int           numberOfReplications = 2;
            ProcessHeader processHeader        = new ProcessHeader(args[0], ProcessType.BROKER, args[1], args[2]);
            MessageBroker process = new MessageBroker(processHeader);

            process.LaunchService <MessageBrokerService, IMessageBroker>(((IMessageBroker)process));
            if (args.Length == 4)
            {
                process.ConnectToParentBroker(args[3]);
                ///process.Replicate(args, numberOfReplications);
            }
            if (args.Length == 5)
            {
                //process.Replicate(args, numberOfReplications);
            }


            Console.WriteLine(process);
            Console.ReadLine();
        }
 public bool TryGetPendingEvent(ProcessHeader subscriber, ProcessHeader publisher, out Event @event)
 {
     if (Ordering == OrderingType.NO_ORDER)
     {
     }
     else if (Ordering == OrderingType.FIFO)
     {
         Queue <Event> pendingDeliveryList;
         lock (pendingDeliveryBuffer) {
             pendingDeliveryList = pendingDeliveryBuffer[subscriber + publisher];
             if (pendingDeliveryList.Any())
             {
                 pendingDeliveryList.Dequeue();
             }
             if (pendingDeliveryList.Any())
             {
                 @event = pendingDeliveryList.Peek();
                 return(true);
             }
         }
     }
     else if (Ordering == OrderingType.TOTAL_ORDER)
     {
         Queue <Event> pendingDeliveryList;
         lock (pendingDeliveryBuffer) {
             pendingDeliveryList = pendingDeliveryBuffer[subscriber.ProcessName];
             if (pendingDeliveryList.Any())
             {
                 pendingDeliveryList.Dequeue();
             }
             if (pendingDeliveryList.Any())
             {
                 @event = pendingDeliveryList.Peek();
                 return(true);
             }
         }
     }
     @event = null;
     return(false);
 }
 public void EnqueueEvent(EventContainer eventContainer)
 {
     //Console.WriteLine("EnqueueEvent Thread: " + Thread.CurrentThread.ManagedThreadId + "\n");
     if (Ordering == OrderingType.NO_ORDER)
     {
         EnqueueEventNoOrder(eventContainer);
     }
     else if (Ordering == OrderingType.FIFO)
     {
         //if publisher is unknown, add it
         ProcessHeader publisher = eventContainer.Event.PublisherHeader;
         EventTable    eventTable;
         lock (orderTables) {
             if (!orderTables.TryGetValue(publisher, out eventTable))
             {
                 eventTable = new EventTable(ref brokerQueue, ref subscriberQueue);
                 orderTables.Add(publisher, eventTable);
             }
         }
         eventTable.AddEvent(eventContainer);
     }
     else if (Ordering == OrderingType.TOTAL_ORDER)
     {
         //if broker is unknown, add it
         ProcessHeader broker = eventContainer.SenderBroker;
         EventTable    eventTable;
         lock (orderTables) {
             if (!orderTables.TryGetValue(broker, out eventTable))
             {
                 eventTable = new EventTable(ref brokerQueue, ref subscriberQueue);
                 orderTables.Add(broker, eventTable);
             }
         }
         eventTable.AddEvent(eventContainer);
     }
 }
Beispiel #20
0
 public Subscriber(ProcessHeader newProcessHeader) :
     base(newProcessHeader)
 {
 }
 public InvalidUnsubscriptionException(ProcessHeader header, Exception exception)
     : base("Unsubscription", header, exception)
 {
 }
 public InvalidPublicationException(ProcessHeader header, Exception exception)
     : base("Publication", header, exception)
 {
 }
Beispiel #23
0
 public InvalidInvokationException(string methodName, ProcessHeader header, Exception exception)
     : base("Invalid " + methodName + " on " + header.ProcessType + " " + header.ProcessName, exception)
 {
 }
Beispiel #24
0
 public void AddSubscriber(ProcessHeader subscriber)
 {
     subscriberList.Add(subscriber);
 }
Beispiel #25
0
 public Publisher(ProcessHeader newProcessHeader) :
     base(newProcessHeader)
 {
     SeqNumber = 0;
 }
Beispiel #26
0
 public void RemoveSubscriber(ProcessHeader subscriber)
 {
     subscriberList.Remove(subscriber);
 }
Beispiel #27
0
 public GenericProcess(ProcessHeader newProcessHeader)
 {
     processHeader = newProcessHeader;
     parentBroker  = null;
     cooler        = new List <Task>();
 }
Beispiel #28
0
 public void AddBroker(ProcessHeader broker)
 {
     brokerList.Add(broker);
 }
Beispiel #29
0
 public void RemoveBroker(ProcessHeader broker)
 {
     brokerList.Remove(broker);
 }
Beispiel #30
0
 public InvalidConnectionException(ProcessHeader header, Exception exception)
     : base("Connection", header, exception)
 {
 }