Ignore:
Timestamp:
Jun 20, 2010, 10:27:22 PM (11 years ago)
Author:
Paul Lelgemann
Message:

o Work on the distributed KeySearcher presentation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/KeySearcher/P2P/Storage/StorageHelper.cs

    r1674 r1682  
    33using Cryptool.P2P;
    44using Cryptool.P2P.Internal;
     5using KeySearcher.P2P.Presentation;
    56using KeySearcher.P2P.Tree;
    67
     
    1011    {
    1112        private readonly KeySearcher keySearcher;
     13        private readonly StatisticsGenerator statisticsGenerator;
     14        private readonly StatusContainer statusContainer;
    1215
    13         public StorageHelper(KeySearcher keySearcher)
     16        public StorageHelper(KeySearcher keySearcher, StatisticsGenerator statisticsGenerator, StatusContainer statusContainer)
    1417        {
    1518            this.keySearcher = keySearcher;
     19            this.statisticsGenerator = statisticsGenerator;
     20            this.statusContainer = statusContainer;
    1621        }
    1722
    18         internal static RequestResult UpdateInDht(NodeBase nodeToUpdate)
     23        internal RequestResult UpdateInDht(NodeBase nodeToUpdate)
    1924        {
    2025            var memoryStream = new MemoryStream();
     
    3944            }
    4045
    41             return P2PManager.Store(KeyInDht(nodeToUpdate), memoryStream.ToArray());
     46            return StoreWithStatistic(KeyInDht(nodeToUpdate), memoryStream.ToArray());
    4247        }
    4348
     
    6368            nodeToUpdate.LastUpdate = DateTime.Now;
    6469
    65             var requestResult = P2PManager.Retrieve(KeyInDht(nodeToUpdate));
     70            var requestResult = RetrieveWithStatistic(KeyInDht(nodeToUpdate));
    6671            var nodeBytes = requestResult.Data;
    6772
     
    97102            {
    98103                keySearcher.IntegrateNewResults(nodeToUpdate.Result);
     104                statisticsGenerator.ProcessPatternResults(nodeToUpdate.Result);
    99105            }
    100106
     
    121127            return string.Format("{0}_node_{1}_{2}", node.DistributedJobIdentifier, node.From, node.To);
    122128        }
     129
     130        public RequestResult RetrieveWithStatistic(string key)
     131        {
     132            statusContainer.RetrieveRequests++;
     133            statusContainer.TotalDhtRequests++;
     134            return P2PManager.Retrieve(key);
     135        }
     136
     137        public RequestResult RemoveWithStatistic(string key)
     138        {
     139            statusContainer.RemoveRequests++;
     140            statusContainer.TotalDhtRequests++;
     141            return P2PManager.Remove(key);
     142        }
     143
     144        public RequestResult StoreWithStatistic(string key, byte[] data)
     145        {
     146            statusContainer.StoreRequests++;
     147            statusContainer.TotalDhtRequests++;
     148            return P2PManager.Store(key, data);
     149        }
    123150    }
    124151}
Note: See TracChangeset for help on using the changeset viewer.