Changeset 1647


Ignore:
Timestamp:
Jun 15, 2010, 5:38:07 PM (12 years ago)
Author:
Paul Lelgemann
Message:

o Work on the distributed KeySearcher

Location:
trunk/CrypPlugins/KeySearcher
Files:
2 added
6 edited

Legend:

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

    r1634 r1647  
    640640                GuiLogMessage("P2P network could not be connected.",
    641641                              NotificationLevel.Error);
    642                 throw new ApplicationException("Workaround for wrong error handling... Workspace should be stopped now.");
    643642            }
    644643        }
  • trunk/CrypPlugins/KeySearcher/KeySearcher.csproj

    r1639 r1647  
    111111    </Compile>
    112112    <Compile Include="KeySearcherSettings.cs" />
     113    <Compile Include="P2P\Exceptions\LeafReservedException.cs" />
    113114    <Compile Include="P2P\KeyPoolTree.cs" />
    114115    <Compile Include="P2P\Nodes\Leaf.cs" />
  • trunk/CrypPlugins/KeySearcher/P2P/KeyPoolTree.cs

    r1643 r1647  
    33using System.Numerics;
    44using KeySearcher.Helper;
     5using KeySearcher.P2P.Exceptions;
    56using KeySearcher.P2P.Nodes;
    67
     
    117118        public KeyPattern CurrentPattern()
    118119        {
    119             _currentLeaf.ReserveNode();
     120            if (!_currentLeaf.ReserveLeaf())
     121            {
     122                throw new LeafReservedException();
     123            }
     124
    120125            return _patternPool[CurrentPatternId()];
    121126        }
  • trunk/CrypPlugins/KeySearcher/P2P/Nodes/Leaf.cs

    r1634 r1647  
    3131        }
    3232
    33         public bool ReserveNode()
     33        public bool ReserveLeaf()
    3434        {
    3535            LastReservationDate = DateTime.UtcNow;
  • trunk/CrypPlugins/KeySearcher/P2P/Nodes/P2PHelper.cs

    r1634 r1647  
    9999        private static void UpdateNodeFromDht(Node nodeToUpdate, BinaryReader binaryReader)
    100100        {
    101             nodeToUpdate.LeftChildFinished = binaryReader.ReadBoolean();
    102             nodeToUpdate.RightChildFinished = binaryReader.ReadBoolean();
     101            nodeToUpdate.LeftChildFinished = binaryReader.ReadBoolean() || nodeToUpdate.LeftChildFinished;
     102            nodeToUpdate.RightChildFinished = binaryReader.ReadBoolean() || nodeToUpdate.RightChildFinished;
    103103        }
    104104
    105105        private static void UpdateLeafFromDht(Leaf nodeToUpdate, BinaryReader binaryReader)
    106106        {
    107             long readInt64 = binaryReader.ReadInt64();
    108             var date = DateTime.FromBinary(readInt64);
    109             nodeToUpdate.LastReservationDate = date;
     107            var date = DateTime.FromBinary(binaryReader.ReadInt64());
     108            if (date > nodeToUpdate.LastReservationDate)
     109            {
     110                nodeToUpdate.LastReservationDate = date;
     111            }
    110112        }
    111113
  • trunk/CrypPlugins/KeySearcher/P2P/P2PBruteForce.cs

    r1643 r1647  
    66using Cryptool.PluginBase;
    77using KeySearcher.Helper;
     8using KeySearcher.P2P.Exceptions;
    89
    910namespace KeySearcher.P2P
     
    2324            _settings = settings;
    2425
    25             // TODO when setting is still default (250), it is only displayed as 250 - but the settings-instance contains 0 for that key!
     26            // TODO when setting is still default (21), it is only displayed as 21 - but the settings-instance contains 0 for that key!
    2627            if (settings.ChunkSize == 0)
    2728            {
    28                 settings.ChunkSize = 250;
     29                settings.ChunkSize = 21;
    2930            }
    3031
     
    4243                    NotificationLevel.Info);
    4344
    44                 var result = _keySearcher.BruteForceWithLocalSystem(_keyPoolTree.CurrentPattern());
     45                try
     46                {
     47                    var result = _keySearcher.BruteForceWithLocalSystem(_keyPoolTree.CurrentPattern());
    4548
    46                 if (!_keySearcher.stop)
     49                    if (!_keySearcher.stop)
     50                    {
     51                        _keyPoolTree.ProcessCurrentPatternCalculationResult(result);
     52                    }
     53                    else
     54                    {
     55                        _keySearcher.GuiLogMessage("Brute force was stopped, not saving results...", NotificationLevel.Info);
     56                    }
     57
     58                    _keySearcher.GuiLogMessage(
     59                        string.Format("Best match: {0} with {1}", result.First.Value.key, result.First.Value.value),
     60                        NotificationLevel.Info);               
     61                } catch (LeafReservedException e)
    4762                {
    48                     _keyPoolTree.ProcessCurrentPatternCalculationResult(result);
    49                 } else
    50                 {
    51                     _keySearcher.GuiLogMessage("Brute force was stopped, not saving results...", NotificationLevel.Info);
     63                    _keySearcher.GuiLogMessage("Pattern was reserved before it could be reserved for this CrypTool instance.", NotificationLevel.Warning);
     64                    continue;
    5265                }
    53 
    54                 _keySearcher.GuiLogMessage(
    55                     string.Format("Best match: {0} with {1}", result.First.Value.key, result.First.Value.value),
    56                     NotificationLevel.Info);
    5766            }
    5867
    5968            // Set progress to 100%
    60             if (!_keyPoolTree.LocateNextPattern())
     69            if (!_keySearcher.stop && !_keyPoolTree.LocateNextPattern())
    6170            {
    6271                _keySearcher.showProgress(_keySearcher.costList, 1, 1, 1);
    6372            }
    6473
    65             _keySearcher.GuiLogMessage("Calculation complete or no more free nodes found.", NotificationLevel.Info);     
     74            if (!_keySearcher.stop)
     75                _keySearcher.GuiLogMessage("Calculation complete or no more free nodes found.", NotificationLevel.Info);
    6676        }
    6777    }
Note: See TracChangeset for help on using the changeset viewer.