Changeset 2024


Ignore:
Timestamp:
Oct 28, 2010, 9:37:42 PM (11 years ago)
Author:
Sven Rech
Message:

distributed key searcher fixes:

  • Gives reservation free if you click stop.
  • Reservation of current leave every five minutes
Location:
trunk/CrypPlugins/KeySearcher/P2P
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher/P2P/DistributedBruteForceManager.cs

    r2017 r2024  
    11using System;
     2using System.Collections.Generic;
    23using System.Diagnostics;
    34using System.Numerics;
     
    1314using KeySearcher.P2P.Tree;
    1415using KeySearcherPresentation.Controls;
     16using System.Timers;
    1517
    1618namespace KeySearcher.P2P
     
    112114                }
    113115
     116                var reservationTimer = new Timer {Interval = 5*60*1000};    //Every 5 minutes
     117                reservationTimer.Elapsed += new ElapsedEventHandler(delegate
     118                                                                        {
     119                                                                            currentLeaf.ReserveLeaf();
     120                                                                        });
     121
    114122                keySearcher.GuiLogMessage(
    115123                    "Running pattern #" + displayablePatternId + " of " + patternPool.Length,
     
    120128                try
    121129                {
     130                    LinkedList<KeySearcher.ValueKey> result;
     131
    122132                    status.IsCurrentProgressIndeterminate = false;
    123133                    StopWatch.Start();
    124                     var result = keySearcher.BruteForceWithLocalSystem(patternPool[currentLeaf.PatternId()], true);
    125                     StopWatch.Stop();
    126                     status.IsCurrentProgressIndeterminate = true;
     134                    reservationTimer.Start();
     135                    try
     136                    {
     137                        result = keySearcher.BruteForceWithLocalSystem(patternPool[currentLeaf.PatternId()], true);
     138                    }
     139                    finally
     140                    {
     141                        reservationTimer.Stop();
     142                        reservationTimer.Dispose();
     143                        StopWatch.Stop();
     144                        status.IsCurrentProgressIndeterminate = true;
     145                    }
    127146
    128147                    if (!keySearcher.stop)
     
    148167                                                  NotificationLevel.Info);
    149168                        status.ProgressOfCurrentChunk = 0;
     169                        currentLeaf.GiveLeaveFree();
    150170                    }
    151171                }
  • trunk/CrypPlugins/KeySearcher/P2P/Tree/KeyPoolTree.cs

    r2015 r2024  
    9494            storageHelper.UpdateFromDht(currentNode, true);
    9595            currentNode.UpdateCache();
    96             while (currentNode.IsCalculated() || (!useReservedLeafs && (isReserved = currentNode.IsReserverd())))
     96            while (currentNode.IsCalculated() || (!useReservedLeafs && (isReserved = currentNode.IsReserved())))
    9797            {
    9898                if (isReserved)
  • trunk/CrypPlugins/KeySearcher/P2P/Tree/Leaf.cs

    r2019 r2024  
    1313        private bool isLeafReserved;
    1414        private const int RESERVATIONTIMEOUT = 30;
    15         //--------------------------------------------------------------------------------------------
    16         private long clientIdentifier = Cryptool.PluginBase.Miscellaneous.UniqueIdentifier.GetID();
    17         //--------------------------------------------------------------------------------------------
     15        private long clientIdentifier = -1;
    1816
    1917        public Leaf(StorageHelper storageHelper, KeyQualityHelper keyQualityHelper, Node parentNode, BigInteger id, string distributedJobIdentifier)
     
    6159        {
    6260            LastReservationDate = DateTime.UtcNow;
     61            clientIdentifier = Cryptool.PluginBase.Miscellaneous.UniqueIdentifier.GetID();
    6362            return StorageHelper.UpdateInDht(this).IsSuccessful();
    6463        }
    6564
    66         public override bool IsReserverd()
     65        public void GiveLeaveFree()
     66        {
     67            StorageHelper.UpdateFromDht((this));
     68            //Only give leaf free, if the reservation is still ours:
     69            if (clientIdentifier == Cryptool.PluginBase.Miscellaneous.UniqueIdentifier.GetID())
     70            {
     71                LastReservationDate = new DateTime(0);
     72                clientIdentifier = -1;
     73                isLeafReserved = false;
     74                StorageHelper.UpdateInDht(this);
     75            }
     76        }
     77
     78        public override bool IsReserved()
    6779        {
    6880            return isLeafReserved;
  • trunk/CrypPlugins/KeySearcher/P2P/Tree/Node.cs

    r1703 r2024  
    4040
    4141            // Only load right node, if the left one is finished or reserved
    42             if ((LeftChildFinished || leftChild.IsReserverd()) && !RightChildFinished)
     42            if ((LeftChildFinished || leftChild.IsReserved()) && !RightChildFinished)
    4343            {
    4444                if (rightChild == null)
     
    6969            LoadOrUpdateChildNodes();
    7070
    71             leftChildReserved = LeftChildFinished || leftChild.IsReserverd();
    72             rightChildReserved = RightChildFinished || (rightChild != null && rightChild.IsReserverd());
     71            leftChildReserved = LeftChildFinished || leftChild.IsReserved();
     72            rightChildReserved = RightChildFinished || (rightChild != null && rightChild.IsReserved());
    7373        }
    7474
     
    108108        }
    109109
    110         public override bool IsReserverd()
     110        public override bool IsReserved()
    111111        {
    112112            if (LeftChildFinished && !RightChildFinished)
  • trunk/CrypPlugins/KeySearcher/P2P/Tree/NodeBase.cs

    r2017 r2024  
    114114        }
    115115
    116         public abstract bool IsReserverd();
     116        public abstract bool IsReserved();
    117117
    118118        public abstract Leaf CalculatableLeaf(bool useReservedNodes);
Note: See TracChangeset for help on using the changeset viewer.