Ignore:
Timestamp:
Feb 2, 2010, 6:09:57 PM (12 years ago)
Author:
arnold
Message:

P2PBase: SuperNode-Killing fixed (so P@P-DLLs were updated)
P2PPublisher: Publisher-Exchange now possible, particularly when "old" Publisher takes a "french leave"
P2PJobs: New Architecture for future use of a generic Manager/Worker-infrastructure
KeySearcher: KeyPattern and KeyPatternPool now inherit from P2PJobs (IJobPart, IJobStack)

Location:
trunk/CrypPlugins/PeerToPeerPublisher
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/PeerToPeerPublisher/P2PPublisher.cs

    r1107 r1129  
    186186            }
    187187
     188            // when Workspace has stopped and has been started again
     189            if (this.p2pPublisher != null && !this.p2pPublisher.Started)
     190            {
     191                this.p2pPublisher.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
     192            }
     193
    188194            if (this.p2pPublisher == null)
    189195            {
     
    192198                this.p2pPublisher.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
    193199            }
    194             if (this.p2pPublisher != null && !this.p2pPublisher.Started) // when Workspace has stopped and has been started again
    195             {
    196                 this.p2pPublisher.Start(this.settings.TopicName, (long)this.settings.SendAliveMessageInterval);
    197             }
    198200        }
    199201
  • trunk/CrypPlugins/PeerToPeerPublisher/P2PPublisherBase.cs

    r1115 r1129  
    4242        }
    4343
     44        // Publisher-exchange extension - Arnie 2010.02.02
     45        /// <summary>
     46        /// Interval for waiting for other Publishers Pong in milliseconds!
     47        /// </summary>
     48        const long INTERVAL_WAITING_FOR_OTHER_PUBS_PONG = 10000;
     49        Timer waitingForOtherPublishersPong;
     50        /// <summary>
     51        /// if this value is set, you are between the TimeSpan of checking liveness of the other peer.
     52        /// If Timespan runs out without receiving a Pong-Msg from the other Publisher, assume its functionality
     53        /// </summary>
     54        PeerId otherPublisherPeer = null;
     55        bool otherPublisherHadResponded = false;
     56
    4457        #endregion
    4558
     
    8598            if (byRead != null)
    8699            {
    87                 // this entry? Then no problem! Otherwise abort Starting the publisher!
     100                // if a different Publisher was found at the DHT entry, send a ping msg
     101                // and wait for Pong-Response. When this won't arrive in the given TimeSpan,
     102                // assume the Publishing functionality
    88103                if (byRead != myPeerId)
    89                 {
    90                     GuiLogging("Can't store Publisher in the DHT because the Entry was already occupied.", NotificationLevel.Error);
    91                     return false;
     104                {   
     105                    if (this.waitingForOtherPublishersPong == null)
     106                    {
     107                        this.otherPublisherHadResponded = false;
     108                        this.otherPublisherPeer = byRead;
     109                        this.waitingForOtherPublishersPong = new Timer(OnWaitingForOtherPublishersPong,
     110                            null, INTERVAL_WAITING_FOR_OTHER_PUBS_PONG, INTERVAL_WAITING_FOR_OTHER_PUBS_PONG);
     111
     112                        this.p2pControl.SendToPeer(PubSubMessageType.Ping, byRead);
     113
     114                        GuiLogging("Another Publisher was found. Waiting for Pong-Response for "
     115                            + INTERVAL_WAITING_FOR_OTHER_PUBS_PONG / 1000 + " seconds. When it won't response "
     116                            + "assume its functionality.", NotificationLevel.Debug);
     117                        return false;
     118                    }
     119                    else
     120                    {
     121                        // if this code will be executed, there's an error in this class logic
     122                        GuiLogging("Can't store Publisher in the DHT because the Entry was already occupied.", NotificationLevel.Error);
     123                        return false;
     124                    }
    92125                }
    93126            }
     
    158191                this.timerWaitingForAliveMsg = null;
    159192            }
     193            // Publisher-exchange extension - Arnie 2010.02.02
     194            if (this.waitingForOtherPublishersPong != null)
     195            {
     196                this.waitingForOtherPublishersPong.Dispose();
     197                this.waitingForOtherPublishersPong = null;
     198            }
    160199
    161200            GuiLogging("Deregister message-received-events", NotificationLevel.Debug);
     
    174213        protected virtual void p2pControl_OnSystemMessageReceived(PeerId sender, PubSubMessageType msgType)
    175214        {
     215            if (sender == ownPeerId)
     216            {
     217                GuiLogging("Received Message from OWN Peer... Strange stuff.", NotificationLevel.Debug);
     218                return;
     219            }
     220
    176221            switch (msgType)
    177222            {
     
    195240                case PubSubMessageType.Alive:
    196241                case PubSubMessageType.Pong:
     242                    if (this.otherPublisherPeer != null && this.otherPublisherPeer == sender)
     243                    {
     244                        this.otherPublisherHadResponded = true;
     245                        this.otherPublisherPeer = null;
     246                    }
    197247                    break;
    198248                case PubSubMessageType.Ping:
     
    278328        #endregion
    279329
     330        // Publisher-exchange extension - Arnie 2010.02.02
     331        /// <summary>
     332        /// Callback function for waitingForOtherPublishersPong-object. Will be only executed, when a
     333        /// different Publisher-ID was found in the DHT, to check if the "old" Publisher is still
     334        /// alive!
     335        /// </summary>
     336        /// <param name="state"></param>
     337        private void OnWaitingForOtherPublishersPong(object state)
     338        {
     339            if (this.otherPublisherHadResponded)
     340            {
     341                GuiLogging("Can't assume functionality of an alive Publishers. So starting this workspace isn't possible!", NotificationLevel.Error);
     342            }
     343            else
     344            {
     345                if (this.waitingForOtherPublishersPong != null)
     346                {
     347                    this.waitingForOtherPublishersPong.Dispose();
     348                    this.waitingForOtherPublishersPong = null;
     349                }
     350                GuiLogging("First trial to assume old Publishers functionality.", NotificationLevel.Debug);
     351                // we have to delete all OLD Publishers entries to assume its functionality
     352                DHT_CommonManagement.DeleteAllPublishersEntries(ref this.p2pControl, this.topic);
     353                Start(this.topic, this.aliveMessageInterval);
     354            }
     355        }
     356
    280357        // Only for testing the (De-)Serialization of SubscribersManagement
    281358        public void TestSerialization()
Note: See TracChangeset for help on using the changeset viewer.